[archstudio-commits] svn commit: r7058 - in /archstudio4/branches/enhancements/edu.uci.isr.archstudio4.comp.relatedelements/src/edu/uci/isr/archstudio4/comp/relatedelements: ./ processors/

archstudio-commits-owner at uci.edu archstudio-commits-owner at uci.edu
Thu May 1 15:35:51 PDT 2008


Author: ssubrama
Date: Thu May  1 15:35:51 2008
New Revision: 7058

Log:
First Working implementation of Copy/Paste

Modified:
    archstudio4/branches/enhancements/edu.uci.isr.archstudio4.comp.relatede=
lements/src/edu/uci/isr/archstudio4/comp/relatedelements/IRelatedElementsPr=
ocessor.java
    archstudio4/branches/enhancements/edu.uci.isr.archstudio4.comp.relatede=
lements/src/edu/uci/isr/archstudio4/comp/relatedelements/processors/Related=
HintedElement.java
    archstudio4/branches/enhancements/edu.uci.isr.archstudio4.comp.relatede=
lements/src/edu/uci/isr/archstudio4/comp/relatedelements/processors/Related=
HintedElementsProcessor.java
    archstudio4/branches/enhancements/edu.uci.isr.archstudio4.comp.relatede=
lements/src/edu/uci/isr/archstudio4/comp/relatedelements/processors/Related=
RationaleElement.java
    archstudio4/branches/enhancements/edu.uci.isr.archstudio4.comp.relatede=
lements/src/edu/uci/isr/archstudio4/comp/relatedelements/processors/Related=
RationaleElementsProcessor.java

Modified: archstudio4/branches/enhancements/edu.uci.isr.archstudio4.comp.re=
latedelements/src/edu/uci/isr/archstudio4/comp/relatedelements/IRelatedElem=
entsProcessor.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- archstudio4/branches/enhancements/edu.uci.isr.archstudio4.comp.relatede=
lements/src/edu/uci/isr/archstudio4/comp/relatedelements/IRelatedElementsPr=
ocessor.java (original)
+++ archstudio4/branches/enhancements/edu.uci.isr.archstudio4.comp.relatede=
lements/src/edu/uci/isr/archstudio4/comp/relatedelements/IRelatedElementsPr=
ocessor.java Thu May  1 15:35:51 2008
@@ -3,10 +3,12 @@
 import java.util.List;
 =

 import edu.uci.isr.xarchflat.ObjRef;
+import edu.uci.isr.xarchflat.XArchFlatInterface;
 =

 public interface IRelatedElementsProcessor {
 	List<IRelatedElement> getRelatedElements(ObjRef objRef);
 	void paste(IRelatedElement relatedElement,ObjRef newXArchRef,ObjRef dupli=
cateObjRef,
 			List<ObjRef> oldReferencedObjRefs, List<ObjRef> newReferencedObjRefs);
 =

+	ObjRef getTargetReferenceRef(ObjRef targetXArchRef,IRelatedElement relate=
dElement);
 }

Modified: archstudio4/branches/enhancements/edu.uci.isr.archstudio4.comp.re=
latedelements/src/edu/uci/isr/archstudio4/comp/relatedelements/processors/R=
elatedHintedElement.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- archstudio4/branches/enhancements/edu.uci.isr.archstudio4.comp.relatede=
lements/src/edu/uci/isr/archstudio4/comp/relatedelements/processors/Related=
HintedElement.java (original)
+++ archstudio4/branches/enhancements/edu.uci.isr.archstudio4.comp.relatede=
lements/src/edu/uci/isr/archstudio4/comp/relatedelements/processors/Related=
HintedElement.java Thu May  1 15:35:51 2008
@@ -1,6 +1,6 @@
 package edu.uci.isr.archstudio4.comp.relatedelements.processors;
 =

-import java.util.List;
+import java.util.Map;
 =

 import edu.uci.isr.archstudio4.comp.relatedelements.IRelatedElement;
 import edu.uci.isr.archstudio4.comp.relatedelements.IRelatedElementsProces=
sor;
@@ -19,13 +19,15 @@
 	=

 	IRelatedElementsProcessor relatedHintedElementsProcessor;
 	=

