use of org.eclipse.vorto.core.api.model.datatype.PrimitiveType in project vorto by eclipse.
the class ModelDtoFactory method createOperation.
private static Operation createOperation(org.eclipse.vorto.core.api.model.functionblock.Operation o) {
Operation operation = new Operation();
operation.setBreakable(o.isBreakable());
operation.setDescription(o.getDescription());
operation.setName(o.getName());
operation.setParams(o.getParams().stream().map(p -> createParam(p)).collect(Collectors.toList()));
if (o.getReturnType() != null) {
ReturnType returnType = new ReturnType();
returnType.setMultiple(o.getReturnType().isMultiplicity());
if (o.getReturnType() instanceof ReturnPrimitiveType) {
returnType.setPrimitive(true);
PrimitiveType pt = ((ReturnPrimitiveType) o.getReturnType()).getReturnType();
returnType.setType(org.eclipse.vorto.repository.api.content.PrimitiveType.valueOf(pt.name()));
} else {
returnType.setPrimitive(false);
returnType.setType(createModelId(((ReturnObjectType) o.getReturnType()).getReturnType()));
}
operation.setResult(returnType);
}
return operation;
}
use of org.eclipse.vorto.core.api.model.datatype.PrimitiveType 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.PrimitiveType in project vorto by eclipse.
the class ModelDtoFactory method createParam.
private static Param createParam(org.eclipse.vorto.core.api.model.functionblock.Param p) {
Param param = new Param();
param.setDescription(p.getDescription());
param.setMultiple(p.isMultiplicity());
param.setName(p.getName());
if (p instanceof PrimitiveParam) {
PrimitiveType pt = ((PrimitiveParam) p).getType();
param.setType(org.eclipse.vorto.repository.api.content.PrimitiveType.valueOf(pt.name()));
if (((PrimitiveParam) p).getConstraintRule() != null && ((PrimitiveParam) p).getConstraintRule().getConstraints() != null) {
List<Constraint> constraints = ((PrimitiveParam) p).getConstraintRule().getConstraints().stream().map(c -> createConstraint(c)).collect(Collectors.toList());
param.setConstraints(constraints);
}
} else {
param.setType(createModelId(((RefParam) p).getType()));
}
return param;
}
Aggregations