use of org.eclipse.vorto.core.api.model.datatype.ObjectPropertyType 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.ObjectPropertyType in project vorto by eclipse.
the class DatatypeGeneratorTask method getTypesOfType.
private static Set<Type> getTypesOfType(Type type, Set<Type> container) {
TreeIterator<EObject> iterator = type.eAllContents();
while (iterator.hasNext()) {
EObject current = iterator.next();
if (current instanceof ObjectPropertyType) {
if (!container.contains(current)) {
container.add(((ObjectPropertyType) current).getType());
Set<Type> moreTypes = getTypesOfType(((ObjectPropertyType) current).getType(), container);
container.addAll(moreTypes);
}
}
}
return container;
}
use of org.eclipse.vorto.core.api.model.datatype.ObjectPropertyType in project vorto by eclipse.
the class DatatypeGeneratorTask method getTypes.
private static Set<Type> getTypes(FunctionblockModel model) {
Set<Type> allTypes = new LinkedHashSet<>();
TreeIterator<EObject> iterator = model.eAllContents();
while (iterator.hasNext()) {
EObject current = iterator.next();
if (current instanceof RefParam) {
addTypeAndReferences(((RefParam) current).getType(), allTypes);
} else if (current instanceof ReturnObjectType) {
addTypeAndReferences(((ReturnObjectType) current).getReturnType(), allTypes);
} else if (current instanceof ObjectPropertyType) {
addTypeAndReferences(((ObjectPropertyType) current).getType(), allTypes);
}
}
return allTypes;
}
use of org.eclipse.vorto.core.api.model.datatype.ObjectPropertyType in project vorto by eclipse.
the class CodeGenTools method getReferencedTypes.
public static EList<Type> getReferencedTypes(Property property) {
EList<Type> types = new BasicEList<Type>();
if (property.getType() instanceof ObjectPropertyType) {
ObjectPropertyType objectType = (ObjectPropertyType) property.getType();
types.add(objectType.getType());
if (objectType.getType() instanceof Entity) {
types.addAll(getReferencedTypes((Entity) objectType.getType()));
}
}
return types;
}
Aggregations