-	public RelatedHintedElement(ObjRef sourceObjRef,ObjRef relatedObjRef,Stri=
ng description,IRelatedElementsProcessor relatedHintElementsProcessor) {
+	Map<String,String> properties;
+	=

+	public RelatedHintedElement(ObjRef sourceObjRef,ObjRef relatedObjRef,Stri=
ng description,IRelatedElementsProcessor relatedHintElementsProcessor,Map<S=
tring,String> properties) {
 		this.sourceObjRef =3D sourceObjRef;
 		this.relatedObjRef =3D relatedObjRef;
 		this.description =3D description;
 		this.relatedHintedElementsProcessor =3D relatedHintElementsProcessor;
+		this.properties =3D properties;
 	}
-
 	public String getDescription() {
 		return this.description;
 	}
@@ -38,7 +40,11 @@
 		return this.relatedHintedElementsProcessor;
 	}
 	=

+	public Map<String,String> getProperties() {
+		return this.properties;
+	}
+	=

 	public ObjRef getSourceObjRef() {
 		return this.sourceObjRef;
-	}
+	}	=

 }

Modified: archstudio4/branches/enhancements/edu.uci.isr.archstudio4.comp.re=
latedelements/src/edu/uci/isr/archstudio4/comp/relatedelements/processors/R=
elatedHintedElementsProcessor.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- archstudio4/branches/enhancements/edu.uci.isr.archstudio4.comp.relatede=
lements/src/edu/uci/isr/archstudio4/comp/relatedelements/processors/Related=
HintedElementsProcessor.java (original)
+++ archstudio4/branches/enhancements/edu.uci.isr.archstudio4.comp.relatede=
lements/src/edu/uci/isr/archstudio4/comp/relatedelements/processors/Related=
HintedElementsProcessor.java Thu May  1 15:35:51 2008
@@ -1,10 +1,14 @@
 package edu.uci.isr.archstudio4.comp.relatedelements.processors;
 =

 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 =

 import edu.uci.isr.archstudio4.comp.relatedelements.IRelatedElement;
 import edu.uci.isr.archstudio4.comp.relatedelements.IRelatedElementsProces=
sor;
+import edu.uci.isr.xarchflat.IXArchInstanceMetadata;
+import edu.uci.isr.xarchflat.IXArchPropertyMetadata;
 import edu.uci.isr.xarchflat.IXArchTypeMetadata;
 import edu.uci.isr.xarchflat.ObjRef;
 import edu.uci.isr.xarchflat.XArchFlatInterface;
@@ -30,7 +34,20 @@
 				for(ObjRef reference : references) {
 					ObjRef parentRef =3D xArch.getParent(reference);
 					if(xArch.isInstanceOf(parentRef, "hints3#HintedElement")) {
-						RelatedHintedElement relatedHintedElement =3D new RelatedHintedEleme=
nt(objRef,parentRef,"Hints",this);
+						=

+						Map<String,String> properties =3D new HashMap<String,String>();
+						ObjRef hintedBundleRef =3D xArch.getParent(xArch.getParent(parentRef=
));
+						IXArchTypeMetadata hintedBundleRefTypeMetadata =3D xArch.getTypeMeta=
data(hintedBundleRef);
+						IXArchPropertyMetadata[] metaDataProperties =3D hintedBundleRefTypeM=
etadata.getProperties();
+						for(IXArchPropertyMetadata metaDataProperty : metaDataProperties) {
+							if(metaDataProperty.getMetadataType() =3D=3D IXArchPropertyMetadata=
.ATTRIBUTE) {
+								String propertyValue =3D (String)xArch.get(hintedBundleRef,metaDat=
aProperty.getName());
+								if(propertyValue !=3D null && !"".equals(propertyValue.trim())) {
+									properties.put(metaDataProperty.getName(), propertyValue);
+								}
+							}
+						}						=

+						RelatedHintedElement relatedHintedElement =3D new RelatedHintedEleme=
nt(objRef,parentRef,"Hints",this,properties);
 						relatedElements.add(relatedHintedElement);
 					}
 				}
@@ -49,7 +66,6 @@
 	public void paste(IRelatedElement relatedElement,ObjRef newXArchRef,ObjRe=
f duplicateObjRef,
 			List<ObjRef> oldReferencedObjRefs, List<ObjRef> newReferencedObjRefs) {
 =

-		ObjRef oldObjRef =3D relatedElement.getRelatedObjRef();
 		ObjRef hintsContextRef =3D xArch.createContext(newXArchRef, "hints3");
 		ObjRef renderingHints =3D xArch.getElement(hintsContextRef, "RenderingHi=
nts3", newXArchRef);
 		ObjRef[] hintBundleRefs =3D xArch.getAll(renderingHints,"HintedElement");
@@ -80,5 +96,47 @@
 		}
 =

 	}
+	=

