Search in sources :

Example 1 with Param

use of org.eclipse.vorto.model.Param 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;
}
Also used : InformationModel(org.eclipse.vorto.core.api.model.informationmodel.InformationModel) EntitySource(org.eclipse.vorto.core.api.model.mapping.EntitySource) ReturnPrimitiveType(org.eclipse.vorto.core.api.model.functionblock.ReturnPrimitiveType) ReturnType(org.eclipse.vorto.model.ReturnType) Event(org.eclipse.vorto.core.api.model.functionblock.Event) EntityPropertySource(org.eclipse.vorto.core.api.model.mapping.EntityPropertySource) PropertyAttribute(org.eclipse.vorto.core.api.model.datatype.PropertyAttribute) BooleanPropertyAttribute(org.eclipse.vorto.core.api.model.datatype.BooleanPropertyAttribute) Entity(org.eclipse.vorto.core.api.model.datatype.Entity) Attribute(org.eclipse.vorto.core.api.model.mapping.Attribute) DictionaryPropertyType(org.eclipse.vorto.core.api.model.datatype.DictionaryPropertyType) ModelInfo(org.eclipse.vorto.repository.core.ModelInfo) PrimitivePropertyType(org.eclipse.vorto.core.api.model.datatype.PrimitivePropertyType) RefParam(org.eclipse.vorto.core.api.model.functionblock.RefParam) ModelInfoDto(org.eclipse.vorto.repository.web.api.v1.dto.ModelInfoDto) Map(java.util.Map) ReturnObjectType(org.eclipse.vorto.core.api.model.functionblock.ReturnObjectType) EnumAttributePropertyType(org.eclipse.vorto.model.EnumAttributePropertyType) Operation(org.eclipse.vorto.model.Operation) AbstractModel(org.eclipse.vorto.model.AbstractModel) EnumLiteral(org.eclipse.vorto.model.EnumLiteral) ConfigurationSource(org.eclipse.vorto.core.api.model.mapping.ConfigurationSource) ReturnDictonaryType(org.eclipse.vorto.core.api.model.functionblock.ReturnDictonaryType) InfoModelPropertySource(org.eclipse.vorto.core.api.model.mapping.InfoModelPropertySource) Collectors(java.util.stream.Collectors) ModelId(org.eclipse.vorto.model.ModelId) List(java.util.List) DictionaryType(org.eclipse.vorto.model.DictionaryType) FunctionblockModel(org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel) BooleanAttributeProperty(org.eclipse.vorto.model.BooleanAttributeProperty) OperationSource(org.eclipse.vorto.core.api.model.mapping.OperationSource) ModelEvent(org.eclipse.vorto.model.ModelEvent) Optional(java.util.Optional) IPropertyAttribute(org.eclipse.vorto.model.IPropertyAttribute) Constraint(org.eclipse.vorto.model.Constraint) EnumAttributeProperty(org.eclipse.vorto.model.EnumAttributeProperty) ConstraintType(org.eclipse.vorto.model.ConstraintType) Param(org.eclipse.vorto.model.Param) IUserContext(org.eclipse.vorto.repository.core.IUserContext) FunctionblockProperty(org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty) MappingModel(org.eclipse.vorto.core.api.model.mapping.MappingModel) Infomodel(org.eclipse.vorto.model.Infomodel) FunctionBlockAttributeSource(org.eclipse.vorto.core.api.model.mapping.FunctionBlockAttributeSource) StatusSource(org.eclipse.vorto.core.api.model.mapping.StatusSource) Model(org.eclipse.vorto.core.api.model.model.Model) IReferenceType(org.eclipse.vorto.model.IReferenceType) Property(org.eclipse.vorto.core.api.model.datatype.Property) PrimitiveParam(org.eclipse.vorto.core.api.model.functionblock.PrimitiveParam) EntityModel(org.eclipse.vorto.model.EntityModel) MappingRule(org.eclipse.vorto.core.api.model.mapping.MappingRule) StereoTypeTarget(org.eclipse.vorto.core.api.model.mapping.StereoTypeTarget) Enum(org.eclipse.vorto.core.api.model.datatype.Enum) ModelReference(org.eclipse.vorto.core.api.model.model.ModelReference) ModelProperty(org.eclipse.vorto.model.ModelProperty) InfoModelAttributeSource(org.eclipse.vorto.core.api.model.mapping.InfoModelAttributeSource) PropertyType(org.eclipse.vorto.core.api.model.datatype.PropertyType) ReferenceTarget(org.eclipse.vorto.core.api.model.mapping.ReferenceTarget) EnumSource(org.eclipse.vorto.core.api.model.mapping.EnumSource) FunctionBlockPropertySource(org.eclipse.vorto.core.api.model.mapping.FunctionBlockPropertySource) EnumLiteralPropertyAttribute(org.eclipse.vorto.core.api.model.datatype.EnumLiteralPropertyAttribute) DictonaryParam(org.eclipse.vorto.core.api.model.functionblock.DictonaryParam) Source(org.eclipse.vorto.core.api.model.mapping.Source) ModelType(org.eclipse.vorto.model.ModelType) Stereotype(org.eclipse.vorto.model.Stereotype) FaultSource(org.eclipse.vorto.core.api.model.mapping.FaultSource) EnumModel(org.eclipse.vorto.model.EnumModel) ObjectPropertyType(org.eclipse.vorto.core.api.model.datatype.ObjectPropertyType) BooleanAttributePropertyType(org.eclipse.vorto.model.BooleanAttributePropertyType) Comment(org.eclipse.vorto.repository.domain.Comment) PrimitiveType(org.eclipse.vorto.core.api.model.datatype.PrimitiveType) Constraint(org.eclipse.vorto.model.Constraint) ReferenceTarget(org.eclipse.vorto.core.api.model.mapping.ReferenceTarget) PrimitiveParam(org.eclipse.vorto.core.api.model.functionblock.PrimitiveParam) MappingRule(org.eclipse.vorto.core.api.model.mapping.MappingRule) RefParam(org.eclipse.vorto.core.api.model.functionblock.RefParam) Param(org.eclipse.vorto.model.Param) PrimitiveParam(org.eclipse.vorto.core.api.model.functionblock.PrimitiveParam) DictonaryParam(org.eclipse.vorto.core.api.model.functionblock.DictonaryParam) DictonaryParam(org.eclipse.vorto.core.api.model.functionblock.DictonaryParam) ReturnPrimitiveType(org.eclipse.vorto.core.api.model.functionblock.ReturnPrimitiveType) PrimitiveType(org.eclipse.vorto.core.api.model.datatype.PrimitiveType) StereoTypeTarget(org.eclipse.vorto.core.api.model.mapping.StereoTypeTarget)

