use of org.eclipse.vorto.core.api.model.functionblock.DictonaryParam in project vorto by eclipse.
the class ModelDtoFactory method createParam.
private static Param createParam(org.eclipse.vorto.core.api.model.functionblock.Param p, Optional<MappingModel> mappingModel) {
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.model.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 if (p instanceof DictonaryParam) {
param.setType(createReferenceType(((DictonaryParam) p).getType()));
} else {
param.setType(createModelId(((RefParam) p).getType()));
}
if (mappingModel.isPresent()) {
param.setTargetPlatformKey(mappingModel.get().getTargetPlatform());
for (MappingRule rule : getParamRule(((org.eclipse.vorto.core.api.model.functionblock.Operation) p.eContainer()).getName(), param.getName(), mappingModel.get().getRules())) {
if (rule.getTarget() instanceof StereoTypeTarget) {
StereoTypeTarget target = (StereoTypeTarget) rule.getTarget();
param.addStereotype(Stereotype.create(target.getName(), convertAttributesToMap(target.getAttributes())));
} else if (rule.getTarget() instanceof ReferenceTarget) {
ReferenceTarget target = (ReferenceTarget) rule.getTarget();
param.setMappingReference(createModelId(target.getMappingModel()));
}
}
}
return param;
}
use of org.eclipse.vorto.core.api.model.functionblock.DictonaryParam in project vorto by eclipse.
the class ModelContentToEcoreConverter method createParams.
private Param[] createParams(List<org.eclipse.vorto.model.Param> params, ModelBuilder<?> builder, ModelContent context) {
List<Param> ecoreParams = new ArrayList<>();
for (org.eclipse.vorto.model.Param param : params) {
if (param.getType() instanceof PrimitiveType) {
PrimitiveParam type = FunctionblockFactory.eINSTANCE.createPrimitiveParam();
type.setMultiplicity(param.isMultiple());
type.setName(param.getName());
type.setType((org.eclipse.vorto.core.api.model.datatype.PrimitiveType.valueOf(((PrimitiveType) param.getType()).name())));
ecoreParams.add(type);
} else if (param.getType() instanceof org.eclipse.vorto.model.ModelId) {
RefParam type = FunctionblockFactory.eINSTANCE.createRefParam();
type.setMultiplicity(param.isMultiple());
type.setName(param.getName());
type.setType((Type) convert(context.getModels().get((org.eclipse.vorto.model.ModelId) param.getType()), context, Optional.empty()));
ecoreParams.add(type);
} else if (param.getType() instanceof DictionaryType) {
DictonaryParam type = FunctionblockFactory.eINSTANCE.createDictonaryParam();
type.setName(param.getName());
type.setMultiplicity(param.isMultiple());
type.setType((DictionaryPropertyType) createPropertyType(param.getType(), builder, context));
ecoreParams.add(type);
} else {
return null;
}
}
return ecoreParams.toArray(new Param[ecoreParams.size()]);
}
Aggregations