/********************************************************************* * The operations from the model ********************************************************************/ public OJSimpleStatement getCopy() { OJSimpleStatement result = new OJSimpleStatement(); result.setExpression(this.getExpression()); return result; } public String toJavaString() {
public void addToStatements(String name, String str){ if(str.length() == 0) return; OJSimpleStatement stat = new OJSimpleStatement(); stat.setName(name); stat.setExpression(str); this.addToStatements(stat); }
public OJSimpleStatement getDeepCopy() { OJSimpleStatement copy = new OJSimpleStatement(); copyDeepInfoInto(copy); return copy; }
public void renameAll(Set<OJPathName> renamePathNames, String newName) { setExpression(replaceAll(getExpression(), renamePathNames, newName)); } /*********************************************************************
!(classifier instanceof Enumeration && pWrap.getType() instanceof DataType)) { OJSimpleStatement statement = new OJSimpleStatement("this." + pWrap.fieldname() + " = " + pWrap.javaDefaultInitialisation(classifier)); statement.setName(pWrap.fieldname()); initialiseProperties.getBody().addToStatements(statement); annotatedClass.addToImports(pWrap.javaImplTypePath()); statement = new OJSimpleStatement( "this." + pWrap.getAssociationClassFakePropertyName() + " = " + pWrap.javaDefaultInitialisationForAssociationClass(classifier, true)); statement.setName(pWrap.getAssociationClassFakePropertyName()); initialiseProperties.getBody().addToStatements(statement); annotatedClass.addToImports(UmlgPropertyOperations.getDefaultTinkerCollectionForAssociationClass(pWrap.getProperty())); for (Property memberEnd : memberEnds) { PropertyWrapper pWrap = new PropertyWrapper(memberEnd); OJSimpleStatement statement = new OJSimpleStatement("this." + pWrap.fieldname() + " = " + pWrap.javaDefaultInitialisation(classifier, true)); statement.setName(pWrap.fieldname()); initialiseProperties.getBody().addToStatements(statement); annotatedClass.addToImports(UmlgPropertyOperations.getDefaultTinkerCollection(memberEnd, true));
/** Returns a copy of this instance. True parts, i.e. associations marked 'aggregate' or 'composite', and attributes, are copied as well. References to other objects, i.e. associations not marked 'aggregate' or 'composite', will not be copied. The returned copy will refer to the same objects as the original (this) instance. */ public OJElement getCopy() { OJSimpleStatement result = new OJSimpleStatement(); this.copyInfoInto(result); return result; }
public void addToStatements(String str){ if(str.length() == 0) return; OJSimpleStatement stat = new OJSimpleStatement(); stat.setExpression(str); this.addToStatements(stat); } public void addToStatements(int index,OJStatement statement){
public void copyDeepInfoInto(OJSimpleStatement copy) { super.copyDeepInfoInto(copy); copy.setExpression(this.getExpression()); }
public OJSimpleStatement(String expression) { super(); this.setExpression(expression); }
public String toJavaString() { String result = ""; if (getExpression().length() != 0 ) result = getExpression(); // if (result.length() > 0 && !(result.charAt(result.length()-1) == '}')) { if (result.length() > 0) { result = result + ";"; } return result; }
OJSwitchCase ojSwitchCase = new OJSwitchCase(); ojSwitchCase.setLabel(pWrap.fieldname()); OJSimpleStatement statement = new OJSimpleStatement("this." + pWrap.fieldname() + " = " + pWrap.javaDefaultInitialisation(classifier)); statement.setName(pWrap.fieldname()); ojSwitchCase.getBody().addToStatements(statement); statement = new OJSimpleStatement("this." + pWrap.getAssociationClassFakePropertyName() + " = " + pWrap.javaDefaultInitialisationForAssociationClass(classifier, true)); statement.setName(pWrap.getAssociationClassFakePropertyName()); ojSwitchCase.getBody().addToStatements(statement); ojSwitchCase.setLabel(pWrap.fieldname()); OJSimpleStatement statement = new OJSimpleStatement("this." + pWrap.fieldname() + " = " + pWrap.javaDefaultInitialisation(classifier, true)); statement.setName(pWrap.fieldname()); ojSwitchCase.getBody().addToStatements(statement); ojSwitchStatement.addToCases(ojSwitchCase);
public void addStatement(String ojStatement) { this.body.addToStatements(new OJSimpleStatement(ojStatement)); }
public void addToStatements(int indexOfRemoveVertex,String expression){ if(expression.length() == 0) return; OJSimpleStatement stat = new OJSimpleStatement(); stat.setExpression(expression); this.addToStatements(indexOfRemoveVertex, stat); } public String toJavaString(){
/** Copies all attributes and associations of this instance into 'copy'. True parts, i.e. associations marked 'aggregate' or 'composite', and attributes, are copied as well. References to other objects, i.e. associations not marked 'aggregate' or 'composite', will not be copied. The 'copy' will refer to the same objects as the original (this) instance. * * @param copy */ public void copyInfoInto(OJSimpleStatement copy) { super.copyInfoInto(copy); copy.setExpression(getExpression()); }
public String javaDefaultInitialisation(Classifier propertyConcreteOwner, boolean ignoreAssociationClass) { return UmlgPropertyOperations.getDefaultTinkerCollectionInitalisation(this.property, propertyConcreteOwner, ignoreAssociationClass).getExpression(); }
private static OJSimpleStatement getDefaultTinkerCollectionInitalisation(Property p, Classifier propertyConcreteOwner, OJPathName collectionPathName) { OJSimpleStatement ojSimpleStatement = new OJSimpleStatement(" new " + collectionPathName.getCollectionTypeName() + "(this"); ojSimpleStatement.setExpression(ojSimpleStatement.getExpression() + ", " + UmlgGenerationUtil.PropertyTree.getLast() + ".from(" + UmlgClassOperations.propertyEnumName(propertyConcreteOwner) + "." + new PropertyWrapper(p).fieldname() + "), " + "loaded"); if (new PropertyWrapper(p).isMemberOfAssociationClass() && !(propertyConcreteOwner instanceof AssociationClass)) { //The constructor for an UmlgPropertyAssociationClassSet takes 2 runtime properties, one to the property end and one to the fake property end to the association class ojSimpleStatement.setExpression(ojSimpleStatement.getExpression() + ", " + UmlgGenerationUtil.PropertyTree.getLast() + ".from(" + UmlgClassOperations.propertyEnumName(propertyConcreteOwner) + "." + new PropertyWrapper(p).getAssociationClassFakePropertyName() + "), loaded"); } ojSimpleStatement.setExpression(ojSimpleStatement.getExpression() + ")"); return ojSimpleStatement; }
if (!clazz.getGeneralizations().isEmpty()) { OJSimpleStatement ojSimpleStatement = new OJSimpleStatement(); ojSimpleStatement.setExpression("super." + ClassBuilder.INTERNAL_MARK_TO_COLLECTION_LOADED + "(umlgRuntimeProperty, loaded)"); z_addToInternalMarkCollectionLoaded.getBody().addToStatements(ojSimpleStatement); OJSimpleStatement ojSimpleStatement = new OJSimpleStatement(); ojSimpleStatement.setExpression("runtimeProperty = " + "(" + UmlgClassOperations.propertyEnumName(clazz) + ".fromQualifiedName(umlgRuntimeProperty.getQualifiedName()))"); z_addToInternalMarkCollectionLoaded.getBody().addToStatements(ojSimpleStatement); OJSimpleStatement statement = new OJSimpleStatement("this." + pWrap.fieldname() + ".setLoaded(loaded)"); statement.setName(pWrap.fieldname()); ojSwitchCase.getBody().addToStatements(statement); annotatedClass.addToImports(pWrap.javaImplTypePath()); ojSwitchCase = new OJSwitchCase(); ojSwitchCase.setLabel(pWrap.getAssociationClassFakePropertyName()); statement = new OJSimpleStatement("this." + pWrap.fieldname() + ".setLoaded(loaded)"); statement.setName(pWrap.fieldname()); ojSwitchCase.getBody().addToStatements(statement); annotatedClass.addToImports(pWrap.javaImplTypePath()); OJSimpleStatement statement = new OJSimpleStatement("this." + pWrap.fieldname() + ".setLoaded(loaded)"); statement.setName(pWrap.fieldname()); ojSwitchCase.getBody().addToStatements(statement); ojSwitchStatement.addToCases(ojSwitchCase);
OJSwitchCase ojSwitchCase = new OJSwitchCase(); ojSwitchCase.setLabel(pWrap.fieldname()); OJSimpleStatement statement = new OJSimpleStatement("this." + pWrap.fieldname() + ".inverseAdder((" + pWrap.javaBaseTypePath().getLast() + ")umlgNode)"); statement.setName(pWrap.fieldname()); ojSwitchCase.getBody().addToStatements(statement); annotatedClass.addToImports(pWrap.javaImplTypePath()); ojSwitchCase = new OJSwitchCase(); ojSwitchCase.setLabel(pWrap.getAssociationClassFakePropertyName()); statement = new OJSimpleStatement("this." + pWrap.getAssociationClassFakePropertyName() + ".inverseAdder((" + pWrap.getAssociationClassPathName().getLast() + ")umlgNode)"); statement.setName(pWrap.fieldname()); ojSwitchCase.getBody().addToStatements(statement); annotatedClass.addToImports(pWrap.javaImplTypePath());
private void addUMLG(OJAnnotatedClass groovyImporter) { groovyImporter.addToStaticBlock( new OJSimpleStatement( "imports.add(\"" + UmlgGenerationUtil.UmlgAdaptorPackage.toJavaString() + ".*\")" ) ); }
private void addUriToObject(Model model, OJEnum ojEnum) { OJAnnotatedOperation asJson = ojEnum.findOperation("asJson"); OJSimpleStatement s = (OJSimpleStatement) asJson.getBody().findStatement("uri"); s.setExpression("sb.append(\"\\\"uri\\\": \\\"/" + model.getName() + "\\\", \")"); }