+	public ObjRef getTargetReferenceRef(ObjRef targetXArchRef,IRelatedElement=
 relatedElement) {
+		if(relatedElement instanceof RelatedHintedElement) {
+			RelatedHintedElement relatedHintedElement =3D (RelatedHintedElement)rel=
atedElement;
+			ObjRef hintsContextRef =3D xArch.createContext(targetXArchRef, "hints3"=
);
+			ObjRef renderingHints =3D xArch.getElement(hintsContextRef, "RenderingH=
ints3", targetXArchRef);
+			ObjRef[] hintBundleRefs =3D xArch.getAll(renderingHints,"HintedElement"=
);
+			ObjRef requiredHintBundleRef =3D null;
+			Map<String,String> properties =3D relatedHintedElement.getProperties();
+			boolean found =3D false;
+			if(hintBundleRefs !=3D null && hintBundleRefs.length > 0) {
+				for(ObjRef hintBundleRef : hintBundleRefs) {
+					boolean sameValues =3D true;
+					for(String propertyName : properties.keySet()) {
+						String propertyValue =3D (String)xArch.get(hintBundleRef, propertyNa=
me);
+						if(!properties.get(propertyName).equals(propertyValue)) {
+							sameValues =3D false;
+							break;
+						}
+					}
+					if(sameValues) {
+						found =3D true;
+						requiredHintBundleRef =3D hintBundleRef;
+						break;
+					}
+				}
+			}
+			if(found) {
+				ObjRef[] refs =3D xArch.getAll(requiredHintBundleRef,"HintedElement");
+				ObjRef parentHintedElementRef =3D refs[0];
+				if(parentHintedElementRef =3D=3D null) {
+					parentHintedElementRef =3D xArch.create(hintsContextRef, "HintedEleme=
nt");
+				}
+				return parentHintedElementRef;
+			}
+			=

+			//TODO:
+			//Ensure that u write the else block for (!found).
+			=

+		}
+		return null;
 =

+	}
 }

Modified: archstudio4/branches/enhancements/edu.uci.isr.archstudio4.comp.re=
latedelements/src/edu/uci/isr/archstudio4/comp/relatedelements/processors/R=
elatedRationaleElement.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- archstudio4/branches/enhancements/edu.uci.isr.archstudio4.comp.relatede=
lements/src/edu/uci/isr/archstudio4/comp/relatedelements/processors/Related=
RationaleElement.java (original)
+++ archstudio4/branches/enhancements/edu.uci.isr.archstudio4.comp.relatede=
lements/src/edu/uci/isr/archstudio4/comp/relatedelements/processors/Related=
RationaleElement.java Thu May  1 15:35:51 2008
@@ -1,7 +1,5 @@
 package edu.uci.isr.archstudio4.comp.relatedelements.processors;
 =

-import java.util.List;
-
 import edu.uci.isr.archstudio4.comp.relatedelements.IRelatedElement;
 import edu.uci.isr.archstudio4.comp.relatedelements.IRelatedElementsProces=
sor;
 import edu.uci.isr.xarchflat.ObjRef;
@@ -41,5 +39,7 @@
 		return this.sourceObjRef;
 	}
 =

-	=

+	public ObjRef getTargetReferenceRef(XArchFlatInterface xArch,ObjRef targe=
tXArchRef) {
+		return null;
+	}	=

 }

Modified: archstudio4/branches/enhancements/edu.uci.isr.archstudio4.comp.re=
latedelements/src/edu/uci/isr/archstudio4/comp/relatedelements/processors/R=
elatedRationaleElementsProcessor.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- archstudio4/branches/enhancements/edu.uci.isr.archstudio4.comp.relatede=
lements/src/edu/uci/isr/archstudio4/comp/relatedelements/processors/Related=
RationaleElementsProcessor.java (original)
+++ archstudio4/branches/enhancements/edu.uci.isr.archstudio4.comp.relatede=
lements/src/edu/uci/isr/archstudio4/comp/relatedelements/processors/Related=
RationaleElementsProcessor.java Thu May  1 15:35:51 2008
@@ -48,4 +48,8 @@
 	public void paste(IRelatedElement relatedElement,ObjRef newXArchRef,ObjRe=
f duplicateObjRef,
 			List<ObjRef> oldReferencedObjRefs, List<ObjRef> newReferencedObjRefs) {	=

 	}
+	=

+	public ObjRef getTargetReferenceRef(ObjRef targetXArchRef,IRelatedElement=
 relatedElement) {
+		return null;
+	}
 }




More information about the archstudio-commits mailing list