Code Duplication    Length = 41-44 lines in 2 locations

src/main/java/it/cnr/istc/pst/platinum/ai/executive/pdb/ExecutivePlanDataBase.java 2 locations

@@ 1163-1206 (lines=44) @@
1160
	 * @param bounds
1161
	 * @throws Exception
1162
	 */
1163
	protected void prepareDuringTemporalConstraint(ExecutionNode reference, ExecutionNode target, long[][] bounds) 
1164
			throws Exception {
1165
		
1166
		// create constraint
1167
		DuringIntervalConstraint constraint = this.facade.
1168
				createTemporalConstraint(TemporalConstraintType.DURING);
1169
		// set references
1170
		constraint.setReference(reference.getInterval());
1171
		constraint.setTarget(target.getInterval());
1172
		
1173
		// set bounds
1174
		constraint.setStartTimeBound(bounds[0]);
1175
		constraint.setEndTimeBound(bounds[1]);
1176
		// propagate temporal constraint
1177
		this.facade.propagate(constraint);
1178
		
1179
		
1180
		// add execution dependencies
1181
		this.addStartExecutionDependency(reference, target, new ExecutionNodeStatus[] {
1182
				ExecutionNodeStatus.IN_EXECUTION
1183
		});
1184
		
1185
		this.addEndExecutionDependency(reference, target, new ExecutionNodeStatus[] {
1186
				ExecutionNodeStatus.IN_EXECUTION,
1187
		});
1188
		
1189
		this.addEndExecutionDependency(target, reference, new ExecutionNodeStatus[] {
1190
				ExecutionNodeStatus.EXECUTED,
1191
		});
1192
		
1193
		
1194
		
1195
		
1196
		// add stop execution condition
1197
		this.addStopExecutionDependency(reference, target, new ExecutionNodeStatus[] {
1198
				ExecutionNodeStatus.IN_EXECUTION,
1199
				ExecutionNodeStatus.FAILURE,
1200
		});
1201
		
1202
		// add stop execution condition
1203
		this.addStopExecutionDependency(target, reference, new ExecutionNodeStatus[] {
1204
				ExecutionNodeStatus.EXECUTED,
1205
				ExecutionNodeStatus.FAILURE,
1206
				ExecutionNodeStatus.WAITING
1207
		});
1208
	}
1209
	
@@ 1217-1257 (lines=41) @@
1214
	 * @param bounds
1215
	 * @throws Exception
1216
	 */
1217
	protected void prepareContainsTemporalConstraint(ExecutionNode reference, ExecutionNode target, long[][] bounds) 
1218
			throws Exception {
1219
		
1220
		// create constraint
1221
		ContainsIntervalConstraint constraint = this.facade.
1222
				createTemporalConstraint(TemporalConstraintType.CONTAINS);
1223
		// set references
1224
		constraint.setReference(reference.getInterval());
1225
		constraint.setTarget(target.getInterval());
1226
		
1227
		// set bounds
1228
		constraint.setStartTimeBound(bounds[0]);
1229
		constraint.setEndTimeBound(bounds[1]);
1230
		// propagate temporal constraint
1231
		this.facade.propagate(constraint);
1232
		
1233
		// add execution dependencies
1234
		this.addEndExecutionDependency(reference, target, new ExecutionNodeStatus[] {
1235
				ExecutionNodeStatus.EXECUTED,
1236
		});
1237
		
1238
		this.addStartExecutionDependency(target, reference, new ExecutionNodeStatus[] {
1239
				ExecutionNodeStatus.IN_EXECUTION
1240
		});
1241
		
1242
		this.addEndExecutionDependency(target, reference, new ExecutionNodeStatus[] { 
1243
				ExecutionNodeStatus.IN_EXECUTION,
1244
		});
1245
		
1246
		
1247
		// add stop execution condition
1248
		this.addStopExecutionDependency(reference, target, new ExecutionNodeStatus[] {
1249
				ExecutionNodeStatus.EXECUTED,
1250
				ExecutionNodeStatus.FAILURE,
1251
				ExecutionNodeStatus.WAITING
1252
		});
1253
		
1254
		// add stop execution condition
1255
		this.addStopExecutionDependency(target, reference, new ExecutionNodeStatus[] {
1256
				ExecutionNodeStatus.IN_EXECUTION,
1257
				ExecutionNodeStatus.FAILURE,
1258
				
1259
		});
1260
	}