Aggregations

List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 BooleanPropertyAttribute (org.eclipse.vorto.core.api.model.datatype.BooleanPropertyAttribute)1 DictionaryPropertyType (org.eclipse.vorto.core.api.model.datatype.DictionaryPropertyType)1 Entity (org.eclipse.vorto.core.api.model.datatype.Entity)1 Enum (org.eclipse.vorto.core.api.model.datatype.Enum)1 EnumLiteralPropertyAttribute (org.eclipse.vorto.core.api.model.datatype.EnumLiteralPropertyAttribute)1 ObjectPropertyType (org.eclipse.vorto.core.api.model.datatype.ObjectPropertyType)1 PrimitivePropertyType (org.eclipse.vorto.core.api.model.datatype.PrimitivePropertyType)1 PrimitiveType (org.eclipse.vorto.core.api.model.datatype.PrimitiveType)1 Property (org.eclipse.vorto.core.api.model.datatype.Property)1 PropertyAttribute (org.eclipse.vorto.core.api.model.datatype.PropertyAttribute)1 PropertyType (org.eclipse.vorto.core.api.model.datatype.PropertyType)1 DictonaryParam (org.eclipse.vorto.core.api.model.functionblock.DictonaryParam)1 Event (org.eclipse.vorto.core.api.model.functionblock.Event)1 FunctionblockModel (org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel)1 PrimitiveParam (org.eclipse.vorto.core.api.model.functionblock.PrimitiveParam)1 RefParam (org.eclipse.vorto.core.api.model.functionblock.RefParam)1