realType.setDomain(new IntegerType()); EAttribute attribute = modifySimpleType(realType, ifcLineIndex); attribute.setLowerBound(2); attribute.setUpperBound(-1); ifcLineIndex.getEAnnotations().add(createWrappedAnnotation()); EAttribute attribute = modifySimpleType(realType, ifcArcIndex); attribute.setUpperBound(3); attribute.setLowerBound(3); ifcArcIndex.getEAnnotations().add(createWrappedAnnotation());
private static EAttribute createSuperTypeAttribute() { EAttribute superTypesAttribute = EcoreFactory.eINSTANCE.createEAttribute(); superTypesAttribute.setEType(getEClassifier("ELong")); superTypesAttribute.setLowerBound(0); superTypesAttribute.setUpperBound(-1); superTypesAttribute.setName("superTypes"); return superTypesAttribute; }
/** * Converts {@link Component} to {@link EAttribute} * * @param component * @return */ private static EStructuralFeature componentToEAttribute(Component component) { if (!component.getSubComponents().isEmpty()) { throw new IllegalArgumentException( "Sub-components are not supported yet for component " + component.getXmltag()); } EAttribute result = EcoreFactory.eINSTANCE.createEAttribute(); result.setName(toJavaName(component.getXmltag(), false)); result.setLowerBound(component.isRequired() ? 1 : 0); result.setUpperBound(1); result.setEType(toEType(component.getTypeClass())); annotate(result, "truncable", String.valueOf(component.isTruncatable())); annotate(result, "required", String.valueOf(component.isRequired())); annotate(result, ANNOTATION_TYPE_KEY, SmooksMetadata.COMPONENT_TYPE); annotateValueNode(result, component); addMappingInformation(result, component); return result; }
private static void evolvePersonEPackage(final EPackage personEPackage) { EClass ecPerson = (EClass) personEPackage.getEClassifier("Person"); EAttribute eaFirstName = (EAttribute) ecPerson.getEStructuralFeature("firstName"); EAttribute eaLastName = (EAttribute) ecPerson.getEStructuralFeature("lastName"); ecPerson.getEStructuralFeatures().remove(eaFirstName); ecPerson.getEStructuralFeatures().remove(eaLastName); EAttribute eaName = EcoreFactory.eINSTANCE.createEAttribute(); eaName.setName("name"); eaName.setLowerBound(0); eaName.setUpperBound(1); eaName.setEType(EcorePackage.Literals.ESTRING); ecPerson.getEStructuralFeatures().add(eaName); }
/** * Converting a {@link Field} to {@link EAttribute} Works only for * {@link Field} where {@link Field#getComponents()} is empty * * @param field * @return */ public static EAttribute fieldToEAttribute(Field field) { if (!field.getComponents().isEmpty()) { throw new IllegalArgumentException( "Can't convert field with components to " + "EAttribute, use fieldToEReference"); } EAttribute attr = EcoreFactory.eINSTANCE.createEAttribute(); attr.setName(toJavaName(field.getXmltag(), false)); attr.setLowerBound(field.isRequired() ? 1 : 0); attr.setUpperBound(1); if (field.getTypeClass() != null) { attr.setEType(toEType(field.getTypeClass())); } else { log.warn("Field " + field.getXmltag() + " has no type! Setting it's type to String"); attr.setEType(XMLTypePackage.Literals.STRING); } addMappingInformation(attr, field); annotateField(field, attr); return attr; }
/** * Converts {@link Component} to {@link EAttribute} * * @param component * @return */ private static EStructuralFeature componentToEAttribute(Component component) { if (!component.getSubComponents().isEmpty()) { throw new IllegalArgumentException( "Sub-components are not supported yet for component " + component.getXmltag()); } EAttribute result = EcoreFactory.eINSTANCE.createEAttribute(); result.setName(toJavaName(component.getXmltag(), false)); result.setLowerBound(component.isRequired() ? 1 : 0); result.setUpperBound(1); result.setEType(toEType(component.getTypeClass())); annotate(result, "truncable", String.valueOf(component.isTruncatable())); annotate(result, "required", String.valueOf(component.isRequired())); annotate(result, ANNOTATION_TYPE_KEY, SmooksMetadata.COMPONENT_TYPE); annotateValueNode(result, component); addMappingInformation(result, component); return result; }
/** * Converting a {@link Field} to {@link EAttribute} Works only for * {@link Field} where {@link Field#getComponents()} is empty * * @param field * @return */ public static EAttribute fieldToEAttribute(Field field) { if (!field.getComponents().isEmpty()) { throw new IllegalArgumentException( "Can't convert field with components to " + "EAttribute, use fieldToEReference"); } EAttribute attr = EcoreFactory.eINSTANCE.createEAttribute(); attr.setName(toJavaName(field.getXmltag(), false)); attr.setLowerBound(field.isRequired() ? 1 : 0); attr.setUpperBound(1); if (field.getTypeClass() != null) { attr.setEType(toEType(field.getTypeClass())); } else { log.warn("Field " + field.getXmltag() + " has no type! Setting it's type to String"); attr.setEType(XMLTypePackage.Literals.STRING); } addMappingInformation(attr, field); annotateField(field, attr); return attr; }
private void createEPackageMultiplicityManyContainmentNoOpposite() { EPackage ePackage = this.createNewEPackage("MyEPackage", "http://www.example.com/model", "model"); EClass eClass = EcoreFactory.eINSTANCE.createEClass(); eClass.setName("MyEClass"); EClass eOtherClass = EcoreFactory.eINSTANCE.createEClass(); eOtherClass.setName("YourEClass"); EAttribute eAttribute = EcoreFactory.eINSTANCE.createEAttribute(); eAttribute.setName("MyAttribute"); eAttribute.setEType(EcorePackage.Literals.ESTRING); eAttribute.setLowerBound(0); eAttribute.setUpperBound(1); eClass.getEStructuralFeatures().add(eAttribute); EReference eReference = EcoreFactory.eINSTANCE.createEReference(); eReference.setName("children"); eReference.setEType(eOtherClass); eReference.setLowerBound(0); eReference.setUpperBound(-1); eReference.setContainment(true); eClass.getEStructuralFeatures().add(eReference); ePackage.getEClassifiers().add(eClass); ePackage.getEClassifiers().add(eOtherClass); this.registerEPackages(ePackage); }
eaA.setName("a"); eaA.setEType(EcorePackage.Literals.ESTRING); eaA.setLowerBound(0); eaA.setUpperBound(1); ecIContainer.getEStructuralFeatures().add(eaA); eaB.setName("b"); eaB.setEType(EcorePackage.Literals.ESTRING); eaB.setLowerBound(0); eaB.setUpperBound(1); ecIContainer.getEStructuralFeatures().add(eaB);
eaElementName.setName("elementName"); eaElementName.setEType(EcorePackage.Literals.ESTRING); eaElementName.setLowerBound(1); eaElementName.setOrdered(false); eaElementName.setUnique(false); eaPath.setName("path"); eaPath.setEType(EcorePackage.Literals.ESTRING); eaPath.setLowerBound(1); eaPath.setOrdered(false); eaPath.setUnique(false); eaIsReadOnly.setOrdered(false); eaIsReadOnly.setUnique(false); eaIsReadOnly.setLowerBound(1); ecPhysicalElement.getEStructuralFeatures().add(eaIsReadOnly); eaIsDefaultPackage.setName("isDefaultPackage"); eaIsDefaultPackage.setEType(EcorePackage.Literals.EBOOLEAN); eaIsDefaultPackage.setLowerBound(1); eaIsDefaultPackage.setOrdered(false); eaIsDefaultPackage.setUnique(false);
private EPackage createSimpleEPackage() { EPackage ePackage = EcoreFactory.eINSTANCE.createEPackage(); ePackage.setName("MyEPackage"); ePackage.setNsURI("http://com.example.model.MyEPackage"); ePackage.setNsPrefix("com.example"); EClass eClass = EcoreFactory.eINSTANCE.createEClass(); eClass.setName("MyEClass"); EClass eOtherClass = EcoreFactory.eINSTANCE.createEClass(); eOtherClass.setName("YourEClass"); EReference eReference = EcoreFactory.eINSTANCE.createEReference(); eReference.setName("child"); eReference.setEType(eOtherClass); eReference.setLowerBound(0); eReference.setUpperBound(1); eReference.setContainment(true); eClass.getEStructuralFeatures().add(eReference); EAttribute eaName = EcoreFactory.eINSTANCE.createEAttribute(); eaName.setName("name"); eaName.setLowerBound(0); eaName.setUpperBound(1); eaName.setEType(EcorePackage.Literals.ESTRING); eClass.getEStructuralFeatures().add(eaName); ePackage.getEClassifiers().add(eClass); ePackage.getEClassifiers().add(eOtherClass); return ePackage; }
eaElementName.setName("elementName"); eaElementName.setEType(EcorePackage.Literals.ESTRING); eaElementName.setLowerBound(1); eaElementName.setOrdered(false); eaElementName.setUnique(false); eaPath.setName("path"); eaPath.setEType(EcorePackage.Literals.ESTRING); eaPath.setLowerBound(1); eaPath.setOrdered(false); eaPath.setUnique(false); eaIsReadOnly.setOrdered(false); eaIsReadOnly.setUnique(false); eaIsReadOnly.setLowerBound(1); ecPhysicalElement.getEStructuralFeatures().add(eaIsReadOnly); eaIsDefaultPackage.setName("isDefaultPackage"); eaIsDefaultPackage.setEType(EcorePackage.Literals.EBOOLEAN); eaIsDefaultPackage.setLowerBound(1); eaIsDefaultPackage.setOrdered(false); eaIsDefaultPackage.setUnique(false);
eaName.setLowerBound(0); eaName.setUpperBound(1); eaName.setEType(EcorePackage.Literals.ESTRING);
eaFirstName.setName("firstName"); eaFirstName.setEType(EcorePackage.Literals.ESTRING); eaFirstName.setLowerBound(0); eaFirstName.setUpperBound(1); ecPerson.getEStructuralFeatures().add(eaFirstName); eaLastName.setName("lastName"); eaLastName.setEType(EcorePackage.Literals.ESTRING); eaLastName.setLowerBound(0); eaLastName.setUpperBound(1); ecPerson.getEStructuralFeatures().add(eaLastName);
EAttribute eaName = EcoreFactory.eINSTANCE.createEAttribute(); eaName.setName("name"); eaName.setLowerBound(0); eaName.setUpperBound(1); eaName.setEType(EcorePackage.Literals.ESTRING);
eAttribute.setName("MyAttribute"); eAttribute.setEType(EcorePackage.Literals.ESTRING); eAttribute.setLowerBound(0); eAttribute.setUpperBound(1); eClass.getEStructuralFeatures().add(eAttribute);
eAttribute.setLowerBound(minOccurs); eAttribute.setUpperBound(maxOccurs); eClass.getEStructuralFeatures().add(eAttribute); eAttribute.setLowerBound(minOccurs); eAttribute.setUpperBound(maxOccurs); eClass.getEStructuralFeatures().add(eAttribute);
eAttribute.setLowerBound(minOccurs); eAttribute.setUpperBound(maxOccurs); eClass.getEStructuralFeatures().add(eAttribute); eAttribute.setLowerBound(minOccurs); eAttribute.setUpperBound(maxOccurs); eClass.getEStructuralFeatures().add(eAttribute);