}
constraints.clear();
constraints.addAll(constraintModel.getAllCompositeConstraint().values());
for (Iterator<CompositeConstraint> itConstraint = constraints.iterator() ; itConstraint.hasNext() ; ) {
CompositeConstraint gc = itConstraint.next();
boolean newFeature = false;
boolean allNewFeature = true;
for (Iterator<Feature> itFeature = gc.getSinkFeatureSet().iterator() ; itFeature.hasNext() ; ) {
Feature constraintFeature = itFeature.next();
if (htNameMap.containsKey(constraintFeature.getID())) {
newFeature = true;
} else {
allNewFeature = false;
}
}
for (Iterator<Feature> itFeature = gc.getSourceFeatureSet().iterator() ; itFeature.hasNext() ; ) {
Feature constraintFeature = itFeature.next();
if (htNameMap.containsKey(constraintFeature.getID())) {
newFeature = true;
} else {
allNewFeature = false;
}
}
if (newFeature) {
CompositeConstraint newConstraint = null;
if (allNewFeature) {
newConstraint = constraintModelEditor.addCompositeConstraint();
compositeConstraintEditor.setPLType(newConstraint , gc.getPLType());
compositeConstraintEditor.setSinkType(newConstraint , gc.getSinkType());
compositeConstraintEditor.setSourceType(newConstraint , gc.getSourceType());
htNameMap.put(gc.getID() , newConstraint.getID());
} else {
newConstraint = gc;
}
for (Iterator<Feature> itFeature = gc.getSourceFeatureSet().iterator() ; itFeature.hasNext() ; ) {
Feature constraintFeature = itFeature.next();
if (allNewFeature || htNameMap.containsKey(constraintFeature.getID())) {
constraintFeature = featureModel.getFeature(htNameMap.get(constraintFeature.getID()));
compositeConstraintEditor.addSourceFeature(newConstraint , constraintFeature);
}
}
for (Iterator<Feature> itFeature = gc.getSinkFeatureSet().iterator() ; itFeature.hasNext() ; ) {
Feature constraintFeature = itFeature.next();
if (allNewFeature || htNameMap.containsKey(constraintFeature.getID())) {
constraintFeature = featureModel.getFeature(htNameMap.get(constraintFeature.getID()));
compositeConstraintEditor.addSinkFeature(newConstraint , constraintFeature);
}
}
}
}
constraints.clear();
constraints.addAll(constraintModel.getAllVPConstraint().values());
for (Iterator<VPConstraint> itConstraint = constraints.iterator() ; itConstraint.hasNext() ; ) {
VPConstraint gc = itConstraint.next();
boolean newFeature = false;
boolean allNewFeature = true;
for (Iterator<Feature> itFeature = gc.getSinkFeatureSet().iterator() ; itFeature.hasNext() ; ) {
Feature constraintFeature = itFeature.next();
if (htNameMap.containsKey(constraintFeature.getID())) {
newFeature = true;
} else {
allNewFeature = false;
}
}
for (Iterator<Feature> itFeature = gc.getSourceFeatureSet().iterator() ; itFeature.hasNext() ; ) {
Feature constraintFeature = itFeature.next();
if (htNameMap.containsKey(constraintFeature.getID())) {
newFeature = true;
} else {
allNewFeature = false;
}
}
if (newFeature) {
VPConstraint newConstraint = null;
if (allNewFeature) {
newConstraint = constraintModelEditor.addVPConstraint();
vpConstraintEditor.setType(newConstraint , gc.getType());
htNameMap.put(gc.getID() , newConstraint.getID());
} else {
newConstraint = gc;
}
for (Iterator<Feature> itFeature = gc.getSourceFeatureSet().iterator() ; itFeature.hasNext() ; ) {
Feature constraintFeature = itFeature.next();
if (allNewFeature || htNameMap.containsKey(constraintFeature.getID())) {
constraintFeature = featureModel.getFeature(htNameMap.get(constraintFeature.getID()));
vpConstraintEditor.addSourceFeature(newConstraint , constraintFeature);
}
}
for (Iterator<Feature> itFeature = gc.getSinkFeatureSet().iterator() ; itFeature.hasNext() ; ) {
Feature constraintFeature = itFeature.next();
if (allNewFeature || htNameMap.containsKey(constraintFeature.getID())) {
constraintFeature = featureModel.getFeature(htNameMap.get(constraintFeature.getID()));
vpConstraintEditor.addSinkFeature(newConstraint , constraintFeature);
}
}
}
}
constraints.clear();
constraints.addAll(constraintModel.getAllCFRelation().values());
for (Iterator<CFRelation> itConstraint = constraints.iterator() ; itConstraint.hasNext() ; ) {
CFRelation gc = itConstraint.next();
boolean newFeature = false;
Feature cfFeature = gc.getFeature();
if (htNameMap.containsKey(gc.getFeature().getID())) {
cfFeature = featureModel.getFeature(htNameMap.get(gc.getFeature().getID()));
newFeature = true;
}
Constraint cfConstraint = gc.getConstraint();
if (htNameMap.containsKey(gc.getConstraint().getID())) {
cfConstraint = constraintModel.getConstraint(htNameMap.get(gc.getConstraint().getID()));
newFeature = true;
}
if (newFeature) {
CFRelation newConstraint = constraintModelEditor.addCFRelation(cfFeature , cfConstraint , gc.isSource() , gc.getModifier());
htNameMap.put(gc.getID() , newConstraint.getID());
}
}
}