/** * To simplify implementation, we list all associations * found with any of the Classifiers * represented by the linked Instances. <p> * * TODO: Make a foolproof algorithm that only allows selecting associations * that create a correct model. Also take into account n-ary associations * and associationclasses. This algo best goes in the model subsystem, e.g. * in a method getAllPossibleAssociationsForALink(). * * @see org.argouml.uml.ui.UMLComboBoxModel#buildModelList() */ protected void buildModelList() { Collection linkEnds; Collection associations = new HashSet(); Object t = getTarget(); if (Model.getFacade().isALink(t)) { linkEnds = Model.getFacade().getConnections(t); Iterator ile = linkEnds.iterator(); while (ile.hasNext()) { Object instance = Model.getFacade().getInstance(ile.next()); Collection c = Model.getFacade().getClassifiers(instance); Iterator ic = c.iterator(); while (ic.hasNext()) { Object classifier = ic.next(); Collection ae = Model.getFacade().getAssociationEnds(classifier); Iterator iae = ae.iterator(); while (iae.hasNext()) { Object associationEnd = iae.next(); Object association = Model.getFacade().getAssociation(associationEnd); associations.add(association); } } } } setElements(associations); }
public List getInEdges(Object port) { if (Model.getFacade().isAClassifierRole(port)) { Object cr = port; Collection ends = Model.getFacade().getAssociationEnds(cr); if (ends == null) { return Collections.EMPTY_LIST; } List result = new ArrayList(); for (Object end : ends) { result.add(Model.getFacade().getAssociation(end)); } } return Collections.EMPTY_LIST; }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLLinkAssociationComboBoxModel.java File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/diagram/collaboration/CollabDiagramGraphModel.java
Method name: void buildModelList() Method name: List getInEdges(Object)
Number of AST nodes: 4 Number of AST nodes: 2
1
/**
1
public List getInEdges(Object port) {
2
     * To simplify implementation, we list all associations
2
3
     * found with any of the Classifiers
3
	if (Model.getFacade().isAClassifierRole(port)) {
4
     * represented by the linked Instances. <p>
4
	    Object cr = port;
5
     *
5
	    Collection ends = Model.getFacade().getAssociationEnds(cr);
6
     * TODO: Make a foolproof algorithm that only allows selecting associations
6
	    if (ends == null) {
7
     * that create a correct model. Also take into account n-ary associations
7
                return Collections.EMPTY_LIST;
8
     * and associationclasses. This algo best goes in the model subsystem, e.g.
8
            }
9
     * in a method getAllPossibleAssociationsForALink().
9
	    List result = new ArrayList();
10
     *
10
	    for (Object end : ends) {
11
     * @see org.argouml.uml.ui.UMLComboBoxModel#buildModelList()
11
		result.add(Model.getFacade().getAssociation(end));
12
     */
12
	    }
13
    protected void buildModelList() {
13
	}
14
        Collection linkEnds;
14
	return Collections.EMPTY_LIST;
15
        Collection associations = new HashSet();
15
    }
16
        Object t = getTarget();
17
        if (Model.getFacade().isALink(t)) {
18
            linkEnds = Model.getFacade().getConnections(t);
19
            Iterator ile = linkEnds.iterator();
20
            while (ile.hasNext()) {
21
                Object instance = Model.getFacade().getInstance(ile.next());
22
                Collection c = Model.getFacade().getClassifiers(instance);
23
                Iterator ic = c.iterator();
24
                while (ic.hasNext()) {
25
                    Object classifier = ic.next();
26
                    Collection ae =
27
                        Model.getFacade().getAssociationEnds(classifier);
28
                    Iterator iae = ae.iterator();
29
                    while (iae.hasNext()) {
30
                        Object associationEnd = iae.next();
31
                        Object association =
32
                            Model.getFacade().getAssociation(associationEnd);
33
                        associations.add(association);
34
                    }
35
                }
36
            }
37
        }
38
        setElements(associations);
39
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.0
    Similarity Score1.000
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    15
    while (iae.hasNext())
    15
    while (iae.hasNext())
    7
    for (Object end : ends)
    Differences
    Expression1Expression2Difference
    associationEndendVARIABLE_NAME_MISMATCH
    7
    for (Object end : ends)
                                                                                                              
    8
    result.add(Model.getFacade().getAssociation(end));
    Preondition Violations
    Unmatched statement result.add(Model.getFacade().getAssociation(end)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8
    result.add(Model.getFacade().getAssociation(end));
    16
    Object associationEnd = iae.next();
    16
    Object associationEnd = iae.next();
    Differences
    Expression1Expression2Difference
    associationEndendVARIABLE_NAME_MISMATCH
                                                                              
    17
    Object association = Model.getFacade().getAssociation(associationEnd);
    17
    Object association = Model.getFacade().getAssociation(associationEnd);
    Preondition Violations
    Unmatched statement Object association=Model.getFacade().getAssociation(associationEnd); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                    
    18
    associations.add(association);
                                                                        
    Precondition Violations (2)
    Row Violation
    1Unmatched statement result.add(Model.getFacade().getAssociation(end)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement Object association=Model.getFacade().getAssociation(associationEnd); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted