Search in sources :

Example 1 with Operation

use of org.eclipse.vorto.repository.api.content.Operation 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;
}
Also used : ReturnPrimitiveType(org.eclipse.vorto.core.api.model.functionblock.ReturnPrimitiveType) ReturnPrimitiveType(org.eclipse.vorto.core.api.model.functionblock.ReturnPrimitiveType) PrimitiveType(org.eclipse.vorto.core.api.model.datatype.PrimitiveType) Operation(org.eclipse.vorto.repository.api.content.Operation) ReturnType(org.eclipse.vorto.repository.api.content.ReturnType) ReturnObjectType(org.eclipse.vorto.core.api.model.functionblock.ReturnObjectType)

Aggregations

PrimitiveType (org.eclipse.vorto.core.api.model.datatype.PrimitiveType)1 ReturnObjectType (org.eclipse.vorto.core.api.model.functionblock.ReturnObjectType)1 ReturnPrimitiveType (org.eclipse.vorto.core.api.model.functionblock.ReturnPrimitiveType)1 Operation (org.eclipse.vorto.repository.api.content.Operation)1 ReturnType (org.eclipse.vorto.repository.api.content.ReturnType)1