Code Duplication    Length = 39-40 lines in 2 locations

src/main/java/it/cnr/istc/pst/platinum/ai/framework/microkernel/resolver/timeline/scheduling/TimelineSchedulingResolver.java 2 locations

@@ 206-245 (lines=40) @@
203
		DecisionPrecedenceConstraint pc1 = new DecisionPrecedenceConstraint(conflict, reference, target, this.schedulingCost);
204
		DecisionPrecedenceConstraint pc2 = new DecisionPrecedenceConstraint(conflict, target, reference, this.schedulingCost);
205
		
206
		try
207
		{
208
			// create relation reference -> target
209
			BeforeRelation before = this.component.create(RelationType.BEFORE, reference, target);
210
			// set bounds
211
			before.setBound(new long[] {
212
					0, 
213
					this.component.getHorizon()});
214
			
215
			// add create relation
216
			pc1.addCreatedRelation(before);
217
			
218
			// activate relation
219
			if (this.component.activate(before)) {
220
				// add activated relations
221
				pc1.addActivatedRelation(before);
222
			}
223
			
224
			// check consistency
225
			this.tdb.verify();
226
			// add solution and deactivate relation
227
			conflict.addSolution(pc1);
228
		}
229
		catch (RelationPropagationException | ConsistencyCheckException ex) {
230
			// discard relation
231
			debug("Unfeasible precedence constraint:\n"
232
					+ "\t- reference: " + reference + "\n"
233
					+ "\t- target: " + target + "\n");
234
		}
235
		finally {
236
			
237
			// deactivate relation
238
			for (Relation rel : pc1.getActivatedRelations()) {
239
				// deactivate relation
240
				this.component.deactivate(rel);
241
			}
242
			
243
			for (Relation rel : pc1.getCreatedRelations()) {
244
				// delete relation
245
				this.component.delete(rel);
246
			}
247
		}
248
		
@@ 250-288 (lines=39) @@
247
		}
248
		
249
		
250
		try
251
		{
252
			// create relation reference -> target
253
			BeforeRelation before = this.component.create(RelationType.BEFORE, target, reference);
254
			// set bounds
255
			before.setBound(new long[] {
256
					0, 
257
					this.component.getHorizon()});
258
			
259
			// add created relation
260
			pc2.addCreatedRelation(before);
261
			// check if relation is feasible
262
			if (this.component.activate(before)) {
263
				// add activated relation
264
				pc2.addActivatedRelation(before);
265
			}
266
			
267
			// check consistency
268
			this.tdb.verify();
269
			// add solution and deactivate relation
270
			conflict.addSolution(pc2);
271
		}
272
		catch (RelationPropagationException | ConsistencyCheckException ex) {
273
			// discard relation
274
			debug("Unfeasible precedence constraint:\n"
275
					+ "\t- reference: " + target + "\n"
276
					+ "\t- target: " + reference + "\n");
277
		}
278
		finally {
279
			
280
			// deactivate relation
281
			for (Relation rel : pc2.getActivatedRelations()) {
282
				// deactivate relation
283
				this.component.deactivate(rel);
284
			}
285
			
286
			for (Relation rel : pc2.getCreatedRelations()) {
287
				// delete relation
288
				this.component.delete(rel);
289
			}
290
		}
291