public AtomSet(FeatureModel featureModel, ConstraintModel constraintModel){
Map allFeatures = featureModel.getAllFeature();
Iterator e = allFeatures.keySet().iterator();
allAtomedFeatures = new LinkedHashMap<Feature, AtomedFeature>();
while(e.hasNext()){
Feature f = (Feature)allFeatures.get(e.next());
AtomedFeature x = new AtomedFeature(f);
allAtomedFeatures.put(f, x);
}
Map include = featureModel.getAllFeatureRelation(FeatureRelation.DECOMPOSE);
Map dimensionValue = featureModel.getAllFeatureRelation(FeatureRelation.ATTRIBUTE);
Map require = featureModel.getAllFeatureRelation(FeatureRelation.REQUIRE);
// ����include��ϵ������ԭ�Ӽ�
// allAtomedFeatures��ʾ��feature������Ӧ��ԭ�Ӽ�
if(include != null){
e = include.keySet().iterator();
// System.out.println(include);
// if (!e.hasNext()) System.out.println("!!!!!!!!!!");
while(e.hasNext()){
FeatureRelation r = (FeatureRelation)include.get(e.next());
Feature startFeature = r.getStartFeature();
Feature endFeature = r.getEndFeature();
// System.out.print(endFeature.getName()+" "+startFeature.getName());
/* if(featureModel.getParentFeature(endFeature.getID())!=null)
System.out.println(" "+featureModel.getParentFeature(endFeature.getID()).getName());
else
System.out.println(" null");*/
if (endFeature.getVariability().equals(de.FeatureModellingTool.FeatureModel.Variability.Mandatory)
&&
featureModel.getParentFeature(endFeature.getID()) == startFeature){
if (allAtomedFeatures.get(startFeature).getAtomSetNum() == -1
&&
allAtomedFeatures.get(endFeature).getAtomSetNum() == -1){
int n = AtomedFeature.increaseSet();
allAtomedFeatures.get(startFeature).setAtomSetNum(n);
allAtomedFeatures.get(endFeature).setAtomSetNum(n);
}
else if (allAtomedFeatures.get(startFeature).getAtomSetNum() == -1){
int n = allAtomedFeatures.get(endFeature).getAtomSetNum();
allAtomedFeatures.get(startFeature).setAtomSetNum(n);
}
else if (allAtomedFeatures.get(endFeature).getAtomSetNum() == -1){
int n = allAtomedFeatures.get(startFeature).getAtomSetNum();
allAtomedFeatures.get(endFeature).setAtomSetNum(n);
}
else{
int m = allAtomedFeatures.get(startFeature).getAtomSetNum();
int n = allAtomedFeatures.get(endFeature).getAtomSetNum();
Iterator i = allAtomedFeatures.keySet().iterator();
while(i.hasNext()){
AtomedFeature cur = allAtomedFeatures.get(i.next());
if(cur.getAtomSetNum() == n)
cur.setAtomSetNum(m);
}
}
}//end if
else{
if (allAtomedFeatures.get(startFeature).getAtomSetNum() == -1){
int n = AtomedFeature.increaseSet();
allAtomedFeatures.get(startFeature).setAtomSetNum(n);
}
if (allAtomedFeatures.get(endFeature).getAtomSetNum() == -1){
int n = AtomedFeature.increaseSet();
allAtomedFeatures.get(endFeature).setAtomSetNum(n);
}
}//end else
}//end while
}
// ����dimensionValue��ϵ������ԭ�Ӽ�
if(dimensionValue != null){
e = dimensionValue.keySet().iterator();
while(e.hasNext()){
FeatureRelation r = (FeatureRelation)dimensionValue.get(e.next());
Feature startFeature = r.getStartFeature();
Feature endFeature = r.getEndFeature();
/* System.out.print(endFeature.getName()+" "+startFeature.getName());
if(featureModel.getParentFeature(endFeature.getID())!=null)
System.out.println(" "+featureModel.getParentFeature(endFeature.getID()).getName());
else
System.out.println(" null");*/
if (endFeature.getVariability().equals(de.FeatureModellingTool.FeatureModel.Variability.Mandatory)
&&
featureModel.getParentFeature(endFeature.getID()) == startFeature){
if (allAtomedFeatures.get(startFeature).getAtomSetNum() == -1
&&
allAtomedFeatures.get(endFeature).getAtomSetNum() == -1){
int n = AtomedFeature.increaseSet();
allAtomedFeatures.get(startFeature).setAtomSetNum(n);
allAtomedFeatures.get(endFeature).setAtomSetNum(n);
}
else if (allAtomedFeatures.get(startFeature).getAtomSetNum() == -1){
int n = allAtomedFeatures.get(endFeature).getAtomSetNum();
allAtomedFeatures.get(startFeature).setAtomSetNum(n);
}
else if (allAtomedFeatures.get(endFeature).getAtomSetNum() == -1){
int n = allAtomedFeatures.get(startFeature).getAtomSetNum();
allAtomedFeatures.get(endFeature).setAtomSetNum(n);
}
else{
int m = allAtomedFeatures.get(startFeature).getAtomSetNum();
int n = allAtomedFeatures.get(endFeature).getAtomSetNum();
Iterator i = allAtomedFeatures.keySet().iterator();
while(i.hasNext()){
AtomedFeature cur = allAtomedFeatures.get(i.next());
if(cur.getAtomSetNum() == n)
cur.setAtomSetNum(m);
}
}
}//end if
else{
if (allAtomedFeatures.get(startFeature).getAtomSetNum() == -1){
int n = AtomedFeature.increaseSet();
allAtomedFeatures.get(startFeature).setAtomSetNum(n);
}
if (allAtomedFeatures.get(endFeature).getAtomSetNum() == -1){
int n = AtomedFeature.increaseSet();
allAtomedFeatures.get(endFeature).setAtomSetNum(n);
}
}//end else
}//end while
}
// ����require��ϵ������ԭ�Ӽ�
if(require != null){
e = require.keySet().iterator();
while(e.hasNext()){
FeatureRelation r = (FeatureRelation)require.get(e.next());
Feature startFeature = r.getStartFeature();
Feature endFeature = r.getEndFeature();
/* System.out.print(endFeature.getName()+" "+startFeature.getName());
if(featureModel.getParentFeature(endFeature.getID())!=null)
System.out.println(" "+featureModel.getParentFeature(endFeature.getID()).getName());
else
System.out.println(" null");*/
if (startFeature.getVariability().equals(de.FeatureModellingTool.FeatureModel.Variability.Mandatory)
&&
featureModel.getParentFeature(endFeature.getID()) == startFeature){
if (allAtomedFeatures.get(startFeature).getAtomSetNum() == -1
&&
allAtomedFeatures.get(endFeature).getAtomSetNum() == -1){
int n = AtomedFeature.increaseSet();
allAtomedFeatures.get(startFeature).setAtomSetNum(n);
allAtomedFeatures.get(endFeature).setAtomSetNum(n);
}
else if (allAtomedFeatures.get(startFeature).getAtomSetNum() == -1){
int n = allAtomedFeatures.get(endFeature).getAtomSetNum();
allAtomedFeatures.get(startFeature).setAtomSetNum(n);
}
else if (allAtomedFeatures.get(endFeature).getAtomSetNum() == -1){
int n = allAtomedFeatures.get(startFeature).getAtomSetNum();
allAtomedFeatures.get(endFeature).setAtomSetNum(n);
}
else{
int m = allAtomedFeatures.get(startFeature).getAtomSetNum();
int n = allAtomedFeatures.get(endFeature).getAtomSetNum();
Iterator i = allAtomedFeatures.keySet().iterator();
while(i.hasNext()){
AtomedFeature cur = allAtomedFeatures.get(i.next());
if(cur.getAtomSetNum() == n)
cur.setAtomSetNum(m);
}
}
}//end if
else{
if (allAtomedFeatures.get(startFeature).getAtomSetNum() == -1){
int n = AtomedFeature.increaseSet();
allAtomedFeatures.get(startFeature).setAtomSetNum(n);
}
if (allAtomedFeatures.get(endFeature).getAtomSetNum() == -1){
int n = AtomedFeature.increaseSet();
allAtomedFeatures.get(endFeature).setAtomSetNum(n);
}
}//end else
}//end while
}
// ����û�о�����ϵ����������Щ�������Զ�ռһ��ԭ�Ӽ�
e = allAtomedFeatures.keySet().iterator();
while(e.hasNext()){
Feature f = (Feature)e.next();
AtomedFeature a = allAtomedFeatures.get(f);
if(a.atomSetNum == -1){
int n = AtomedFeature.increaseSet();
a.setAtomSetNum(n);
}