1 28 29 package org.objectweb.openccm.uml.transformation.rules.xml; 30 31 import ispuml.mdaTransformation.RuleContext; 32 import ispuml.mdaTransformation.TransformationException; 33 import ispuml.mdaTransformation.rules.xml.BeanProperty; 34 import ispuml.mdaTransformation.rules.xml.RuleCallXmlAction; 35 36 42 public class TransformAssociatedClass extends RuleCallXmlAction { 43 44 45 private String associatedClassWithStereotype; 46 47 48 private AssociatedClassUtils assoClassUtils; 49 50 51 54 public TransformAssociatedClass () { 55 super(); 56 assoClassUtils = new AssociatedClassUtils(); 57 } 58 59 60 64 public void setAssociatedClassWithStereotype(String stereotype) { 65 associatedClassWithStereotype = stereotype; 66 } 67 68 69 76 private void setSrcAssociatedClassWithStereotype(Object bean, RuleContext context) throws TransformationException { 77 Object value = assoClassUtils.getAssociatedClass(bean, associatedClassWithStereotype, null, context.engineContext.getModel(bean)); 78 if (value != null) { 79 if (srcProperty == null) { 80 srcProperty = new BeanProperty(); 81 } 82 ((BeanProperty) srcProperty).setBeanName(associatedClassWithStereotype); 83 context.putAttribute(associatedClassWithStereotype, value); 84 } else { 85 throw new TransformationException("The Association stereotyped '" + associatedClassWithStereotype + "' is not present."); 86 } 87 } 88 89 90 99 protected Object getSrcValue(Object bean, RuleContext request) throws TransformationException { 100 setSrcAssociatedClassWithStereotype(bean, request); 101 return super.getSrcValue(bean, request); 102 } 103 104 } 105 | Popular Tags |