Update of /cvsroot/modelwizard/source/Model Wizard Plugin/src/net/sourceforge/modelWizard/profileViewer/drawingInformation In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv3484/src/net/sourceforge/modelWizard/profileViewer/drawingInformation Modified Files: ClassInformation.java AssociationInformation.java DrawingInformation.java Log Message: removed unused imports or reformatted import order (ctrl-shift-o) Index: DrawingInformation.java =================================================================== RCS file: /cvsroot/modelwizard/source/Model Wizard Plugin/src/net/sourceforge/modelWizard/profileViewer/drawingInformation/DrawingInformation.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DrawingInformation.java 5 May 2006 15:34:25 -0000 1.4 --- DrawingInformation.java 24 Oct 2006 21:43:59 -0000 1.5 *************** *** 30,34 **** import net.sourceforge.modelWizard.Profile.util.ProfileSwitch; import net.sourceforge.modelWizard.backingModelAbstraction.IAssociation; - import net.sourceforge.modelWizard.backingModelAbstraction.IAssociationClass; import net.sourceforge.modelWizard.backingModelAbstraction.IClass; import net.sourceforge.modelWizard.backingModelAbstraction.IMethod; --- 30,33 ---- Index: ClassInformation.java =================================================================== RCS file: /cvsroot/modelwizard/source/Model Wizard Plugin/src/net/sourceforge/modelWizard/profileViewer/drawingInformation/ClassInformation.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ClassInformation.java 7 Nov 2005 16:19:15 -0000 1.3 --- ClassInformation.java 24 Oct 2006 21:43:59 -0000 1.4 *************** *** 1,157 **** ! /* ! * Created on Sep 27, 2005 ! * @author stjerman ! * <copyright> ! * ! * Copyright (c) 2005 Cisco Systems Inc, ! * All rights reserved. This program and the accompanying materials ! * are made available under the terms of the BSD License ! * which accompanies this distribution. ! * ! * Contributors: ! * CISCO - Initial API and implementation ! * ! * </copyright> ! */ ! package net.sourceforge.modelWizard.profileViewer.drawingInformation; ! ! import java.util.ArrayList; ! ! import net.sourceforge.modelWizard.Profile.Diagram; ! import net.sourceforge.modelWizard.backingModelAbstraction.IAssociation; ! import net.sourceforge.modelWizard.backingModelAbstraction.IAssociationClass; ! import net.sourceforge.modelWizard.backingModelAbstraction.IClass; ! import net.sourceforge.modelWizard.backingModelAbstraction.INamedElement; ! ! public class ClassInformation { ! ! private String name; ! ! private ArrayList props = new ArrayList(); ! ! private ArrayList methods = new ArrayList(); ! ! private String comment; ! ! private INamedElement modelElement; ! ! private boolean isAssoc = false; ! ! private ArrayList ends = new ArrayList(); ! ! private boolean isStub = false; ! ! private Diagram diagram; ! ! private ElementInfo elementInfo; ! ! ClassInformation(INamedElement element, String description, Diagram diagram, ! ElementInfo info) { ! name = element.getName(); ! elementInfo = info; ! this.modelElement = element; ! this.diagram = diagram; ! comment = TextUtilities.wordWrap(description, 40); ! if (element instanceof IAssociation) ! isAssoc = true; ! } ! ! ClassInformation(INamedElement element) { ! this.name = element.getName(); ! this.modelElement = element; ! elementInfo = new ElementInfo(ElementInfo.NORMAL, name); ! comment = null; ! isStub = true; ! } ! ! public boolean isStub() { ! return isStub; ! } ! ! public String getComment() { ! return comment; ! } ! ! public boolean isAssoc() { ! return isAssoc; ! } ! ! public boolean isAbstract() { ! boolean isAbstract = false; ! if (modelElement instanceof IClass ) ! isAbstract = ((IClass) modelElement).isAbstract(); ! return isAbstract; ! } ! ! public ArrayList getDisplayMethods() { ! if (diagram == null || diagram.isShowDetail()) ! return methods; ! else ! return new ArrayList(); ! } ! ! public ArrayList getMethods() { ! return methods; ! } ! ! public ArrayList getProps() { ! return props; ! } ! ! public String getName() { ! return name; ! } ! ! public ArrayList getDisplayProperties() { ! if (diagram == null || diagram.isShowDetail()) ! return props; ! else ! return new ArrayList(); ! } ! ! public ElementInfo getDisplayName() { ! return elementInfo; ! } ! ! public INamedElement getModelElement() { ! return modelElement; ! } ! ! public ArrayList getEnds() { ! return ends; ! } ! ! public short getPageNo() { ! if (diagram == null) ! return 1; ! return diagram.getDiagramPageNumber(); ! } ! ! public int getSuperClass() { ! if (diagram == null) ! return 0; ! if (!diagram.isSetShowSuperClasses()) ! return 0; ! else ! return diagram.getShowSuperClasses(); ! } ! ! public String getAlias() { ! if (diagram == null) ! return null; ! return diagram.getAlias(); ! } ! ! public String toString() { ! String ret = "Class " + getName() + "\n"; ! ret += " Props:" + props.toString() + "\n"; ! ret += " Methods:" + methods.toString() + "\n"; ! return ret; ! } ! ! public boolean isShowDetail() { ! if (diagram == null) ! return true; ! return diagram.isShowDetail(); ! } ! } --- 1,156 ---- ! /* ! * Created on Sep 27, 2005 ! * @author stjerman ! * <copyright> ! * ! * Copyright (c) 2005 Cisco Systems Inc, ! * All rights reserved. This program and the accompanying materials ! * are made available under the terms of the BSD License ! * which accompanies this distribution. ! * ! * Contributors: ! * CISCO - Initial API and implementation ! * ! * </copyright> ! */ ! package net.sourceforge.modelWizard.profileViewer.drawingInformation; ! ! import java.util.ArrayList; ! ! import net.sourceforge.modelWizard.Profile.Diagram; ! import net.sourceforge.modelWizard.backingModelAbstraction.IAssociation; ! import net.sourceforge.modelWizard.backingModelAbstraction.IClass; ! import net.sourceforge.modelWizard.backingModelAbstraction.INamedElement; ! ! public class ClassInformation { ! ! private String name; ! ! private ArrayList props = new ArrayList(); ! ! private ArrayList methods = new ArrayList(); ! ! private String comment; ! ! private INamedElement modelElement; ! ! private boolean isAssoc = false; ! ! private ArrayList ends = new ArrayList(); ! ! private boolean isStub = false; ! ! private Diagram diagram; ! ! private ElementInfo elementInfo; ! ! ClassInformation(INamedElement element, String description, Diagram diagram, ! ElementInfo info) { ! name = element.getName(); ! elementInfo = info; ! this.modelElement = element; ! this.diagram = diagram; ! comment = TextUtilities.wordWrap(description, 40); ! if (element instanceof IAssociation) ! isAssoc = true; ! } ! ! ClassInformation(INamedElement element) { ! this.name = element.getName(); ! this.modelElement = element; ! elementInfo = new ElementInfo(ElementInfo.NORMAL, name); ! comment = null; ! isStub = true; ! } ! ! public boolean isStub() { ! return isStub; ! } ! ! public String getComment() { ! return comment; ! } ! ! public boolean isAssoc() { ! return isAssoc; ! } ! ! public boolean isAbstract() { ! boolean isAbstract = false; ! if (modelElement instanceof IClass ) ! isAbstract = ((IClass) modelElement).isAbstract(); ! return isAbstract; ! } ! ! public ArrayList getDisplayMethods() { ! if (diagram == null || diagram.isShowDetail()) ! return methods; ! else ! return new ArrayList(); ! } ! ! public ArrayList getMethods() { ! return methods; ! } ! ! public ArrayList getProps() { ! return props; ! } ! ! public String getName() { ! return name; ! } ! ! public ArrayList getDisplayProperties() { ! if (diagram == null || diagram.isShowDetail()) ! return props; ! else ! return new ArrayList(); ! } ! ! public ElementInfo getDisplayName() { ! return elementInfo; ! } ! ! public INamedElement getModelElement() { ! return modelElement; ! } ! ! public ArrayList getEnds() { ! return ends; ! } ! ! public short getPageNo() { ! if (diagram == null) ! return 1; ! return diagram.getDiagramPageNumber(); ! } ! ! public int getSuperClass() { ! if (diagram == null) ! return 0; ! if (!diagram.isSetShowSuperClasses()) ! return 0; ! else ! return diagram.getShowSuperClasses(); ! } ! ! public String getAlias() { ! if (diagram == null) ! return null; ! return diagram.getAlias(); ! } ! ! public String toString() { ! String ret = "Class " + getName() + "\n"; ! ret += " Props:" + props.toString() + "\n"; ! ret += " Methods:" + methods.toString() + "\n"; ! return ret; ! } ! ! public boolean isShowDetail() { ! if (diagram == null) ! return true; ! return diagram.isShowDetail(); ! } ! } Index: AssociationInformation.java =================================================================== RCS file: /cvsroot/modelwizard/source/Model Wizard Plugin/src/net/sourceforge/modelWizard/profileViewer/drawingInformation/AssociationInformation.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AssociationInformation.java 7 Nov 2005 16:19:15 -0000 1.3 --- AssociationInformation.java 24 Oct 2006 21:43:59 -0000 1.4 *************** *** 1,370 **** ! /* ! * Created on Sep 27, 2005 ! * @author stjerman ! * <copyright> ! * ! * Copyright (c) 2005 Cisco Systems Inc, ! * All rights reserved. This program and the accompanying materials ! * are made available under the terms of the BSD License ! * which accompanies this distribution. ! * ! * Contributors: ! * CISCO - Initial API and implementation ! * ! * </copyright> ! */ ! package net.sourceforge.modelWizard.profileViewer.drawingInformation; ! ! import java.util.ArrayList; ! import java.util.Collection; ! import java.util.Iterator; ! ! import net.sourceforge.modelWizard.Profile.Reference; ! import net.sourceforge.modelWizard.backingModelAbstraction.AssociationEndKind; ! import net.sourceforge.modelWizard.backingModelAbstraction.IAssociation; ! import net.sourceforge.modelWizard.backingModelAbstraction.IAssociationClass; ! import net.sourceforge.modelWizard.backingModelAbstraction.IClass; ! import net.sourceforge.modelWizard.backingModelAbstraction.IEndProperty; ! import net.sourceforge.modelWizard.backingModelAbstraction.IProperty; ! import net.sourceforge.modelWizard.modelAbstraction.ModelAccess; ! import net.sourceforge.modelWizard.profileViewer.ProfileParsingException; ! ! public class AssociationInformation { ! ! private class AssocInfo { ! private boolean isThreeWay = false; ! ! private AssociationEndKind kind; ! ! private ArrayList ends = new ArrayList(); ! ! private ArrayList refs = new ArrayList(); ! ! private IProperty primary, secondary; ! ! AssocInfo(IAssociation ac, Collection refs) { ! ends.addAll(ac.getEnds().values()); ! if (ends.size() != 2 && ends.size() != 3) ! throw new ProfileParsingException(ac.getName() + " has " ! + ends.size() + " ends!"); ! this.refs.addAll(refs); ! // note that all 3 ways are simple associations. ! if (ends.size() == 3) { ! isThreeWay = true; ! kind = AssociationEndKind.NONE_LITERAL; ! } else { ! // first of all check the first prperty ! IEndProperty tmp = (IEndProperty) ends.get(0); ! if (!tmp.getAggregationKind().equals( ! AssociationEndKind.NONE_LITERAL)) { ! secondary = tmp; ! primary = (IProperty) ends.get(1); ! kind = tmp.getAggregationKind(); ! } else { ! tmp = (IEndProperty) ends.get(1); ! if (!tmp.getAggregationKind().equals( ! AssociationEndKind.NONE_LITERAL)) { ! secondary = tmp; ! kind = tmp.getAggregationKind(); ! primary = (IProperty) ends.get(0); ! } else { ! primary = tmp; ! kind = tmp.getAggregationKind(); ! secondary = (IProperty) ends.get(0); ! } ! } ! } ! } ! ! public Collection getEnds() { ! return ends; ! } ! ! public IProperty getEnd(String name) { ! Iterator i = ends.iterator(); ! while (i.hasNext()) { ! IProperty p = (IProperty) i.next(); ! if (p.getName().equalsIgnoreCase(name)) ! return p; ! } ! throw new ProfileParsingException("can't find end: " + name); ! } ! ! public boolean isThreeWay() { ! return isThreeWay; ! } ! ! public AssociationEndKind getKind() { ! return kind; ! } ! ! public IProperty getPrimary() { ! if (isThreeWay) ! throw new ProfileParsingException( ! "Primary not valid for a three way association."); ! return primary; ! } ! ! public IProperty getSecondary() { ! if (isThreeWay) ! throw new ProfileParsingException( ! "Secondary not valid for a three way association."); ! return secondary; ! } ! ! // for a passed property (one of those in this AssocType), find the ! // right reference and return the min cardinality. ! public int getProfileMinCardinality(IProperty property) { ! if (refs == null) ! return 0; ! String propName = property.getName(); ! Reference thisRef = null; ! Iterator i = refs.iterator(); ! while (i.hasNext()) { ! Reference tmp = (Reference) i.next(); ! if (tmp.getEndRole().equalsIgnoreCase(propName)) { ! thisRef = tmp; ! break; ! } ! } ! if (thisRef != null) ! if (thisRef.isSetMinCardinality()) ! return thisRef.getMinCardinality(); ! return 0; ! } ! ! // for a passed property (one of those in this AssocType), find the ! // right reference and return the min cardinality. ! public int getProfileMaxCardinality(IProperty property) { ! if (refs == null) ! return -1; ! String propName = property.getName(); ! Reference thisRef = null; ! Iterator i = refs.iterator(); ! while (i.hasNext()) { ! Reference tmp = (Reference) i.next(); ! if (tmp.getEndRole().equalsIgnoreCase(propName)) { ! thisRef = tmp; ! break; ! } ! } ! if (thisRef != null) ! if (thisRef.isSetMaxCardinality()) ! return thisRef.getMaxCardinality(); ! return -1; ! } ! ! } ! ! private String name; ! ! private IAssociation realAssoc; ! ! private String containingClassKey; ! ! private String comment; ! ! private ArrayList referenceList = new ArrayList(); ! ! private short pageNo; ! ! private AssocInfo ac; ! ! static ModelAccess model = ModelAccess.INSTANCE; ! ! public AssociationInformation(IAssociation thisClass, String description, ! short pageNo, Collection references, String classKey) { ! name = thisClass.getName(); ! realAssoc = thisClass; ! comment = description; ! referenceList.addAll(references); ! this.pageNo = pageNo; ! ac = new AssocInfo(thisClass, references); ! this.containingClassKey = classKey; ! } ! ! private String getMultiplicity(AssocInfo acType, IProperty property) { ! int modelUpper = property.getUpper(); ! if (modelUpper == -1) ! modelUpper = Integer.MAX_VALUE; ! int modelLower = property.getLower(); ! int profileUpper = acType.getProfileMaxCardinality(property); ! if (profileUpper == -1) ! profileUpper = Integer.MAX_VALUE; ! int profileLower = acType.getProfileMinCardinality(property); ! String ret = ""; ! ! int u = modelUpper; ! if (modelUpper == Integer.MAX_VALUE) { ! u = profileUpper; ! } else if (profileUpper < modelUpper) ! u = profileUpper; ! ! int l = modelLower; ! if (profileLower > modelLower) ! l = profileLower; ! ! if (u == l) ! return Integer.toString(l); ! ! ret = l + ".."; ! ! if (u == Integer.MAX_VALUE) ! ret += "*"; ! else ! ret += u; ! return ret; ! } ! ! public IAssociation getCimCxClass() { ! return realAssoc; ! } ! ! public String getComment() { ! return comment; ! } ! ! public String getName() { ! return name; ! } ! ! public short getPageNo() { ! return pageNo; ! } ! ! public String toString() { ! String ret = "Assoc " + getName() + "\n"; ! ret += " Page No:" + pageNo + "\n"; ! Iterator i = referenceList.iterator(); ! while (i.hasNext()) { ! Reference r = (Reference) i.next(); ! ret += " Ref:" + r.toString(); ! } ! return ret; ! } ! ! /** ! * Return the contents of the reference list. ! * ! * @return ArrayList of Strings. ! */ ! public ArrayList getReferences() { ! ArrayList ret = new ArrayList(); ! Iterator i = referenceList.iterator(); ! while (i.hasNext()) { ! Reference r = (Reference) i.next(); ! // check that the roleName exists. ! Iterator n = ac.ends.iterator(); ! boolean found = false; ! while (n.hasNext()) { ! IProperty p = (IProperty) n.next(); ! if (p.getName().equalsIgnoreCase(r.getEndRole())) { ! found = true; ! break; ! } ! } ! if (!found) ! throw new ProfileParsingException("The end role '" ! + r.getEndRole() + "' does not exist in " ! + this.getName()); ! ret ! .add(DrawingInformation.getKey(r.getEndClass(), r ! .getEndAlias())); ! } ! ret.add(containingClassKey); ! return ret; ! } ! ! public String getPrimaryKey() { ! if (ac.isThreeWay()) ! throw new ProfileParsingException( ! "Primary not valid for a three way association."); ! ! String priRoleName = ac.getPrimary().getName(); ! Reference one = (Reference) referenceList.get(0); ! ! if (one.getEndRole().equalsIgnoreCase(priRoleName)) ! return DrawingInformation.getKey(one.getEndClass(), one ! .getEndAlias()); ! else ! return containingClassKey; ! } ! ! public String getSecondaryKey() { ! if (ac.isThreeWay()) ! throw new ProfileParsingException( ! "Secondary not valid for a three way association."); ! ! String secRoleName = ac.getSecondary().getName(); ! Reference one = (Reference) referenceList.get(0); ! ! if (one.getEndRole().equalsIgnoreCase(secRoleName)) ! return DrawingInformation.getKey(one.getEndClass(), one ! .getEndAlias()); ! else ! return containingClassKey; ! } ! ! public static final int ASSOCIATION = 0; ! ! public static final int AGGREGATION = 1; ! ! public static final int COMPOSITION = 2; ! ! public int getType() { ! if (ac.kind.equals(AssociationEndKind.AGGREGATION_LITERAL)) ! return AGGREGATION; ! if (ac.kind.equals(AssociationEndKind.COMPOSITION_LITERAL)) ! return COMPOSITION; ! return ASSOCIATION; ! } ! ! public String getKey(int index) { ! Reference one = (Reference) referenceList.get(index); ! return DrawingInformation.getKey(one.getEndClass(), one.getEndAlias()); ! } ! ! public String getMultiplicity(int index) { ! Reference it = (Reference) referenceList.get(index); ! return getMultiplicity(ac, ac.getEnd(it.getEndRole())); ! } ! ! public boolean isThreeWay() { ! return ac.isThreeWay(); ! } ! ! public String getPrimaryMultiplicity() { ! return getMultiplicity(ac, ac.getSecondary()); ! } ! ! public String getSecondaryMultiplicity() { ! return getMultiplicity(ac, ac.getPrimary()); ! } ! ! public boolean compare(String assocName, String primaryClassName, ! String secondaryClassName) { ! if (getPrimaryKey().equalsIgnoreCase(primaryClassName) ! && getSecondaryKey().equalsIgnoreCase(secondaryClassName) ! && name.equalsIgnoreCase(assocName)) ! return true; ! else ! return false; ! } ! ! public boolean equals(Object arg0) { ! if (arg0 instanceof AssociationInformation) { ! AssociationInformation ai = (AssociationInformation) arg0; ! if (getPrimaryKey().equalsIgnoreCase(ai.getPrimaryKey()) ! && getSecondaryKey().equalsIgnoreCase(ai.getSecondaryKey()) ! && name.equalsIgnoreCase(ai.getName())) ! return true; ! } ! return false; ! } ! ! // //only works for 2 ways... as will most of this.. ! // public void setOverride(String propertyName, int max, int min){ ! // multOverrideProperyName = propertyName; ! // multOverride ProperyName = propertyName; ! // } ! } --- 1,368 ---- ! /* ! * Created on Sep 27, 2005 ! * @author stjerman ! * <copyright> ! * ! * Copyright (c) 2005 Cisco Systems Inc, ! * All rights reserved. This program and the accompanying materials ! * are made available under the terms of the BSD License ! * which accompanies this distribution. ! * ! * Contributors: ! * CISCO - Initial API and implementation ! * ! * </copyright> ! */ ! package net.sourceforge.modelWizard.profileViewer.drawingInformation; ! ! import java.util.ArrayList; ! import java.util.Collection; ! import java.util.Iterator; ! ! import net.sourceforge.modelWizard.Profile.Reference; ! import net.sourceforge.modelWizard.backingModelAbstraction.AssociationEndKind; ! import net.sourceforge.modelWizard.backingModelAbstraction.IAssociation; ! import net.sourceforge.modelWizard.backingModelAbstraction.IEndProperty; ! import net.sourceforge.modelWizard.backingModelAbstraction.IProperty; ! import net.sourceforge.modelWizard.modelAbstraction.ModelAccess; ! import net.sourceforge.modelWizard.profileViewer.ProfileParsingException; ! ! public class AssociationInformation { ! ! private class AssocInfo { ! private boolean isThreeWay = false; ! ! private AssociationEndKind kind; ! ! private ArrayList ends = new ArrayList(); ! ! private ArrayList refs = new ArrayList(); ! ! private IProperty primary, secondary; ! ! AssocInfo(IAssociation ac, Collection refs) { ! ends.addAll(ac.getEnds().values()); ! if (ends.size() != 2 && ends.size() != 3) ! throw new ProfileParsingException(ac.getName() + " has " ! + ends.size() + " ends!"); ! this.refs.addAll(refs); ! // note that all 3 ways are simple associations. ! if (ends.size() == 3) { ! isThreeWay = true; ! kind = AssociationEndKind.NONE_LITERAL; ! } else { ! // first of all check the first prperty ! IEndProperty tmp = (IEndProperty) ends.get(0); ! if (!tmp.getAggregationKind().equals( ! AssociationEndKind.NONE_LITERAL)) { ! secondary = tmp; ! primary = (IProperty) ends.get(1); ! kind = tmp.getAggregationKind(); ! } else { ! tmp = (IEndProperty) ends.get(1); ! if (!tmp.getAggregationKind().equals( ! AssociationEndKind.NONE_LITERAL)) { ! secondary = tmp; ! kind = tmp.getAggregationKind(); ! primary = (IProperty) ends.get(0); ! } else { ! primary = tmp; ! kind = tmp.getAggregationKind(); ! secondary = (IProperty) ends.get(0); ! } ! } ! } ! } ! ! public Collection getEnds() { ! return ends; ! } ! ! public IProperty getEnd(String name) { ! Iterator i = ends.iterator(); ! while (i.hasNext()) { ! IProperty p = (IProperty) i.next(); ! if (p.getName().equalsIgnoreCase(name)) ! return p; ! } ! throw new ProfileParsingException("can't find end: " + name); ! } ! ! public boolean isThreeWay() { ! return isThreeWay; ! } ! ! public AssociationEndKind getKind() { ! return kind; ! } ! ! public IProperty getPrimary() { ! if (isThreeWay) ! throw new ProfileParsingException( ! "Primary not valid for a three way association."); ! return primary; ! } ! ! public IProperty getSecondary() { ! if (isThreeWay) ! throw new ProfileParsingException( ! "Secondary not valid for a three way association."); ! return secondary; ! } ! ! // for a passed property (one of those in this AssocType), find the ! // right reference and return the min cardinality. ! public int getProfileMinCardinality(IProperty property) { ! if (refs == null) ! return 0; ! String propName = property.getName(); ! Reference thisRef = null; ! Iterator i = refs.iterator(); ! while (i.hasNext()) { ! Reference tmp = (Reference) i.next(); ! if (tmp.getEndRole().equalsIgnoreCase(propName)) { ! thisRef = tmp; ! break; ! } ! } ! if (thisRef != null) ! if (thisRef.isSetMinCardinality()) ! return thisRef.getMinCardinality(); ! return 0; ! } ! ! // for a passed property (one of those in this AssocType), find the ! // right reference and return the min cardinality. ! public int getProfileMaxCardinality(IProperty property) { ! if (refs == null) ! return -1; ! String propName = property.getName(); ! Reference thisRef = null; ! Iterator i = refs.iterator(); ! while (i.hasNext()) { ! Reference tmp = (Reference) i.next(); ! if (tmp.getEndRole().equalsIgnoreCase(propName)) { ! thisRef = tmp; ! break; ! } ! } ! if (thisRef != null) ! if (thisRef.isSetMaxCardinality()) ! return thisRef.getMaxCardinality(); ! return -1; ! } ! ! } ! ! private String name; ! ! private IAssociation realAssoc; ! ! private String containingClassKey; ! ! private String comment; ! ! private ArrayList referenceList = new ArrayList(); ! ! private short pageNo; ! ! private AssocInfo ac; ! ! static ModelAccess model = ModelAccess.INSTANCE; ! ! public AssociationInformation(IAssociation thisClass, String description, ! short pageNo, Collection references, String classKey) { ! name = thisClass.getName(); ! realAssoc = thisClass; ! comment = description; ! referenceList.addAll(references); ! this.pageNo = pageNo; ! ac = new AssocInfo(thisClass, references); ! this.containingClassKey = classKey; ! } ! ! private String getMultiplicity(AssocInfo acType, IProperty property) { ! int modelUpper = property.getUpper(); ! if (modelUpper == -1) ! modelUpper = Integer.MAX_VALUE; ! int modelLower = property.getLower(); ! int profileUpper = acType.getProfileMaxCardinality(property); ! if (profileUpper == -1) ! profileUpper = Integer.MAX_VALUE; ! int profileLower = acType.getProfileMinCardinality(property); ! String ret = ""; ! ! int u = modelUpper; ! if (modelUpper == Integer.MAX_VALUE) { ! u = profileUpper; ! } else if (profileUpper < modelUpper) ! u = profileUpper; ! ! int l = modelLower; ! if (profileLower > modelLower) ! l = profileLower; ! ! if (u == l) ! return Integer.toString(l); ! ! ret = l + ".."; ! ! if (u == Integer.MAX_VALUE) ! ret += "*"; ! else ! ret += u; ! return ret; ! } ! ! public IAssociation getCimCxClass() { ! return realAssoc; ! } ! ! public String getComment() { ! return comment; ! } ! ! public String getName() { ! return name; ! } ! ! public short getPageNo() { ! return pageNo; ! } ! ! public String toString() { ! String ret = "Assoc " + getName() + "\n"; ! ret += " Page No:" + pageNo + "\n"; ! Iterator i = referenceList.iterator(); ! while (i.hasNext()) { ! Reference r = (Reference) i.next(); ! ret += " Ref:" + r.toString(); ! } ! return ret; ! } ! ! /** ! * Return the contents of the reference list. ! * ! * @return ArrayList of Strings. ! */ ! public ArrayList getReferences() { ! ArrayList ret = new ArrayList(); ! Iterator i = referenceList.iterator(); ! while (i.hasNext()) { ! Reference r = (Reference) i.next(); ! // check that the roleName exists. ! Iterator n = ac.ends.iterator(); ! boolean found = false; ! while (n.hasNext()) { ! IProperty p = (IProperty) n.next(); ! if (p.getName().equalsIgnoreCase(r.getEndRole())) { ! found = true; ! break; ! } ! } ! if (!found) ! throw new ProfileParsingException("The end role '" ! + r.getEndRole() + "' does not exist in " ! + this.getName()); ! ret ! .add(DrawingInformation.getKey(r.getEndClass(), r ! .getEndAlias())); ! } ! ret.add(containingClassKey); ! return ret; ! } ! ! public String getPrimaryKey() { ! if (ac.isThreeWay()) ! throw new ProfileParsingException( ! "Primary not valid for a three way association."); ! ! String priRoleName = ac.getPrimary().getName(); ! Reference one = (Reference) referenceList.get(0); ! ! if (one.getEndRole().equalsIgnoreCase(priRoleName)) ! return DrawingInformation.getKey(one.getEndClass(), one ! .getEndAlias()); ! else ! return containingClassKey; ! } ! ! public String getSecondaryKey() { ! if (ac.isThreeWay()) ! throw new ProfileParsingException( ! "Secondary not valid for a three way association."); ! ! String secRoleName = ac.getSecondary().getName(); ! Reference one = (Reference) referenceList.get(0); ! ! if (one.getEndRole().equalsIgnoreCase(secRoleName)) ! return DrawingInformation.getKey(one.getEndClass(), one ! .getEndAlias()); ! else ! return containingClassKey; ! } ! ! public static final int ASSOCIATION = 0; ! ! public static final int AGGREGATION = 1; ! ! public static final int COMPOSITION = 2; ! ! public int getType() { ! if (ac.kind.equals(AssociationEndKind.AGGREGATION_LITERAL)) ! return AGGREGATION; ! if (ac.kind.equals(AssociationEndKind.COMPOSITION_LITERAL)) ! return COMPOSITION; ! return ASSOCIATION; ! } ! ! public String getKey(int index) { ! Reference one = (Reference) referenceList.get(index); ! return DrawingInformation.getKey(one.getEndClass(), one.getEndAlias()); ! } ! ! public String getMultiplicity(int index) { ! Reference it = (Reference) referenceList.get(index); ! return getMultiplicity(ac, ac.getEnd(it.getEndRole())); ! } ! ! public boolean isThreeWay() { ! return ac.isThreeWay(); ! } ! ! public String getPrimaryMultiplicity() { ! return getMultiplicity(ac, ac.getSecondary()); ! } ! ! public String getSecondaryMultiplicity() { ! return getMultiplicity(ac, ac.getPrimary()); ! } ! ! public boolean compare(String assocName, String primaryClassName, ! String secondaryClassName) { ! if (getPrimaryKey().equalsIgnoreCase(primaryClassName) ! && getSecondaryKey().equalsIgnoreCase(secondaryClassName) ! && name.equalsIgnoreCase(assocName)) ! return true; ! else ! return false; ! } ! ! public boolean equals(Object arg0) { ! if (arg0 instanceof AssociationInformation) { ! AssociationInformation ai = (AssociationInformation) arg0; ! if (getPrimaryKey().equalsIgnoreCase(ai.getPrimaryKey()) ! && getSecondaryKey().equalsIgnoreCase(ai.getSecondaryKey()) ! && name.equalsIgnoreCase(ai.getName())) ! return true; ! } ! return false; ! } ! ! // //only works for 2 ways... as will most of this.. ! // public void setOverride(String propertyName, int max, int min){ ! // multOverrideProperyName = propertyName; ! // multOverride ProperyName = propertyName; ! // } ! } |