use of org.eclipse.vorto.core.api.model.datatype.PrimitivePropertyType in project vorto by eclipse.
the class ModelDtoFactory method createProperty.
private static ModelProperty createProperty(Property property, Optional<MappingModel> mappingModel) {
ModelProperty p = new ModelProperty();
p.setDescription(property.getDescription());
p.setMandatory(property.getPresence() != null ? property.getPresence().isMandatory() : true);
p.setMultiple(property.isMultiplicity());
p.setName(property.getName());
if (property.getType() instanceof PrimitivePropertyType) {
PrimitiveType pt = ((PrimitivePropertyType) property.getType()).getType();
p.setType(org.eclipse.vorto.repository.api.content.PrimitiveType.valueOf(pt.name()));
} else {
p.setType(createModelId(((ObjectPropertyType) property.getType()).getType()));
}
if (property.getConstraintRule() != null && property.getConstraintRule().getConstraints() != null) {
List<Constraint> constraints = property.getConstraintRule().getConstraints().stream().map(c -> createConstraint(c)).collect(Collectors.toList());
p.setConstraints(constraints);
}
if (property.getPropertyAttributes() != null) {
List<IPropertyAttribute> attributes = property.getPropertyAttributes().stream().map(a -> createAttribute(a)).collect(Collectors.toList());
p.setAttributes(attributes);
}
if (mappingModel.isPresent()) {
p.setTargetPlatformKey(mappingModel.get().getTargetPlatform());
for (MappingRule rule : getPropertyRule(p.getName(), mappingModel.get().getRules())) {
StereoTypeTarget target = (StereoTypeTarget) rule.getTarget();
p.addStereotype(Stereotype.create(target.getName(), convertAttributesToMap(target.getAttributes())));
}
}
return p;
}
use of org.eclipse.vorto.core.api.model.datatype.PrimitivePropertyType in project vorto by eclipse.
the class TestFunctionBlockFactory method createPrimitiveProperty.
private static org.eclipse.vorto.core.api.model.datatype.Property createPrimitiveProperty(String propName, PrimitiveType type) {
org.eclipse.vorto.core.api.model.datatype.Property prop = DatatypeFactory.eINSTANCE.createProperty();
prop.setName(propName);
PrimitivePropertyType primi = DatatypeFactory.eINSTANCE.createPrimitivePropertyType();
primi.setType(type);
prop.setType(primi);
return prop;
}
use of org.eclipse.vorto.core.api.model.datatype.PrimitivePropertyType in project vorto by eclipse.
the class TestEntityFactory method createPrimitiveProperty.
public static Property createPrimitiveProperty(String propName, PrimitiveType type) {
Property prop = DatatypeFactory.eINSTANCE.createProperty();
prop.setName(propName);
PrimitivePropertyType primi = DatatypeFactory.eINSTANCE.createPrimitivePropertyType();
primi.setType(type);
prop.setType(primi);
return prop;
}
Aggregations