constraints.clear();
constraints.addAll(featureModel.getAllFeatureRelation().values());
for (Iterator<FeatureRelation> itRelation = constraints.iterator() ; itRelation.hasNext() ; ) {
FeatureRelation relation = itRelation.next();
if (!htNameMap.containsKey(relation.getID())) {
Feature start = featureModel.getFeature(htNameMap.get(relation.getStartFeature().getID()));
Feature end = featureModel.getFeature(htNameMap.get(relation.getEndFeature().getID()));
if (start!=null || end!=null) {
if (start==null)
start = relation.getStartFeature();
if (end==null)
end = relation.getEndFeature();
FeatureRelation newRelation = featureModelEditor.addRelation(relation.getName() , start, end);
htNameMap.put(relation.getID() , newRelation.getID());
}
}
}
constraints.clear();
constraints.addAll(constraintModel.getAllGroupConstraint().values());
for (Iterator<GroupConstraint> itConstraint = constraints.iterator() ; itConstraint.hasNext() ; ) {
GroupConstraint gc = itConstraint.next();
boolean newFeature = false;
boolean allNewFeature = true;
for (Iterator<Feature> itFeature = gc.getFeatureSet().iterator() ; itFeature.hasNext() ; ) {
Feature constraintFeature = itFeature.next();
if (htNameMap.containsKey(constraintFeature.getID())) {
newFeature = true;
} else {
allNewFeature = false;
}
}
GroupConstraint newConstraint = null;
if (newFeature) {
if (allNewFeature) {
newConstraint = constraintModelEditor.addGroupConstraint();
groupConstraintEditor.setType(newConstraint , gc.getType());
htNameMap.put(gc.getID() , newConstraint.getID());
} else {
newConstraint = gc;
}
for (Iterator<Feature> itFeature = gc.getFeatureSet().iterator() ; itFeature.hasNext() ; ) {
Feature constraintFeature = itFeature.next();
if (allNewFeature || htNameMap.containsKey(constraintFeature.getID())) {
constraintFeature = featureModel.getFeature(htNameMap.get(constraintFeature.getID()));
groupConstraintEditor.addFeature(newConstraint , constraintFeature);
}
}
}
}
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();