diff --git a/bundles/org.eclipse.vorto.repository/src/org/eclipse/vorto/repository/RestClient.java b/bundles/org.eclipse.vorto.repository/src/org/eclipse/vorto/repository/RestClient.java index 99a3576be7..fad01a8aed 100644 --- a/bundles/org.eclipse.vorto.repository/src/org/eclipse/vorto/repository/RestClient.java +++ b/bundles/org.eclipse.vorto.repository/src/org/eclipse/vorto/repository/RestClient.java @@ -57,7 +57,6 @@ public RestClient(ConnectionInfo connectionInfo) { this.connectionInfo = connectionInfo; } - @SuppressWarnings("restriction") public Result executeGet(String query, final Function responseConverter) throws ClientProtocolException, IOException { ProxyConfiguration proxyProvider = getProxyConfiguration(); @@ -75,7 +74,6 @@ public Result handleSuccess(HttpResponse response) throws ClientProtocolExceptio }); } - @SuppressWarnings("restriction") public Attachment executeGetAttachment(String query) throws ClientProtocolException, IOException { ProxyConfiguration proxyProvider = getProxyConfiguration(); @@ -97,7 +95,6 @@ public Attachment handleSuccess(HttpResponse response) throws ClientProtocolExce }); } - @SuppressWarnings("restriction") public Result executePost(String query, HttpEntity content, final Function responseConverter) throws ClientProtocolException, IOException { ProxyConfiguration proxyProvider = getProxyConfiguration(); @@ -121,7 +118,6 @@ protected Result handleFailure(HttpResponse response) throws ClientProtocolExcep }); } - @SuppressWarnings("restriction") public void executePut(String query) throws ClientProtocolException, IOException { ProxyConfiguration proxyProvider = getProxyConfiguration(); @@ -147,7 +143,6 @@ private ProxyConfiguration getProxyConfiguration() { IProxyService proxyService = getProxyService(); IProxyData[] proxyDataForHost = proxyService.select(java.net.URI.create(connectionInfo.getUrl())); - @SuppressWarnings("restriction") CredentialsProvider credsProvider = new BasicCredentialsProvider(); RequestConfig.Builder configBuilder = RequestConfig.custom(); diff --git a/bundles/org.eclipse.vorto.repository/src/org/eclipse/vorto/repository/RestModelRepository.java b/bundles/org.eclipse.vorto.repository/src/org/eclipse/vorto/repository/RestModelRepository.java index 9029dd052d..127ac9077a 100644 --- a/bundles/org.eclipse.vorto.repository/src/org/eclipse/vorto/repository/RestModelRepository.java +++ b/bundles/org.eclipse.vorto.repository/src/org/eclipse/vorto/repository/RestModelRepository.java @@ -14,7 +14,6 @@ */ package org.eclipse.vorto.repository; -import java.net.URL; import java.net.URLEncoder; import java.util.List; import java.util.Objects; diff --git a/bundles/org.eclipse.vorto.repository/src/org/eclipse/vorto/repository/function/ModelViewToModelResource.java b/bundles/org.eclipse.vorto.repository/src/org/eclipse/vorto/repository/function/ModelViewToModelResource.java index 66b8064026..d6a8232cb0 100644 --- a/bundles/org.eclipse.vorto.repository/src/org/eclipse/vorto/repository/function/ModelViewToModelResource.java +++ b/bundles/org.eclipse.vorto.repository/src/org/eclipse/vorto/repository/function/ModelViewToModelResource.java @@ -27,7 +27,7 @@ public class ModelViewToModelResource implements Function { public ModelResource apply(ModelView input) { - ModelId modelId = ModelIdFactory.newInstance(input.getModelType(), input.getId().getNamespace(), input.getId() + ModelId modelId = ModelIdFactory.newInstance(input.getType(), input.getId().getNamespace(), input.getId() .getVersion(), input.getId().getName()); return new ModelResource(modelId, input.getDescription(), input.getDisplayName(), transformReferences(input, input.getReferences())); @@ -35,7 +35,7 @@ public ModelResource apply(ModelView input) { private List transformReferences(ModelView modelView, List references) { for (ModelId modelId : references) { - modelId.setModelType(getReferenceModelType(modelView.getModelType())); + modelId.setModelType(getReferenceModelType(modelView.getType())); } return references; } diff --git a/bundles/org.eclipse.vorto.repository/src/org/eclipse/vorto/repository/model/ModelView.java b/bundles/org.eclipse.vorto.repository/src/org/eclipse/vorto/repository/model/ModelView.java index 979771ad07..e64986c0e4 100644 --- a/bundles/org.eclipse.vorto.repository/src/org/eclipse/vorto/repository/model/ModelView.java +++ b/bundles/org.eclipse.vorto.repository/src/org/eclipse/vorto/repository/model/ModelView.java @@ -22,7 +22,7 @@ public class ModelView { private ModelId id = null; - private ModelType modelType = null; + private ModelType type = null; private String description = null; private String displayName = null; private List references = new ArrayList<>(); @@ -33,11 +33,11 @@ public void setId(ModelId id) { this.id = id; } - public ModelType getModelType() { - return modelType; + public ModelType getType() { + return type; } - public void setModelType(ModelType modelType) { - this.modelType = modelType; + public void setType(ModelType type) { + this.type = type; } public String getDescription() { return description; diff --git a/server/devtool/pom.xml b/server/devtool/pom.xml index 90df952043..6ee57a6147 100644 --- a/server/devtool/pom.xml +++ b/server/devtool/pom.xml @@ -52,7 +52,7 @@ org.eclipse.vorto - repo-http-models + repository-api ${project.version} @@ -99,7 +99,7 @@ org.eclipse.vorto - repo-http-models + repository-api ${project.version} diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/models/ProjectResource.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/models/ProjectResource.java index f2fef4817e..b6c8f93257 100644 --- a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/models/ProjectResource.java +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/models/ProjectResource.java @@ -14,7 +14,7 @@ *******************************************************************************/ package org.eclipse.vorto.server.devtool.models; -import org.eclipse.vorto.http.model.ModelTypeDto; +import org.eclipse.vorto.repository.api.ModelType; public class ProjectResource { @@ -23,7 +23,7 @@ public class ProjectResource { private String version; private String namespace; private String subType; - private ModelTypeDto modelType; + private ModelType modelType; public String getSubType() { return subType; @@ -65,11 +65,11 @@ public void setNamespace(String namespace) { this.namespace = namespace; } - public ModelTypeDto getModelType() { + public ModelType getModelType() { return modelType; } - public void setModelType(ModelTypeDto modelType) { + public void setModelType(ModelType modelType) { this.modelType = modelType; } diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/editor/IEditorService.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/editor/IEditorService.java index f76cd859d5..857393e99c 100644 --- a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/editor/IEditorService.java +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/editor/IEditorService.java @@ -19,8 +19,9 @@ import java.util.Set; import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.vorto.http.model.ModelIdDto; -import org.eclipse.vorto.http.model.ModelResourceDto; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; +import org.eclipse.vorto.repository.api.ModelType; import org.eclipse.vorto.server.devtool.utils.DevtoolRestClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -31,17 +32,17 @@ public abstract class IEditorService { @Autowired DevtoolRestClient devtoolRestClient; - public abstract String linkModelToResource(String infoModelResourceId, ModelIdDto modelId, ResourceSet resourceSet, + public abstract String linkModelToResource(String infoModelResourceId, ModelId modelId, ResourceSet resourceSet, Set referencedResourceSet); - public abstract List searchModelByExpression(String expression); + public abstract List searchModelByExpression(String expression); - protected final List searchModelByExpressionAndValidate(String expression, - org.eclipse.vorto.http.model.ModelTypeDto modelType) { - List resourceList = devtoolRestClient.searchByExpression(expression); - ArrayList modelResourceList = new ArrayList(); - for (ModelResourceDto modelResource : resourceList) { - if (modelResource.getModelType().equals(modelType)) { + protected final List searchModelByExpressionAndValidate(String expression, + ModelType modelType) { + List resourceList = devtoolRestClient.searchByExpression(expression); + ArrayList modelResourceList = new ArrayList(); + for (ModelInfo modelResource : resourceList) { + if (modelResource.getType().equals(modelType)) { modelResourceList.add(modelResource); } } diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/impl/editor/DatatypeEditorServiceImpl.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/impl/editor/DatatypeEditorServiceImpl.java index 980c61a2bf..a77f72c9cb 100644 --- a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/impl/editor/DatatypeEditorServiceImpl.java +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/impl/editor/DatatypeEditorServiceImpl.java @@ -22,8 +22,9 @@ import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.vorto.http.model.ModelIdDto; -import org.eclipse.vorto.http.model.ModelResourceDto; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; +import org.eclipse.vorto.repository.api.ModelType; import org.eclipse.vorto.server.devtool.service.editor.IEditorService; import org.eclipse.vorto.server.devtool.utils.DevtoolReferenceLinker; import org.springframework.beans.factory.annotation.Autowired; @@ -36,7 +37,7 @@ public class DatatypeEditorServiceImpl extends IEditorService { DevtoolReferenceLinker devtoolReferenceLinker; @Override - public String linkModelToResource(String datatypeResourceId, ModelIdDto datatypeModelId, ResourceSet resourceSet, + public String linkModelToResource(String datatypeResourceId, ModelId datatypeModelId, ResourceSet resourceSet, Set referencedResourceSet) { devtoolReferenceLinker.linkDataTypeToFunctionBlock(datatypeResourceId, datatypeModelId, resourceSet, referencedResourceSet); @@ -51,8 +52,8 @@ public String linkModelToResource(String datatypeResourceId, ModelIdDto datatype } @Override - public List searchModelByExpression(String expression) { - List modelList = searchModelByExpressionAndValidate(expression + " " + org.eclipse.vorto.http.model.ModelTypeDto.Datatype.toString() , org.eclipse.vorto.http.model.ModelTypeDto.Datatype); + public List searchModelByExpression(String expression) { + List modelList = searchModelByExpressionAndValidate(expression + " " + ModelType.Datatype.toString() , ModelType.Datatype); return modelList; } diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/impl/editor/FunctionBlockEditorServiceImpl.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/impl/editor/FunctionBlockEditorServiceImpl.java index 4aac3924df..9e9e2c6417 100644 --- a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/impl/editor/FunctionBlockEditorServiceImpl.java +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/impl/editor/FunctionBlockEditorServiceImpl.java @@ -22,8 +22,9 @@ import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.vorto.http.model.ModelIdDto; -import org.eclipse.vorto.http.model.ModelResourceDto; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; +import org.eclipse.vorto.repository.api.ModelType; import org.eclipse.vorto.server.devtool.service.editor.IEditorService; import org.eclipse.vorto.server.devtool.utils.DevtoolReferenceLinker; import org.springframework.beans.factory.annotation.Autowired; @@ -35,7 +36,7 @@ public class FunctionBlockEditorServiceImpl extends IEditorService { @Autowired DevtoolReferenceLinker devtoolReferenceLinker; - public String linkModelToResource(String functionBlockResourceId, ModelIdDto datatypeModelId, + public String linkModelToResource(String functionBlockResourceId, ModelId datatypeModelId, ResourceSet resourceSet, Set referencedResourceSet) { devtoolReferenceLinker.linkDataTypeToFunctionBlock(functionBlockResourceId, datatypeModelId, resourceSet, referencedResourceSet); @@ -49,9 +50,9 @@ public String linkModelToResource(String functionBlockResourceId, ModelIdDto dat } } - public List searchModelByExpression(String expression) { - List modelList = searchModelByExpressionAndValidate(expression + " " + org.eclipse.vorto.http.model.ModelTypeDto.Datatype.toString() , org.eclipse.vorto.http.model.ModelTypeDto.Datatype); - List functionBlockModelList = searchModelByExpressionAndValidate(expression + " " + org.eclipse.vorto.http.model.ModelTypeDto.Functionblock.toString(), org.eclipse.vorto.http.model.ModelTypeDto.Functionblock); + public List searchModelByExpression(String expression) { + List modelList = searchModelByExpressionAndValidate(expression + " " + ModelType.Datatype.toString() , ModelType.Datatype); + List functionBlockModelList = searchModelByExpressionAndValidate(expression + " " + ModelType.Functionblock.toString(), ModelType.Functionblock); modelList.addAll(functionBlockModelList); return modelList; } diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/impl/editor/InformationModelEditorServiceImpl.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/impl/editor/InformationModelEditorServiceImpl.java index 1881c4becc..fd1f83b7da 100644 --- a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/impl/editor/InformationModelEditorServiceImpl.java +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/impl/editor/InformationModelEditorServiceImpl.java @@ -22,8 +22,9 @@ import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.vorto.http.model.ModelIdDto; -import org.eclipse.vorto.http.model.ModelResourceDto; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; +import org.eclipse.vorto.repository.api.ModelType; import org.eclipse.vorto.server.devtool.service.editor.IEditorService; import org.eclipse.vorto.server.devtool.utils.DevtoolReferenceLinker; import org.springframework.beans.factory.annotation.Autowired; @@ -35,7 +36,7 @@ public class InformationModelEditorServiceImpl extends IEditorService { @Autowired DevtoolReferenceLinker devtoolReferenceLinker; - public String linkModelToResource(String infoModelResourceId, ModelIdDto functionBlockModelId, + public String linkModelToResource(String infoModelResourceId, ModelId functionBlockModelId, ResourceSet resourceSet, Set referencedResourceSet) { devtoolReferenceLinker.linkFunctionBlockToInfoModel(infoModelResourceId, functionBlockModelId, resourceSet, referencedResourceSet); @@ -49,7 +50,7 @@ public String linkModelToResource(String infoModelResourceId, ModelIdDto functio } } - public List searchModelByExpression(String expression) { - return searchModelByExpressionAndValidate(expression + " " + org.eclipse.vorto.http.model.ModelTypeDto.Functionblock.toString(), org.eclipse.vorto.http.model.ModelTypeDto.Functionblock); + public List searchModelByExpression(String expression) { + return searchModelByExpressionAndValidate(expression + " " + ModelType.Functionblock.toString(), ModelType.Functionblock); } } diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/utils/DevtoolReferenceLinker.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/utils/DevtoolReferenceLinker.java index 5b55cce880..150dca4e4f 100644 --- a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/utils/DevtoolReferenceLinker.java +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/utils/DevtoolReferenceLinker.java @@ -32,7 +32,7 @@ import org.eclipse.vorto.core.api.model.model.Model; import org.eclipse.vorto.core.api.model.model.ModelReference; import org.eclipse.vorto.core.api.model.model.ModelType; -import org.eclipse.vorto.http.model.ModelIdDto; +import org.eclipse.vorto.repository.api.ModelId; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -42,7 +42,7 @@ public class DevtoolReferenceLinker { @Autowired DevtoolRestClient devtoolRestClient; - public void linkFunctionBlockToInfoModel(String infoModelResourceId, ModelIdDto functionBlockModelId, + public void linkFunctionBlockToInfoModel(String infoModelResourceId, ModelId functionBlockModelId, ResourceSet resourceSet, Set referencedResourceSet) { if (!containsResource(infoModelResourceId, resourceSet)) { throw new RuntimeException("No resource with resourceId : " + infoModelResourceId); @@ -64,7 +64,7 @@ public void linkFunctionBlockToInfoModel(String infoModelResourceId, ModelIdDto referencedResource.getContents().add(eObject); } - public void linkDataTypeToFunctionBlock(String functionBlockResourceId, ModelIdDto datatypeModelId, + public void linkDataTypeToFunctionBlock(String functionBlockResourceId, ModelId datatypeModelId, ResourceSet resourceSet, Set referencedResourceSet) { if (!containsResource(functionBlockResourceId, resourceSet)) { throw new RuntimeException("No resource with resourceId : " + functionBlockResourceId); @@ -77,7 +77,7 @@ public void linkDataTypeToFunctionBlock(String functionBlockResourceId, ModelIdD linkReferenceToModel(functionBlockResourceId, datatypeModelId, resourceSet, referencedResourceSet); } - public void linkDataTypeToDataType(String dataTypeResourceId, ModelIdDto datatypeModelId, + public void linkDataTypeToDataType(String dataTypeResourceId, ModelId datatypeModelId, ResourceSet resourceSet, Set referencedResourceSet) { if (!containsResource(dataTypeResourceId, resourceSet)) { throw new RuntimeException("No resource with resourceId : " + dataTypeResourceId); @@ -90,7 +90,7 @@ public void linkDataTypeToDataType(String dataTypeResourceId, ModelIdDto datatyp linkReferenceToModel(dataTypeResourceId, datatypeModelId, resourceSet, referencedResourceSet); } - private void linkReferenceToModel(String modelResourceId, ModelIdDto referenceModelId, ResourceSet resourceSet, + private void linkReferenceToModel(String modelResourceId, ModelId referenceModelId, ResourceSet resourceSet, Set referencedResourceSet) { ModelType referenceModelType = devtoolRestClient.getModelType(referenceModelId); @@ -170,13 +170,13 @@ private String generateFunctionBlockVariableName(FunctionblockModel fbm, Set searchByExpression(String expression) { + public List searchByExpression(String expression) { String results = restTemplate.getForObject(basePath + "/rest/model/query=" + expression, String.class); JsonElement jsonElement = new JsonParser().parse(results); Gson gson = createGson(); - List modelResourceList = gson.fromJson(jsonElement, new TypeToken>() { + List modelResourceList = gson.fromJson(jsonElement, new TypeToken>() { }.getType()); return modelResourceList; } - public ResponseEntity uploadMultipleFiles(final String fileName, byte[] multipleFileContent){ + public ResponseEntity uploadMultipleFiles(final String fileName, byte[] multipleFileContent){ LinkedMultiValueMap map = new LinkedMultiValueMap<>(); map.add("file", new FileMessageResource(multipleFileContent, fileName)); HttpHeaders httpHeaders = getAuthorisedHeaders(); httpHeaders.setContentType(MediaType.MULTIPART_FORM_DATA); HttpEntity> requestEntity = new HttpEntity>(map, httpHeaders); - return restTemplate.postForEntity(basePath + "/rest/secure/multiple", requestEntity, ServerResponseDto.class); + return restTemplate.postForEntity(basePath + "/rest/secure/multiple", requestEntity, ServerResponse.class); } - public ResponseEntity checkInSingleFile(String handleId){ + public ResponseEntity checkInSingleFile(String handleId){ HttpHeaders httpHeaders = getAuthorisedHeaders(); HttpEntity> requestEntity = new HttpEntity>(httpHeaders); - return restTemplate.exchange(basePath + "/rest/secure/{handleId:.+}", HttpMethod.PUT, requestEntity, ServerResponseDto.class, handleId); + return restTemplate.exchange(basePath + "/rest/secure/{handleId:.+}", HttpMethod.PUT, requestEntity, ServerResponse.class, handleId); } - public ResponseEntity checkInMultipleFiles(ModelHandle[] modelHandles){ + public ResponseEntity checkInMultipleFiles(ModelHandle[] modelHandles){ Gson gson = new Gson(); String json = gson.toJson(modelHandles); HttpHeaders httpHeaders = getAuthorisedHeaders(); httpHeaders.setContentType(MediaType.APPLICATION_JSON_UTF8); System.out.println(json); HttpEntity requestEntity = new HttpEntity<>(json, httpHeaders); - return restTemplate.exchange(basePath + "/rest/secure/checkInMultiple", HttpMethod.PUT, requestEntity, ServerResponseDto.class); + return restTemplate.exchange(basePath + "/rest/secure/checkInMultiple", HttpMethod.PUT, requestEntity, ServerResponse.class); // return null; } diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/web/controller/editor/DatatypeEditorController.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/web/controller/editor/DatatypeEditorController.java index 76dda246c8..34df55b2d9 100644 --- a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/web/controller/editor/DatatypeEditorController.java +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/web/controller/editor/DatatypeEditorController.java @@ -26,8 +26,8 @@ import org.apache.tomcat.util.http.fileupload.IOUtils; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.vorto.editor.web.resource.WebEditorResourceSetProvider; -import org.eclipse.vorto.http.model.ModelIdDto; -import org.eclipse.vorto.http.model.ModelResourceDto; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; import org.eclipse.vorto.server.devtool.service.impl.editor.DatatypeEditorServiceImpl; import org.eclipse.xtext.web.server.model.IWebResourceSetProvider; import org.eclipse.xtext.web.servlet.HttpServiceContext; @@ -66,7 +66,7 @@ public void linkEditor(@ApiParam(value = "ResourceId", required = true) final @P Objects.requireNonNull(name, "name must not be null"); Objects.requireNonNull(version, "version must not be null"); - ModelIdDto modelId = new ModelIdDto(name, namespace, version); + ModelId modelId = new ModelId(name, namespace, version); HttpServiceContext httpServiceContext = new HttpServiceContext(request); WebEditorResourceSetProvider webEditorResourceSetProvider = (WebEditorResourceSetProvider) injector.getInstance(IWebResourceSetProvider.class); @@ -85,7 +85,7 @@ public void linkEditor(@ApiParam(value = "ResourceId", required = true) final @P @ApiOperation(value = "") @RequestMapping(value = "/search={expression:.*}", method = RequestMethod.GET) - public List searchByExpression( + public List searchByExpression( @ApiParam(value = "Search expression", required = true) @PathVariable String expression) { Objects.requireNonNull(expression, "namespace must not be null"); return datatypeEditorServiceImpl.searchModelByExpression(expression); diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/web/controller/editor/FunctionBlockEditorController.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/web/controller/editor/FunctionBlockEditorController.java index c2b267bf88..e599d0c2f6 100644 --- a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/web/controller/editor/FunctionBlockEditorController.java +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/web/controller/editor/FunctionBlockEditorController.java @@ -26,8 +26,8 @@ import org.apache.tomcat.util.http.fileupload.IOUtils; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.vorto.editor.web.resource.WebEditorResourceSetProvider; -import org.eclipse.vorto.http.model.ModelIdDto; -import org.eclipse.vorto.http.model.ModelResourceDto; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; import org.eclipse.vorto.server.devtool.service.impl.editor.FunctionBlockEditorServiceImpl; import org.eclipse.xtext.web.server.model.IWebResourceSetProvider; import org.eclipse.xtext.web.servlet.HttpServiceContext; @@ -66,7 +66,7 @@ public void linkEditor(@ApiParam(value = "ResourceId", required = true) final @P Objects.requireNonNull(name, "name must not be null"); Objects.requireNonNull(version, "version must not be null"); - ModelIdDto modelId = new ModelIdDto(name, namespace, version); + ModelId modelId = new ModelId(name, namespace, version); HttpServiceContext httpServiceContext = new HttpServiceContext(request); WebEditorResourceSetProvider webEditorResourceSetProvider = (WebEditorResourceSetProvider) injector.getInstance(IWebResourceSetProvider.class); @@ -85,7 +85,7 @@ public void linkEditor(@ApiParam(value = "ResourceId", required = true) final @P @ApiOperation(value = "") @RequestMapping(value = "/search={expression:.*}", method = RequestMethod.GET) - public List searchByExpression( + public List searchByExpression( @ApiParam(value = "Search expression", required = true) @PathVariable String expression) { Objects.requireNonNull(expression, "namespace must not be null"); diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/web/controller/editor/IEditorController.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/web/controller/editor/IEditorController.java index 5c26624e51..b2a10edfea 100644 --- a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/web/controller/editor/IEditorController.java +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/web/controller/editor/IEditorController.java @@ -19,13 +19,13 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.eclipse.vorto.http.model.ModelResourceDto; +import org.eclipse.vorto.repository.api.ModelInfo; public interface IEditorController { public void linkEditor(String resourceId, String namespace, String name, String version, HttpServletRequest request, HttpServletResponse response); - List searchByExpression(String expression); + List searchByExpression(String expression); } diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/web/controller/editor/InformationModelEditorController.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/web/controller/editor/InformationModelEditorController.java index c52779f7cd..b120e48d8b 100644 --- a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/web/controller/editor/InformationModelEditorController.java +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/web/controller/editor/InformationModelEditorController.java @@ -26,8 +26,8 @@ import org.apache.tomcat.util.http.fileupload.IOUtils; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.vorto.editor.web.resource.WebEditorResourceSetProvider; -import org.eclipse.vorto.http.model.ModelIdDto; -import org.eclipse.vorto.http.model.ModelResourceDto; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; import org.eclipse.vorto.server.devtool.service.impl.editor.InformationModelEditorServiceImpl; import org.eclipse.xtext.web.server.model.IWebResourceSetProvider; import org.eclipse.xtext.web.servlet.HttpServiceContext; @@ -66,7 +66,7 @@ public void linkEditor(@ApiParam(value = "ResourceId", required = true) final @P Objects.requireNonNull(name, "name must not be null"); Objects.requireNonNull(version, "version must not be null"); - ModelIdDto modelId = new ModelIdDto(name, namespace, version); + ModelId modelId = new ModelId(name, namespace, version); HttpServiceContext httpServiceContext = new HttpServiceContext(request); WebEditorResourceSetProvider webEditorResourceSetProvider = (WebEditorResourceSetProvider) injector @@ -87,7 +87,7 @@ public void linkEditor(@ApiParam(value = "ResourceId", required = true) final @P @ApiOperation(value = "") @RequestMapping(value = "/search={expression:.*}", method = RequestMethod.GET) - public List searchByExpression( + public List searchByExpression( @ApiParam(value = "Search expression", required = true) @PathVariable String expression) { Objects.requireNonNull(expression, "namespace must not be null"); diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/web/controller/publisher/PublisherController.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/web/controller/publisher/PublisherController.java index 1b370f1cbb..2bbaed077f 100644 --- a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/web/controller/publisher/PublisherController.java +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/web/controller/publisher/PublisherController.java @@ -25,7 +25,7 @@ import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.vorto.editor.web.resource.WebEditorResourceSetProvider; -import org.eclipse.vorto.http.model.ServerResponseDto; +import org.eclipse.vorto.repository.api.upload.ServerResponse; import org.eclipse.vorto.repository.model.ModelHandle; import org.eclipse.vorto.server.devtool.models.ProjectResource; import org.eclipse.vorto.server.devtool.models.ProjectResourceListWrapper; @@ -61,7 +61,7 @@ public class PublisherController { @ApiOperation(value = "Uploads models to the vorto repository for validation") @RequestMapping(value = "/upload", method = RequestMethod.POST) - public ResponseEntity uploadModels( + public ResponseEntity uploadModels( @RequestBody ProjectResourceListWrapper projectResourceListWrapper, @ApiParam(value = "Request", required = true) final HttpServletRequest request) { @@ -82,14 +82,14 @@ public ResponseEntity uploadModels( @ApiOperation(value = "Checks in single model to the vorto repository") @RequestMapping(value = "/{handleId:.+}", method = RequestMethod.PUT) - public ResponseEntity checkin( + public ResponseEntity checkin( @ApiParam(value = "The file name of uploaded vorto model", required = true) final @PathVariable String handleId) { return devtoolRestClient.checkInSingleFile(handleId); } @ApiOperation(value = "Checks in multiple models to the vorto repository") @RequestMapping(value = "/checkInMultiple", method = RequestMethod.PUT) - public ResponseEntity checkInMultiple( + public ResponseEntity checkInMultiple( @ApiParam(value = "The file name of uploaded vorto model", required = true) final @RequestBody ModelHandle[] modelHandles) { return devtoolRestClient.checkInMultipleFiles(modelHandles); } diff --git a/server/repo/pom.xml b/server/repo/pom.xml index 5542fbb85a..f726676f87 100644 --- a/server/repo/pom.xml +++ b/server/repo/pom.xml @@ -15,9 +15,8 @@ pom - repo-core - repo-ui - repo-http-models + repository-server + repository-api diff --git a/server/repo/repo-core/pom.xml b/server/repo/repo-core/pom.xml deleted file mode 100644 index e116ae193d..0000000000 --- a/server/repo/repo-core/pom.xml +++ /dev/null @@ -1,153 +0,0 @@ - - - 4.0.0 - - org.eclipse.vorto - repo - 0.9.0-SNAPSHOT - - repo-core - jar - - - - - javax.jcr - jcr - - - org.modeshape - modeshape-sequencer-xml - - - org.modeshape - modeshape-jcr - - - org.modeshape - modeshape-jcr-api - - - org.modeshape - modeshape-common - - - org.modeshape - modeshape-unit-test - test - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-data-jpa - - - - org.eclipse.core - org.eclipse.core.runtime - 3.7.0 - - - - org.eclipse.vorto - org.eclipse.vorto.core - - - org.eclipse.vorto - org.eclipse.vorto.editor - - - org.eclipse.vorto - org.eclipse.vorto.editor.datatype - - - org.eclipse.vorto - org.eclipse.vorto.editor.functionblock - - - org.eclipse.vorto - org.eclipse.vorto.editor.infomodel - - - org.eclipse.vorto - org.eclipse.vorto.editor.mapping - - - org.eclipse.xtext - org.eclipse.xtext - - - com.google.guava - guava - - - - - org.eclipse.xtext - org.eclipse.xtext.xbase - - - asm - org.ow2.asm - - - com.google.guava - guava - - - - - - com.google.guava - guava - 18.0 - - - - - com.sun.mail - javax.mail - - - - org.freemarker - freemarker - - - - - commons-io - commons-io - - - - - - junit - junit - test - - - org.subethamail - subethasmtp - test - - - - - diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/resolver/BlueToothUUIDResolver.java b/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/resolver/BlueToothUUIDResolver.java deleted file mode 100644 index 75bef1db49..0000000000 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/resolver/BlueToothUUIDResolver.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * The Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Bosch Software Innovations GmbH - Please refer to git log - */ -package org.eclipse.vorto.repository.internal.resolver; - -import java.util.Optional; - -import org.eclipse.vorto.core.api.model.mapping.Attribute; -import org.eclipse.vorto.core.api.model.mapping.MappingModel; -import org.eclipse.vorto.core.api.model.mapping.MappingRule; -import org.eclipse.vorto.core.api.model.mapping.StereoTypeTarget; -import org.eclipse.vorto.repository.model.IModelContent; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ModelResource; -import org.eclipse.vorto.repository.service.IModelRepository; -import org.eclipse.vorto.repository.service.IModelRepository.ContentType; - -public class BlueToothUUIDResolver extends AbstractResolver { - - public BlueToothUUIDResolver(IModelRepository repository, String serviceKey) { - super(repository,serviceKey); - } - - @Override - protected ModelId doResolve(ModelResource mappingModelResource, String id) { - IModelContent content = this.repository.getModelContent(mappingModelResource.getId(), ContentType.DSL); - MappingModel mappingModel = (MappingModel)content.getModel(); - Optional objectRule = mappingModel.getRules().stream().filter(rule -> rule.getTarget() instanceof StereoTypeTarget && ((StereoTypeTarget)rule.getTarget()).getName().equals("DeviceInfoProfile")).findFirst(); - - if (objectRule.isPresent()) { - Optional objectIdAttribute = ((StereoTypeTarget)objectRule.get().getTarget()).getAttributes().stream().filter(attribute -> attribute.getName().equals("modelNumber")).findFirst(); - if (objectIdAttribute.isPresent() && objectIdAttribute.get().getValue().equals(id)) { - return ModelId.fromReference(mappingModel.getReferences().get(0).getImportedNamespace(),mappingModel.getReferences().get(0).getVersion()); - } - } - return null; - } -} diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/resolver/Lwm2mObjectIdResolver.java b/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/resolver/Lwm2mObjectIdResolver.java deleted file mode 100644 index 9d48807203..0000000000 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/resolver/Lwm2mObjectIdResolver.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * The Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Bosch Software Innovations GmbH - Please refer to git log - */ -package org.eclipse.vorto.repository.internal.resolver; - -import java.util.Optional; - -import org.eclipse.vorto.core.api.model.mapping.Attribute; -import org.eclipse.vorto.core.api.model.mapping.MappingModel; -import org.eclipse.vorto.core.api.model.mapping.MappingRule; -import org.eclipse.vorto.core.api.model.mapping.StereoTypeTarget; -import org.eclipse.vorto.repository.model.IModelContent; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ModelResource; -import org.eclipse.vorto.repository.service.IModelRepository; -import org.eclipse.vorto.repository.service.IModelRepository.ContentType; - -/** - * The LWM2M Resolver resolves a function block model id by a given LWM2M object identifier defined in the function block mappings. - * - * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. - * - */ -public class Lwm2mObjectIdResolver extends AbstractResolver { - - public Lwm2mObjectIdResolver(IModelRepository repository, String serviceKey) { - super(repository,serviceKey); - } - - @Override - protected ModelId doResolve(ModelResource mappingModelResource, String id) { - IModelContent content = this.repository.getModelContent(mappingModelResource.getId(), ContentType.DSL); - MappingModel mappingModel = (MappingModel)content.getModel(); - Optional objectRule = mappingModel.getRules().stream().filter(rule -> rule.getTarget() instanceof StereoTypeTarget && ((StereoTypeTarget)rule.getTarget()).getName().equals("Object")).findFirst(); - - if (objectRule.isPresent()) { - Optional objectIdAttribute = ((StereoTypeTarget)objectRule.get().getTarget()).getAttributes().stream().filter(attribute -> attribute.getName().equals("ObjectID")).findFirst(); - if (objectIdAttribute.isPresent() && objectIdAttribute.get().getValue().equals(id)) { - return ModelId.fromReference(mappingModel.getReferences().get(0).getImportedNamespace(),mappingModel.getReferences().get(0).getVersion()); - } - } - return null; - } - -} diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/resolver/ModelIdResolverFactory.java b/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/resolver/ModelIdResolverFactory.java deleted file mode 100644 index a5c0d4b080..0000000000 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/resolver/ModelIdResolverFactory.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * The Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Bosch Software Innovations GmbH - Please refer to git log - */ -package org.eclipse.vorto.repository.internal.resolver; - -import java.util.HashMap; -import java.util.Map; - -import javax.annotation.PostConstruct; - -import org.eclipse.vorto.repository.resolver.IModelIdResolver; -import org.eclipse.vorto.repository.service.IModelRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class ModelIdResolverFactory { - - @Autowired - private IModelRepository repository; - - private static final String LWM2M_SERVICEKEY = "lwm2m"; - private static final String BT_SERVICEKEY = "bluetooth"; - - private Map resolvers = new HashMap<>(); - - public IModelIdResolver getResolver(String serviceKey) { - if (!resolvers.containsKey(serviceKey)) { - throw new UnknownModelIdResolverException(serviceKey); - } - return resolvers.get(serviceKey); - } - - @PostConstruct - public void initResolvers() { - resolvers.put(LWM2M_SERVICEKEY, new Lwm2mObjectIdResolver(repository,LWM2M_SERVICEKEY)); - resolvers.put(BT_SERVICEKEY, new BlueToothUUIDResolver(repository,BT_SERVICEKEY)); - } -} diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/ModelId.java b/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/ModelId.java deleted file mode 100644 index 7a37b1a66e..0000000000 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/ModelId.java +++ /dev/null @@ -1,180 +0,0 @@ -/** - * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * The Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Bosch Software Innovations GmbH - Please refer to git log - */ -package org.eclipse.vorto.repository.model; -import java.util.Iterator; -import java.util.StringTokenizer; - -/** - * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. - */ -public class ModelId { - private String name; - private String namespace; - private String version; - - private static final String PATH_DELIMITER = "/"; - - public ModelId() { - } - - public ModelId(String name, String namespace, String version) { - super(); - this.name = name; - this.namespace = namespace.toLowerCase(); - this.version = version; - } - - public static ModelId fromReference(String qualifiedName, String version) { - String name = qualifiedName.substring(qualifiedName.lastIndexOf(".")+1); - String namespace = qualifiedName.substring(0,qualifiedName.lastIndexOf(".")); - return new ModelId(name,namespace,version); - } - - /** - * Example path: /org/eclipse/vorto/color/1.0.0/ - * @param path - * @return - */ - public static ModelId fromPath(String path) { - String[] pathFragments = path.substring(1).split("/"); - return new ModelId(pathFragments[pathFragments.length-2],convertToNamespace(pathFragments),pathFragments[pathFragments.length-1]); - } - - private static String convertToNamespace(String[] fragments) { - StringBuilder namespaceBuilder = new StringBuilder(); - for (int i = 0; i < fragments.length-2;i++) { - namespaceBuilder.append(fragments[i]); - if (i < fragments.length-3) { - namespaceBuilder.append("."); - } - } - return namespaceBuilder.toString(); - } - - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - public String getNamespace() { - return namespace; - } - public void setNamespace(String namespace) { - this.namespace = namespace; - } - public String getVersion() { - return version; - } - public void setVersion(String version) { - this.version = version; - } - - public String getFullPath() { - StringBuilder path = new StringBuilder(getNamespacePath()); - path.append(PATH_DELIMITER); - path.append(name); - path.append(PATH_DELIMITER); - path.append(version); - return path.toString(); - } - - public String getNamespacePath() { - StringBuilder path = new StringBuilder(PATH_DELIMITER); - StringTokenizer tokenizer = new StringTokenizer(namespace, "."); - while(tokenizer.hasMoreTokens()) { - path.append(tokenizer.nextToken()); - if (tokenizer.hasMoreTokens()) { - path.append(PATH_DELIMITER); - } - } - return path.toString(); - } - - public Iterator iterator() { - return new StringTokenizerIterator(getFullPath()); - } - - private static class StringTokenizerIterator implements Iterator { - - private StringTokenizer enumeration; - - public StringTokenizerIterator(String fullPath) { - this.enumeration = new StringTokenizer(fullPath.substring(1),"/"); - } - - public boolean hasNext() { - return this.enumeration.hasMoreElements(); - } - - public String next() { - return this.enumeration.nextToken(); - } - - public void remove() throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - } - - @Override - public String toString() { - return "ModelId [name=" + name + ", namespace=" + namespace + ", version=" + version + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((namespace == null) ? 0 : namespace.hashCode()); - result = prime * result + ((version == null) ? 0 : version.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ModelId other = (ModelId) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (namespace == null) { - if (other.namespace != null) - return false; - } else if (!namespace.equals(other.namespace)) - return false; - if (version == null) { - if (other.version != null) - return false; - } else if (!version.equals(other.version)) - return false; - return true; - } - - public String getPrettyFormat() { - return namespace + "." + name + ":" +version; - } - - public String getFileName() { - return namespace.replace(".", "_")+"-"+name+"-"+version.replace(".", "_"); - } -} \ No newline at end of file diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/ModelResource.java b/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/ModelResource.java deleted file mode 100644 index ca653d037a..0000000000 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/ModelResource.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * The Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Bosch Software Innovations GmbH - Please refer to git log - */ -package org.eclipse.vorto.repository.model; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -/** - * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. - */ -public class ModelResource { - - protected ModelId id; - - protected ModelType modelType; - protected String displayName; - protected String description; - protected String author; - protected Date creationDate; - protected boolean hasImage = false; - - protected List references = new ArrayList<>(); - - protected List referencedBy = new ArrayList(); - - protected List supportedTargetPlatforms = new ArrayList(); - - public ModelResource(ModelId modelId,ModelType modelType) { - this.id = modelId; - this.modelType = modelType; - } - - public ModelId getId() { - return id; - } - - public void setId(ModelId id) { - this.id = id; - } - - public String getDisplayName() { - return displayName; - } - - public void setDisplayName(String displayName) { - this.displayName = displayName; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public List getReferences() { - return references; - } - - public void setReferences(List references) { - this.references = references; - } - - public List getReferencedBy() { - return referencedBy; - } - - public void setReferencedBy(List referencedBy) { - this.referencedBy = referencedBy; - } - - public ModelType getModelType() { - return modelType; - } - - public void setModelType(ModelType modelType) { - this.modelType = modelType; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public Date getCreationDate() { - return creationDate; - } - - public void setCreationDate(Date creationDate) { - this.creationDate = creationDate; - } - - public List getSupportedTargetPlatforms() { - return supportedTargetPlatforms; - } - - public void setSupportedTargetPlatforms(List supportedTargetPlatforms) { - this.supportedTargetPlatforms = supportedTargetPlatforms; - } - - public boolean isHasImage() { - return hasImage; - } - - public void setHasImage(boolean hasImage) { - this.hasImage = hasImage; - } - - - @Override - public String toString() { - return "ModelResource [id=" + id + ", modelType=" + modelType + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result - + ((modelType == null) ? 0 : modelType.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ModelResource other = (ModelResource) obj; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - if (modelType != other.modelType) - return false; - return true; - } - - public void addTargetPlatform(String targetPlatform) { - if (targetPlatform != null && !targetPlatform.equals("")) { - this.supportedTargetPlatforms.add(targetPlatform); - } - } - - public void addReferencedBy(ModelId id) { - this.referencedBy.add(id); - } - -} \ No newline at end of file diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/StatusMessage.java b/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/StatusMessage.java deleted file mode 100644 index 59ef4d2552..0000000000 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/StatusMessage.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * The Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Bosch Software Innovations GmbH - Please refer to git log - */ -package org.eclipse.vorto.repository.model; - -/** - * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. - */ -public class StatusMessage { - - public static enum Level { - WARNING, ERROR, OK - } - - private Level level; - private String message; - - private StatusMessage(Level level,String message) { - this.level = level; - this.message = message; - } - - public static StatusMessage ok(String message) { - return new StatusMessage(Level.OK,message); - } - - public static StatusMessage warning(String message) { - return new StatusMessage(Level.WARNING,message); - } - - public static StatusMessage error(String message) { - return new StatusMessage(Level.ERROR,message); - } - - public Level getLevel() { - return level; - } - - public String getMessage() { - return message; - } - - -} diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/ZipData.java b/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/ZipData.java deleted file mode 100644 index a1177a4052..0000000000 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/ZipData.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * The Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Bosch Software Innovations GmbH - Please refer to git log - */ -package org.eclipse.vorto.repository.model; - -import com.google.common.base.Objects; - -/** - * Class to hold model related data for upload and extraction tasks. - * @author Nagavijay Sivakumar - Robert Bosch (SEA) Pte. Ltd. - * - */ -public class ZipData { - - private ModelId modelId; - private String fileName; - private ModelType modelType; - - public ZipData(String fileName, ModelType modelType) { - this.fileName = fileName; - this.modelType = modelType; - } - public String getFileName() { - return fileName; - } - public void setFileName(String fileName) { - this.fileName = fileName; - } - public ModelType getModelType() { - return modelType; - } - public void setModelType(ModelType modelType) { - this.modelType = modelType; - } - public ModelId getModelId() { - return modelId; - } - public void setModelId(ModelId modelId) { - this.modelId = modelId; - } - - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (obj == this) { - return true; - } - if (this.getClass() != obj.getClass()) { - return false; - } - ZipData other = (ZipData) obj; - return Objects.equal(this.getModelType(), other.getModelType()) - && Objects.equal(this.getFileName(), other.getFileName()); - } -} diff --git a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ModelTypeDto.java b/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ModelTypeDto.java deleted file mode 100644 index 19c7e1fb9d..0000000000 --- a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ModelTypeDto.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * The Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Bosch Software Innovations GmbH - Please refer to git log - */ -package org.eclipse.vorto.http.model; - -/** - * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. - */ -public enum ModelTypeDto { - Functionblock(".fbmodel"), - InformationModel(".infomodel"), - Datatype(".type"), - Mapping(".mapping"); - - private String extension; - - ModelTypeDto(String extension) { - this.extension = extension; - } - - public String getExtension() { - return extension; - } - - public static ModelTypeDto fromFileName(String fileName) { - String type = fileName.substring(fileName.lastIndexOf(".")); - if (type.equals(ModelTypeDto.Functionblock.getExtension())) { - return ModelTypeDto.Functionblock; - } else if (type.equals(ModelTypeDto.InformationModel.getExtension())) { - return ModelTypeDto.InformationModel; - } else if (type.equals(ModelTypeDto.Datatype.getExtension())) { - return ModelTypeDto.Datatype; - } else if (type.equals(ModelTypeDto.Mapping.getExtension())) { - return ModelTypeDto.Mapping; - } else { - throw new IllegalArgumentException(fileName); - } - } -} \ No newline at end of file diff --git a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ParamDto.java b/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ParamDto.java deleted file mode 100644 index 98443ec750..0000000000 --- a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ParamDto.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * The Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Bosch Software Innovations GmbH - Please refer to git log - */ -package org.eclipse.vorto.http.model; - -public class ParamDto { - - private boolean isMultiple = false; - - private String name; - - private String description; - - private boolean isPrimitive = false; - - private IReferenceType type; - - public boolean isMultiple() { - return isMultiple; - } - - public void setMultiple(boolean isMultiple) { - this.isMultiple = isMultiple; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public boolean isPrimitive() { - return isPrimitive; - } - - public void setPrimitive(boolean isPrimitive) { - this.isPrimitive = isPrimitive; - } - - public IReferenceType getType() { - return type; - } - - public void setType(IReferenceType type) { - this.type = type; - } - - @Override - public String toString() { - return "ParamDto [isMultiple=" + isMultiple + ", name=" + name + ", description=" + description - + ", isPrimitive=" + isPrimitive + ", type=" + type + "]"; - } - - -} diff --git a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ModelDtoFactory.java b/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ModelDtoFactory.java deleted file mode 100644 index 7e58f4a24b..0000000000 --- a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ModelDtoFactory.java +++ /dev/null @@ -1,231 +0,0 @@ -/** - * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * The Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Bosch Software Innovations GmbH - Please refer to git log - */ -package org.eclipse.vorto.repository.web; - -import java.util.stream.Collectors; - -import org.eclipse.vorto.core.api.model.datatype.Entity; -import org.eclipse.vorto.core.api.model.datatype.Enum; -import org.eclipse.vorto.core.api.model.datatype.ObjectPropertyType; -import org.eclipse.vorto.core.api.model.datatype.PrimitivePropertyType; -import org.eclipse.vorto.core.api.model.datatype.PrimitiveType; -import org.eclipse.vorto.core.api.model.datatype.Property; -import org.eclipse.vorto.core.api.model.functionblock.Event; -import org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel; -import org.eclipse.vorto.core.api.model.functionblock.PrimitiveParam; -import org.eclipse.vorto.core.api.model.functionblock.RefParam; -import org.eclipse.vorto.core.api.model.functionblock.ReturnObjectType; -import org.eclipse.vorto.core.api.model.functionblock.ReturnPrimitiveType; -import org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty; -import org.eclipse.vorto.core.api.model.informationmodel.InformationModel; -import org.eclipse.vorto.core.api.model.mapping.MappingModel; -import org.eclipse.vorto.core.api.model.model.Model; -import org.eclipse.vorto.core.api.model.model.ModelReference; -import org.eclipse.vorto.http.model.AbstractModelDto; -import org.eclipse.vorto.http.model.EntityModelDto; -import org.eclipse.vorto.http.model.EnumLiteralDto; -import org.eclipse.vorto.http.model.EnumModelDto; -import org.eclipse.vorto.http.model.FunctionblockModelDto; -import org.eclipse.vorto.http.model.InfomodelDto; -import org.eclipse.vorto.http.model.ModelEventDto; -import org.eclipse.vorto.http.model.ModelIdDto; -import org.eclipse.vorto.http.model.ModelPropertyDto; -import org.eclipse.vorto.http.model.ModelResourceDto; -import org.eclipse.vorto.http.model.ModelTypeDto; -import org.eclipse.vorto.http.model.OperationDto; -import org.eclipse.vorto.http.model.ParamDto; -import org.eclipse.vorto.http.model.PrimitiveTypeDto; -import org.eclipse.vorto.http.model.ReturnTypeDto; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ModelResource; - -public class ModelDtoFactory { - - public static ModelResourceDto createDto(ModelResource resource) { - ModelResourceDto dto = new ModelResourceDto(createDto(resource.getId()), ModelTypeDto.valueOf(resource.getModelType().name())); - dto.setAuthor(resource.getAuthor()); - dto.setCreationDate(resource.getCreationDate()); - dto.setDescription(resource.getDescription()); - dto.setDisplayName(resource.getDisplayName()); - dto.setHasImage(resource.isHasImage()); - dto.setReferencedBy(resource.getReferencedBy().stream().map(r -> createDto(r)).collect(Collectors.toList())); - dto.setReferences(resource.getReferences().stream().map(r -> createDto(r)).collect(Collectors.toList())); - dto.setSupportedTargetPlatforms(resource.getSupportedTargetPlatforms()); - return dto; - } - - public static ModelIdDto createDto(ModelId modelId) { - return new ModelIdDto(modelId.getName(), modelId.getNamespace(), modelId.getVersion()); - } - - public static AbstractModelDto createResource(Model model) { - if (model instanceof InformationModel) { - return createResource((InformationModel)model); - } else if (model instanceof FunctionblockModel) { - return createResource((FunctionblockModel)model); - } else if (model instanceof Entity) { - return createResource((Entity)model); - } else if (model instanceof Enum) { - return createResource((Enum)model); - } else if (model instanceof MappingModel) { - return new ModelResourceDto(new ModelIdDto(model.getName(), model.getNamespace(), model.getVersion()),ModelTypeDto.Mapping); - } else { - throw new UnsupportedOperationException(); - } - } - - public static InfomodelDto createResource(InformationModel model) { - InfomodelDto infoResource = new InfomodelDto(new ModelIdDto(model.getName(),model.getNamespace(),model.getVersion()), ModelTypeDto.InformationModel); - - for (FunctionblockProperty property : model.getProperties()) { - infoResource.getFunctionblocks().add(createProperty(property)); - } - - infoResource.setDescription(model.getDescription()); - infoResource.setDisplayName(model.getDisplayname()); - infoResource.setReferences(model.getReferences().stream().map(reference -> createModelId(reference)).collect(Collectors.toList())); - - return infoResource; - } - - private static ModelIdDto createModelId(Model model) { - return new ModelIdDto(model.getName(), model.getNamespace(), model.getVersion()); - } - - private static ModelIdDto createModelId(ModelReference reference) { - org.eclipse.vorto.repository.model.ModelId modelId = org.eclipse.vorto.repository.model.ModelId.fromReference(reference.getImportedNamespace(), reference.getVersion()); - return new ModelIdDto(modelId.getName(),modelId.getNamespace(),modelId.getVersion()); - } - - public static FunctionblockModelDto createResource(FunctionblockModel model) { - FunctionblockModelDto resource = new FunctionblockModelDto(new ModelIdDto(model.getName(),model.getNamespace(),model.getVersion()), ModelTypeDto.Functionblock); - resource.setDescription(model.getDescription()); - resource.setDisplayName(model.getDisplayname()); - resource.setReferences(model.getReferences().stream().map(reference -> createModelId(reference)).collect(Collectors.toList())); - - if (model.getFunctionblock().getConfiguration() != null) { - resource.setConfigurationProperties(model.getFunctionblock().getConfiguration().getProperties().stream().map(p -> createProperty(p)).collect(Collectors.toList())); - } - if (model.getFunctionblock().getStatus() != null) { - resource.setStatusProperties(model.getFunctionblock().getStatus().getProperties().stream().map(p -> createProperty(p)).collect(Collectors.toList())); - } - - if (model.getFunctionblock().getFault() != null) { - resource.setFaultProperties(model.getFunctionblock().getFault().getProperties().stream().map(p -> createProperty(p)).collect(Collectors.toList())); - } - - if (model.getFunctionblock().getEvents() != null) { - resource.setEvents(model.getFunctionblock().getEvents().stream().map(e -> createEvent(e)).collect(Collectors.toList())); - } - - if (model.getFunctionblock().getOperations() != null) { - resource.setOperations(model.getFunctionblock().getOperations().stream().map(o -> createOperation(o)).collect(Collectors.toList())); - } - - return resource; - } - - private static OperationDto createOperation(org.eclipse.vorto.core.api.model.functionblock.Operation o) { - OperationDto operation = new OperationDto(); - 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) { - ReturnTypeDto returnType = new ReturnTypeDto(); - returnType.setMultiple(o.getReturnType().isMultiplicity()); - if (o.getReturnType() instanceof ReturnPrimitiveType) { - returnType.setPrimitive(true); - PrimitiveType pt = ((ReturnPrimitiveType)o.getReturnType()).getReturnType(); - returnType.setType(PrimitiveTypeDto.valueOf(pt.name())); - } else { - returnType.setPrimitive(false); - returnType.setType(createModelId(((ReturnObjectType)o.getReturnType()).getReturnType())); - } - operation.setResult(returnType); - } - return operation; - } - - private static ParamDto createParam(org.eclipse.vorto.core.api.model.functionblock.Param p) { - ParamDto param = new ParamDto(); - param.setDescription(p.getDescription()); - param.setMultiple(p.isMultiplicity()); - param.setName(p.getName()); - if (p instanceof PrimitiveParam) { - param.setPrimitive(true); - PrimitiveType pt = ((PrimitiveParam)p).getType(); - param.setType(PrimitiveTypeDto.valueOf(pt.name())); - } else { - param.setPrimitive(false); - param.setType(createModelId(((RefParam)p).getType())); - } - return param; - } - - - private static ModelPropertyDto createProperty(FunctionblockProperty property) { - ModelPropertyDto p = new ModelPropertyDto(); - p.setDescription(property.getDescription()); - p.setName(property.getName()); - p.setType(createModelId(property.getType())); - return p; - } - - private static ModelPropertyDto createProperty(Property property) { - ModelPropertyDto p = new ModelPropertyDto(); - 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(PrimitiveTypeDto.valueOf(pt.name())); - } else { - p.setType(createModelId(((ObjectPropertyType)property.getType()).getType())); - } - return p; - } - - private static ModelEventDto createEvent(Event event) { - ModelEventDto modelEvent = new ModelEventDto(); - modelEvent.setName(event.getName()); - modelEvent.setProperties(event.getProperties().stream().map(p -> createProperty(p)).collect(Collectors.toList())); - return modelEvent; - } - - public static EntityModelDto createResource(Entity model) { - EntityModelDto resource = new EntityModelDto(new ModelIdDto(model.getName(),model.getNamespace(),model.getVersion()), ModelTypeDto.Datatype); - resource.setDescription(model.getDescription()); - resource.setDisplayName(model.getDisplayname()); - resource.setReferences(model.getReferences().stream().map(reference -> createModelId(reference)).collect(Collectors.toList())); - resource.setProperties(model.getProperties().stream().map(p -> createProperty(p)).collect(Collectors.toList())); - return resource; - } - - public static EnumModelDto createResource(Enum model) { - EnumModelDto resource = new EnumModelDto(new ModelIdDto(model.getName(),model.getNamespace(),model.getVersion()), ModelTypeDto.Datatype); - resource.setDescription(model.getDescription()); - resource.setDisplayName(model.getDisplayname()); - resource.setReferences(model.getReferences().stream().map(reference -> createModelId(reference)).collect(Collectors.toList())); - resource.setLiterals(model.getEnums().stream().map(p -> createLiteral(p)).collect(Collectors.toList())); - return resource; - } - - private static EnumLiteralDto createLiteral(org.eclipse.vorto.core.api.model.datatype.EnumLiteral literal) { - return new EnumLiteralDto(literal.getName(), literal.getDescription()); - } -} diff --git a/server/repo/repo-ui/src/main/resources/application-cloud.yml b/server/repo/repo-ui/src/main/resources/application-cloud.yml deleted file mode 100644 index f31ddf886b..0000000000 --- a/server/repo/repo-ui/src/main/resources/application-cloud.yml +++ /dev/null @@ -1,16 +0,0 @@ -spring: - jpa: - show-sql: false - generate-ddl: true - hibernate: - ddl-auto: validate - -logging: - level: - org.springframework: INFO - -mail: - smtp: - host: localhost - port: 25 - from: vorto-dev@eclipse.org diff --git a/server/repo/repo-ui/src/main/resources/application-local.yml b/server/repo/repo-ui/src/main/resources/application-local.yml deleted file mode 100644 index d6e65dcde2..0000000000 --- a/server/repo/repo-ui/src/main/resources/application-local.yml +++ /dev/null @@ -1,13 +0,0 @@ -server: - port: 8080 - contextPath: /infomodelrepository - -logging: - level: - org.springframework: DEBUG - -mail: - smtp: - host: localhost - port: 25 - from: vorto-dev@eclipse.org diff --git a/server/repo/repo-ui/src/main/resources/application.properties b/server/repo/repo-ui/src/main/resources/application.properties deleted file mode 100644 index 1e6820b41a..0000000000 --- a/server/repo/repo-ui/src/main/resources/application.properties +++ /dev/null @@ -1,5 +0,0 @@ -spring.datasource.testWhileIdle = true -spring.datasource.timeBetweenEvictionRunsMillis = 60000 -spring.datasource.validationQuery = SELECT 1 -spring.profiles.active=local -spring.jackson.serialization.write-dates-as-timestamps:false diff --git a/server/repo/repo-http-models/pom.xml b/server/repo/repository-api/pom.xml similarity index 90% rename from server/repo/repo-http-models/pom.xml rename to server/repo/repository-api/pom.xml index 51d3aa0f61..3da88ab006 100644 --- a/server/repo/repo-http-models/pom.xml +++ b/server/repo/repository-api/pom.xml @@ -6,6 +6,6 @@ repo 0.9.0-SNAPSHOT - repo-http-models + repository-api jar diff --git a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/AbstractModelDto.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/AbstractModel.java similarity index 64% rename from server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/AbstractModelDto.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/AbstractModel.java index db5cc65032..8aa64cab37 100644 --- a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/AbstractModelDto.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/AbstractModel.java @@ -12,39 +12,39 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.http.model; +package org.eclipse.vorto.repository.api; import java.util.ArrayList; import java.util.List; -public abstract class AbstractModelDto { +public abstract class AbstractModel implements IModel { - protected ModelIdDto id; - protected ModelTypeDto modelType; + protected ModelId id; + protected ModelType type; protected String displayName; protected String description; - protected List references = new ArrayList<>(); + protected List references = new ArrayList<>(); - public AbstractModelDto(ModelIdDto modelId,ModelTypeDto modelType) { + public AbstractModel(ModelId modelId,ModelType modelType) { this.id = modelId; - this.modelType = modelType; + this.type = modelType; } - public ModelIdDto getId() { + public ModelId getId() { return id; } - public void setId(ModelIdDto id) { + public void setId(ModelId id) { this.id = id; } - public ModelTypeDto getModelType() { - return modelType; + public ModelType getType() { + return type; } - public void setModelType(ModelTypeDto modelType) { - this.modelType = modelType; + public void setType(ModelType type) { + this.type = type; } public String getDisplayName() { @@ -63,13 +63,12 @@ public void setDescription(String description) { this.description = description; } - public List getReferences() { + public List getReferences() { return references; } - public void setReferences(List references) { + public void setReferences(List references) { this.references = references; } - } diff --git a/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/IModel.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/IModel.java new file mode 100644 index 0000000000..c7d5d93a63 --- /dev/null +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/IModel.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v1.0 which accompany this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * The Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Bosch Software Innovations GmbH - Please refer to git log + */ +package org.eclipse.vorto.repository.api; + +import java.util.Collection; + +public interface IModel { + + /** + * unique id of the model + * @return + */ + ModelId getId(); + + /** + * Type of model + * @return + */ + ModelType getType(); + + /** + * Gets the display name of the model as described in the vorto model, can be null + * @return + */ + String getDisplayName(); + + /** + * Gets the description of the model as described in the vorto model, can be null + * @return + */ + String getDescription(); + + /** + * Gets all model ids that the model depends on, never null + * @return + */ + Collection getReferences(); +} diff --git a/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/IModelGeneration.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/IModelGeneration.java new file mode 100644 index 0000000000..abebee1b86 --- /dev/null +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/IModelGeneration.java @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v1.0 which accompany this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * The Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Bosch Software Innovations GmbH - Please refer to git log + */ +package org.eclipse.vorto.repository.api; + +import java.util.Map; +import java.util.Set; +import java.util.concurrent.CompletableFuture; + +import org.eclipse.vorto.repository.api.exception.GenerationException; +import org.eclipse.vorto.repository.api.exception.GeneratorNotFoundException; +import org.eclipse.vorto.repository.api.exception.ModelNotFoundException; +import org.eclipse.vorto.repository.api.generation.GeneratedOutput; +import org.eclipse.vorto.repository.api.generation.GeneratorInfo; + +/** + * Lets you generate platform specific code for Information Models that were found + * either via {@link IModelRepository} or resolved via {@link IModelResolver} + * + */ +public interface IModelGeneration { + + /** + * Gets all available generators keys of generators that are currently registered in the repository. + * @return a list of generator keys + */ + CompletableFuture> getAvailableGeneratorKeys(); + + /** + * Gives further information about the generator for a given generator key. + * + * @param generatorKey + * @return generator information + * + * @throws GeneratorNotFoundException if no generator can be found for the given key + */ + CompletableFuture getInfo(String generatorKey); + + /** + * Generates platform-specific code for a given Vorto model id using a code generator + * @param modelId + * @param generatorKey + * @param invocationParams + * @return the generated platform - specific source code + * + * @throws GeneratorNotFoundException if no generator can be found for the provided key + * @throws ModelNotFoundException if no model exists in the repository with the specified model id + * @throws GenerationException if something goes wrong during the generation + */ + CompletableFuture generate(ModelId modelId, String generatorKey, Map invocationParams); +} diff --git a/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/IModelRepository.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/IModelRepository.java new file mode 100644 index 0000000000..ad2acdf039 --- /dev/null +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/IModelRepository.java @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v1.0 which accompany this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * The Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Bosch Software Innovations GmbH - Please refer to git log + */ +package org.eclipse.vorto.repository.api; + +import java.util.Collection; +import java.util.concurrent.CompletableFuture; + +import org.eclipse.vorto.repository.api.content.EntityModel; +import org.eclipse.vorto.repository.api.content.EnumModel; +import org.eclipse.vorto.repository.api.content.FunctionblockModel; +import org.eclipse.vorto.repository.api.content.Infomodel; + +/** + * Model repository lets you find and retrieve Vorto information models from the Vorto Repository + * + */ +public interface IModelRepository { + + /** + * Searches the repository by a query expression. Use {@link IModelRepository#newQuery()} as a helper to formulate your query + * @param query expression containing the criteria for the search + * @return a list of model info objects, never null + */ + CompletableFuture> search(ModelQuery query); + + /** + * Finds a model by the given model id. + * @param modelId + * @return model info that was found in the repository or null if a model does not exist with the given id + */ + CompletableFuture getById(ModelId modelId); + + /** + * Gets the actual information model content for a given model id. + * @param modelId model id to get its content for + * @param resultClass expected model class, either {@link Infomodel}, {@link FunctionblockModel}, {@link EntityModel} or {@link EnumModel} + * @return model content + */ + CompletableFuture getContent(ModelId modelId, Class resultClass); + + /** + * Creates a new model query builder as a helper for searching models via {@link IModelRepository#search(ModelQuery)} + * @return + */ + static ModelQueryBuilder newQuery() { + return new ModelQueryBuilder(); + } +} diff --git a/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/IModelResolver.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/IModelResolver.java new file mode 100644 index 0000000000..d75a3ddb4a --- /dev/null +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/IModelResolver.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v1.0 which accompany this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * The Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Bosch Software Innovations GmbH - Please refer to git log + */ +package org.eclipse.vorto.repository.api; + +import java.util.concurrent.CompletableFuture; + +import org.eclipse.vorto.repository.api.resolver.ResolveQuery; + +public interface IModelResolver { + + /** + * Resolves a model for the given query + * @param query containing criteria for resolving the model + * @return model info or null, if no model can be found for the given query + */ + CompletableFuture resolve(ResolveQuery query); +} diff --git a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ModelIdDto.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/ModelId.java similarity index 81% rename from server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ModelIdDto.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/ModelId.java index b1e3244cc1..e2c43b831b 100644 --- a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ModelIdDto.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/ModelId.java @@ -12,35 +12,37 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.http.model; +package org.eclipse.vorto.repository.api; + +import org.eclipse.vorto.repository.api.content.IReferenceType; /** * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. */ -public class ModelIdDto implements IReferenceType { +public class ModelId implements IReferenceType { private String name; private String namespace; private String version; - public ModelIdDto() { + public ModelId() { } - public ModelIdDto(String name, String namespace, String version) { + public ModelId(String name, String namespace, String version) { super(); this.name = name; this.namespace = namespace.toLowerCase(); this.version = version; } - public static ModelIdDto fromReference(String qualifiedName, String version) { + public static ModelId fromReference(String qualifiedName, String version) { String name = qualifiedName.substring(qualifiedName.lastIndexOf(".")+1); String namespace = qualifiedName.substring(0,qualifiedName.lastIndexOf(".")); - return new ModelIdDto(name,namespace,version); + return new ModelId(name,namespace,version); } - public static ModelIdDto fromPrettyFormat(String prettyFormat) { + public static ModelId fromPrettyFormat(String prettyFormat) { final int versionIndex = prettyFormat.indexOf(":"); - return ModelIdDto.fromReference(prettyFormat.substring(0,versionIndex),prettyFormat.substring(versionIndex+1)); + return ModelId.fromReference(prettyFormat.substring(0,versionIndex),prettyFormat.substring(versionIndex+1)); } public String getName() { @@ -86,7 +88,7 @@ public boolean equals(Object obj) { return false; if (getClass() != obj.getClass()) return false; - ModelIdDto other = (ModelIdDto) obj; + ModelId other = (ModelId) obj; if (name == null) { if (other.name != null) return false; diff --git a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ModelResourceDto.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/ModelInfo.java similarity index 79% rename from server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ModelResourceDto.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/ModelInfo.java index 5ca37cdb85..48e1908545 100644 --- a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ModelResourceDto.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/ModelInfo.java @@ -12,7 +12,7 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.http.model; +package org.eclipse.vorto.repository.api; import java.util.ArrayList; import java.util.Date; @@ -21,25 +21,25 @@ /** * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. */ -public class ModelResourceDto extends AbstractModelDto { +public class ModelInfo extends AbstractModel { protected String author; protected Date creationDate; protected boolean hasImage = false; - protected List referencedBy = new ArrayList(); + protected List referencedBy = new ArrayList(); protected List supportedTargetPlatforms = new ArrayList(); - public ModelResourceDto(ModelIdDto modelId,ModelTypeDto modelType) { + public ModelInfo(ModelId modelId,ModelType modelType) { super(modelId,modelType); } - public List getReferencedBy() { + public List getReferencedBy() { return referencedBy; } - public void setReferencedBy(List referencedBy) { + public void setReferencedBy(List referencedBy) { this.referencedBy = referencedBy; } @@ -78,7 +78,7 @@ public void setHasImage(boolean hasImage) { @Override public String toString() { - return "ModelResource [id=" + id + ", modelType=" + modelType + "]"; + return "ModelResource [id=" + id + ", modelType=" + type + "]"; } @Override @@ -87,7 +87,7 @@ public int hashCode() { int result = 1; result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result - + ((modelType == null) ? 0 : modelType.hashCode()); + + ((type == null) ? 0 : type.hashCode()); return result; } @@ -99,13 +99,13 @@ public boolean equals(Object obj) { return false; if (getClass() != obj.getClass()) return false; - ModelResourceDto other = (ModelResourceDto) obj; + ModelInfo other = (ModelInfo) obj; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; - if (modelType != other.modelType) + if (type != other.type) return false; return true; } @@ -116,7 +116,7 @@ public void addTargetPlatform(String targetPlatform) { } } - public void addReferencedBy(ModelIdDto id) { + public void addReferencedBy(ModelId id) { this.referencedBy.add(id); } diff --git a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/EnumModelDto.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/ModelQuery.java similarity index 55% rename from server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/EnumModelDto.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/ModelQuery.java index bb2c7b9d6b..c0d5cc9b2c 100644 --- a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/EnumModelDto.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/ModelQuery.java @@ -12,26 +12,17 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.http.model; +package org.eclipse.vorto.repository.api; -import java.util.ArrayList; -import java.util.List; - -public class EnumModelDto extends AbstractModelDto { - - private List literals = new ArrayList(); +public class ModelQuery { - public EnumModelDto(ModelIdDto modelId, ModelTypeDto modelType) { - super(modelId, modelType); - } - - public List getLiterals() { - return literals; + private String expression; + + public ModelQuery(String expression) { + this.expression = expression; } - public void setLiterals(List literals) { - this.literals = literals; + public String getExpression() { + return this.expression; } - - } diff --git a/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/ModelQueryBuilder.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/ModelQueryBuilder.java new file mode 100644 index 0000000000..4ca0843c4c --- /dev/null +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/ModelQueryBuilder.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v1.0 which accompany this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * The Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Bosch Software Innovations GmbH - Please refer to git log + */ +package org.eclipse.vorto.repository.api; + +public class ModelQueryBuilder { + + private StringBuilder expression = new StringBuilder(); + + public ModelQueryBuilder name(String modelName) { + expression.append("name:"); + expression.append(modelName); + expression.append(" "); + return this; + } + + public ModelQueryBuilder namespace(String modelNamespace) { + expression.append("namespace:"); + expression.append(modelNamespace); + expression.append(" "); + return this; + } + + public ModelQueryBuilder type (ModelType modelType) { + expression.append(modelType.name()); + expression.append(" "); + return this; + } + + public ModelQueryBuilder freeText(String freeText) { + expression.append(freeText); + expression.append(" "); + return this; + } + + public ModelQuery build() { + return new ModelQuery(this.expression.toString()); + } +} diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/ModelType.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/ModelType.java similarity index 97% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/ModelType.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/ModelType.java index fbc2b3ef05..520d960596 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/ModelType.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/ModelType.java @@ -12,7 +12,7 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.repository.model; +package org.eclipse.vorto.repository.api; /** * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. diff --git a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ModelPropertyDto.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/AbstractProperty.java similarity index 69% rename from server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ModelPropertyDto.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/AbstractProperty.java index 4f79d457b9..c87069ba25 100644 --- a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ModelPropertyDto.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/AbstractProperty.java @@ -12,18 +12,31 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.http.model; +package org.eclipse.vorto.repository.api.content; -public class ModelPropertyDto { +import java.util.ArrayList; +import java.util.List; - private boolean isMandatory = true; - private String name; +public class AbstractProperty { + + protected boolean isMandatory = true; + protected String name; + + protected boolean isMultiple = false; + protected String description; - private boolean isMultiple = false; - private String description; + protected IReferenceType type = null; - private IReferenceType type = null; - + protected List constraints = new ArrayList<>(); + + public List getConstraints() { + return constraints; + } + + public void setConstraints(List constraints) { + this.constraints = constraints; + } + public boolean isMandatory() { return isMandatory; } @@ -57,7 +70,7 @@ public void setType(IReferenceType type) { } public boolean isPrimitive() { - return type instanceof PrimitiveTypeDto; + return type instanceof PrimitiveType; } public boolean isMultiple() { @@ -67,14 +80,4 @@ public boolean isMultiple() { public void setMultiple(boolean isMultiple) { this.isMultiple = isMultiple; } - - @Override - public String toString() { - return "ModelPropertyDto [isMandatory=" + isMandatory + ", name=" + name + ", isMultiple=" + isMultiple - + ", description=" + description + ", type=" + type + ", isPrimitive=" + isPrimitive() + "]"; - } - - - - } diff --git a/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/BooleanAttributeProperty.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/BooleanAttributeProperty.java new file mode 100644 index 0000000000..fd6f2d4c9e --- /dev/null +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/BooleanAttributeProperty.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v1.0 which accompany this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * The Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Bosch Software Innovations GmbH - Please refer to git log + */ +package org.eclipse.vorto.repository.api.content; + +public class BooleanAttributeProperty implements IPropertyAttribute { + + private BooleanAttributePropertyType type; + + private boolean value; + + public BooleanAttributeProperty(BooleanAttributePropertyType type, boolean value) { + super(); + this.type = type; + this.value = value; + } + + public BooleanAttributeProperty() { + + } + + public BooleanAttributePropertyType getType() { + return type; + } + + public void setType(BooleanAttributePropertyType type) { + this.type = type; + } + + public boolean isValue() { + return value; + } + + public void setValue(boolean value) { + this.value = value; + } + + @Override + public String toString() { + return "BooleanAttributeProperty [type=" + type + ", value=" + value + "]"; + } + + +} diff --git a/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/BooleanAttributePropertyType.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/BooleanAttributePropertyType.java new file mode 100644 index 0000000000..61516e3fa1 --- /dev/null +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/BooleanAttributePropertyType.java @@ -0,0 +1,21 @@ +/** + * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v1.0 which accompany this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * The Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Bosch Software Innovations GmbH - Please refer to git log + */ +package org.eclipse.vorto.repository.api.content; + +public enum BooleanAttributePropertyType { + READABLE, + WRITABLE, + EVENTABLE +} diff --git a/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/Constraint.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/Constraint.java new file mode 100644 index 0000000000..85eb32ddae --- /dev/null +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/Constraint.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v1.0 which accompany this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * The Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Bosch Software Innovations GmbH - Please refer to git log + */ +package org.eclipse.vorto.repository.api.content; + +public class Constraint { + + private ConstraintType type; + + private String value; + + public Constraint(ConstraintType type, String value) { + this.type = type; + this.value = value; + } + + public Constraint() { + + } + + public ConstraintType getType() { + return type; + } + + public void setType(ConstraintType type) { + this.type = type; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + + @Override + public String toString() { + return "Constraint [type=" + type + ", value=" + value + "]"; + } + + + + +} diff --git a/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/ConstraintType.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/ConstraintType.java new file mode 100644 index 0000000000..07b883b42c --- /dev/null +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/ConstraintType.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v1.0 which accompany this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * The Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Bosch Software Innovations GmbH - Please refer to git log + */ +package org.eclipse.vorto.repository.api.content; + +public enum ConstraintType { + + MIN, + MAX, + STRLEN, + REGEX, + MIMETYPE, + SCALING +} diff --git a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/EntityModelDto.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/EntityModel.java similarity index 62% rename from server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/EntityModelDto.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/EntityModel.java index 56caaeb50b..371b06704d 100644 --- a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/EntityModelDto.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/EntityModel.java @@ -12,24 +12,28 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.http.model; +package org.eclipse.vorto.repository.api.content; import java.util.ArrayList; import java.util.List; -public class EntityModelDto extends AbstractModelDto { +import org.eclipse.vorto.repository.api.AbstractModel; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelType; - public EntityModelDto(ModelIdDto modelId, ModelTypeDto modelType) { +public class EntityModel extends AbstractModel { + + public EntityModel(ModelId modelId, ModelType modelType) { super(modelId, modelType); } - private List properties = new ArrayList(); + private List properties = new ArrayList(); - public List getProperties() { + public List getProperties() { return properties; } - public void setProperties(List properties) { + public void setProperties(List properties) { this.properties = properties; } @@ -37,7 +41,6 @@ public void setProperties(List properties) { public String toString() { return "EntityModelDto [properties=" + properties + "]"; } - - + } diff --git a/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/EnumAttributeProperty.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/EnumAttributeProperty.java new file mode 100644 index 0000000000..67ce6da9ae --- /dev/null +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/EnumAttributeProperty.java @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v1.0 which accompany this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * The Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Bosch Software Innovations GmbH - Please refer to git log + */ +package org.eclipse.vorto.repository.api.content; + +public class EnumAttributeProperty implements IPropertyAttribute { + + private EnumAttributePropertyType type; + private EnumLiteral value; + + public EnumAttributeProperty(EnumAttributePropertyType type, EnumLiteral value) { + super(); + this.type = type; + this.value = value; + } + + public EnumAttributeProperty() { + + } + + public EnumAttributePropertyType getType() { + return type; + } + public void setType(EnumAttributePropertyType type) { + this.type = type; + } + public EnumLiteral getValue() { + return value; + } + public void setValue(EnumLiteral value) { + this.value = value; + } + + @Override + public String toString() { + return "EnumAttributeProperty [type=" + type + ", value=" + value + "]"; + } + + +} diff --git a/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/EnumAttributePropertyType.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/EnumAttributePropertyType.java new file mode 100644 index 0000000000..d7b7ed3531 --- /dev/null +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/EnumAttributePropertyType.java @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v1.0 which accompany this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * The Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Bosch Software Innovations GmbH - Please refer to git log + */ +package org.eclipse.vorto.repository.api.content; + +public enum EnumAttributePropertyType { + + MEASUREMENT_UNIT +} diff --git a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/EnumLiteralDto.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/EnumLiteral.java similarity index 89% rename from server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/EnumLiteralDto.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/EnumLiteral.java index 904eb36298..e73287afe9 100644 --- a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/EnumLiteralDto.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/EnumLiteral.java @@ -12,14 +12,14 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.http.model; +package org.eclipse.vorto.repository.api.content; -public class EnumLiteralDto { +public class EnumLiteral { private String name; private String description; - public EnumLiteralDto(String name, String description) { + public EnumLiteral(String name, String description) { super(); this.name = name; this.description = description; diff --git a/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/EnumModel.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/EnumModel.java new file mode 100644 index 0000000000..c2338308c9 --- /dev/null +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/EnumModel.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v1.0 which accompany this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * The Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Bosch Software Innovations GmbH - Please refer to git log + */ +package org.eclipse.vorto.repository.api.content; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.vorto.repository.api.AbstractModel; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelType; + +public class EnumModel extends AbstractModel { + + private List literals = new ArrayList(); + + public EnumModel(ModelId modelId, ModelType modelType) { + super(modelId, modelType); + } + + public List getLiterals() { + return literals; + } + + public void setLiterals(List literals) { + this.literals = literals; + } + + @Override + public ModelType getType() { + return ModelType.Datatype; + } + + @Override + public String toString() { + return "EnumModel [literals=" + literals + ", id=" + id + ", type=" + type + ", displayName=" + displayName + + ", description=" + description + ", references=" + references + "]"; + } + + +} diff --git a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/FunctionblockModelDto.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/FunctionblockModel.java similarity index 52% rename from server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/FunctionblockModelDto.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/FunctionblockModel.java index c54724c5c7..ec12455fe1 100644 --- a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/FunctionblockModelDto.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/FunctionblockModel.java @@ -12,78 +12,80 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.http.model; +package org.eclipse.vorto.repository.api.content; import java.util.ArrayList; import java.util.List; -public class FunctionblockModelDto extends AbstractModelDto { +import org.eclipse.vorto.repository.api.AbstractModel; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelType; - private List configurationProperties = new ArrayList<>(); - private List statusProperties = new ArrayList<>(); - private List faultProperties = new ArrayList<>(); - private List events = new ArrayList<>(); +public class FunctionblockModel extends AbstractModel { + + private List configurationProperties = new ArrayList<>(); + private List statusProperties = new ArrayList<>(); + private List faultProperties = new ArrayList<>(); + private List events = new ArrayList<>(); - private List operations = new ArrayList<>(); + private List operations = new ArrayList<>(); - public FunctionblockModelDto(ModelIdDto modelId, ModelTypeDto modelType) { + public FunctionblockModel(ModelId modelId, ModelType modelType) { super(modelId, modelType); } - public List getConfigurationProperties() { + public List getConfigurationProperties() { return configurationProperties; } - public void setConfigurationProperties(List configurationProperties) { + public void setConfigurationProperties(List configurationProperties) { this.configurationProperties = configurationProperties; } - public List getStatusProperties() { + public List getStatusProperties() { return statusProperties; } - public void setStatusProperties(List statusProperties) { + public void setStatusProperties(List statusProperties) { this.statusProperties = statusProperties; } - public List getFaultProperties() { + public List getFaultProperties() { return faultProperties; } - public void setFaultProperties(List faultProperties) { + public void setFaultProperties(List faultProperties) { this.faultProperties = faultProperties; } - public List getEvents() { + public List getEvents() { return events; } - - - public void setEvents(List events) { + public void setEvents(List events) { this.events = events; } - public List getOperations() { + public List getOperations() { return operations; } - public void setOperations(List operations) { + public void setOperations(List operations) { this.operations = operations; } @@ -93,7 +95,5 @@ public String toString() { + statusProperties + ", faultProperties=" + faultProperties + ", events=" + events + ", operations=" + operations + "]"; } - - } diff --git a/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/IPropertyAttribute.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/IPropertyAttribute.java new file mode 100644 index 0000000000..1c39a37551 --- /dev/null +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/IPropertyAttribute.java @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v1.0 which accompany this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * The Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Bosch Software Innovations GmbH - Please refer to git log + */ +package org.eclipse.vorto.repository.api.content; + +public interface IPropertyAttribute { + +} diff --git a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/IReferenceType.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/IReferenceType.java similarity index 92% rename from server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/IReferenceType.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/IReferenceType.java index 60a7aad8fd..25eeb0cd51 100644 --- a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/IReferenceType.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/IReferenceType.java @@ -12,7 +12,7 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.http.model; +package org.eclipse.vorto.repository.api.content; public interface IReferenceType { diff --git a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/InfomodelDto.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/Infomodel.java similarity index 62% rename from server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/InfomodelDto.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/Infomodel.java index 1302708137..30d52a46fc 100644 --- a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/InfomodelDto.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/Infomodel.java @@ -12,24 +12,28 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.http.model; +package org.eclipse.vorto.repository.api.content; import java.util.ArrayList; import java.util.List; -public class InfomodelDto extends AbstractModelDto { +import org.eclipse.vorto.repository.api.AbstractModel; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelType; - public InfomodelDto(ModelIdDto modelId, ModelTypeDto modelType) { +public class Infomodel extends AbstractModel { + + public Infomodel(ModelId modelId, ModelType modelType) { super(modelId, modelType); } - private List functionblocks = new ArrayList(); + private List functionblocks = new ArrayList(); - public List getFunctionblocks() { + public List getFunctionblocks() { return functionblocks; } - public void setFunctionblocks(List functionblocks) { + public void setFunctionblocks(List functionblocks) { this.functionblocks = functionblocks; } @@ -37,7 +41,5 @@ public void setFunctionblocks(List functionblocks) { public String toString() { return "InfomodelDto [functionblocks=" + functionblocks + "]"; } - - } diff --git a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ModelEventDto.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/ModelEvent.java similarity index 78% rename from server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ModelEventDto.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/ModelEvent.java index 2f127afae7..889a479545 100644 --- a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ModelEventDto.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/ModelEvent.java @@ -12,15 +12,15 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.http.model; +package org.eclipse.vorto.repository.api.content; import java.util.ArrayList; import java.util.List; -public class ModelEventDto { +public class ModelEvent { private String name; - private List properties = new ArrayList(); + private List properties = new ArrayList(); public String getName() { return name; @@ -28,10 +28,10 @@ public String getName() { public void setName(String name) { this.name = name; } - public List getProperties() { + public List getProperties() { return properties; } - public void setProperties(List properties) { + public void setProperties(List properties) { this.properties = properties; } @Override diff --git a/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/ModelProperty.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/ModelProperty.java new file mode 100644 index 0000000000..e238916e89 --- /dev/null +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/ModelProperty.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v1.0 which accompany this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * The Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Bosch Software Innovations GmbH - Please refer to git log + */ +package org.eclipse.vorto.repository.api.content; + +import java.util.ArrayList; +import java.util.List; + +public class ModelProperty extends AbstractProperty { + + private List attributes = new ArrayList(); + + public List getAttributes() { + return attributes; + } + + public void setAttributes(List attributes) { + this.attributes = attributes; + } + + @Override + public String toString() { + return "ModelProperty [attributes=" + attributes + ", isMandatory=" + isMandatory + ", name=" + name + + ", isMultiple=" + isMultiple + ", description=" + description + ", type=" + type + ", constraints=" + + constraints + "]"; + } + + + +} diff --git a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/OperationDto.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/Operation.java similarity index 81% rename from server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/OperationDto.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/Operation.java index b0f1c0284b..6d1da4f186 100644 --- a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/OperationDto.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/Operation.java @@ -12,21 +12,21 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.http.model; +package org.eclipse.vorto.repository.api.content; import java.util.ArrayList; import java.util.List; -public class OperationDto { +public class Operation { private String name; private String description; private boolean isBreakable = false; - private ReturnTypeDto result; + private ReturnType result; - private List params = new ArrayList<>(); + private List params = new ArrayList<>(); public String getName() { return name; @@ -52,19 +52,19 @@ public void setBreakable(boolean isBreakable) { this.isBreakable = isBreakable; } - public ReturnTypeDto getResult() { + public ReturnType getResult() { return result; } - public void setResult(ReturnTypeDto result) { + public void setResult(ReturnType result) { this.result = result; } - public List getParams() { + public List getParams() { return params; } - public void setParams(List params) { + public void setParams(List params) { this.params = params; } diff --git a/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/Param.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/Param.java new file mode 100644 index 0000000000..d3ab0bae1e --- /dev/null +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/Param.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v1.0 which accompany this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * The Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Bosch Software Innovations GmbH - Please refer to git log + */ +package org.eclipse.vorto.repository.api.content; + +public class Param extends AbstractProperty { + + @Override + public String toString() { + return "Param [isMandatory=" + isMandatory + ", name=" + name + ", isMultiple=" + isMultiple + ", description=" + + description + ", type=" + type + ", constraints=" + constraints + "]"; + } + +} diff --git a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/PrimitiveTypeDto.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/PrimitiveType.java similarity index 86% rename from server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/PrimitiveTypeDto.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/PrimitiveType.java index 009a638b85..459139f85c 100644 --- a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/PrimitiveTypeDto.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/PrimitiveType.java @@ -12,9 +12,9 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.http.model; +package org.eclipse.vorto.repository.api.content; -public enum PrimitiveTypeDto implements IReferenceType { +public enum PrimitiveType implements IReferenceType { STRING, INT, diff --git a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ReturnTypeDto.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/ReturnType.java similarity index 94% rename from server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ReturnTypeDto.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/ReturnType.java index b96c27b595..a69b299ad4 100644 --- a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ReturnTypeDto.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/content/ReturnType.java @@ -12,9 +12,9 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.http.model; +package org.eclipse.vorto.repository.api.content; -public class ReturnTypeDto { +public class ReturnType { private boolean isMultiple = false; diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/GenerationException.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/exception/GenerationException.java similarity index 94% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/GenerationException.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/exception/GenerationException.java index 827e5a1b4a..ca6186e216 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/GenerationException.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/exception/GenerationException.java @@ -12,7 +12,7 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.repository.service; +package org.eclipse.vorto.repository.api.exception; /** * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. diff --git a/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/exception/GeneratorNotFoundException.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/exception/GeneratorNotFoundException.java new file mode 100644 index 0000000000..b611a54338 --- /dev/null +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/exception/GeneratorNotFoundException.java @@ -0,0 +1,18 @@ +package org.eclipse.vorto.repository.api.exception; + +public class GeneratorNotFoundException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public GeneratorNotFoundException(String msg, Throwable t) { + super(msg,t); + } + + public GeneratorNotFoundException(String msg) { + super(msg); + } +} + diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/ModelNotFoundException.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/exception/ModelNotFoundException.java similarity index 87% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/ModelNotFoundException.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/exception/ModelNotFoundException.java index 3fbdc9f3be..59fe290bed 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/ModelNotFoundException.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/exception/ModelNotFoundException.java @@ -12,12 +12,12 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.repository.service; +package org.eclipse.vorto.repository.api.exception; /** * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. */ -public class ModelNotFoundException extends ModelRepositoryException { +public class ModelNotFoundException extends RuntimeException { /** * diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/GeneratedOutput.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/generation/GeneratedOutput.java similarity index 95% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/GeneratedOutput.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/generation/GeneratedOutput.java index eca1baa38d..b3e1b0c69a 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/GeneratedOutput.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/generation/GeneratedOutput.java @@ -12,7 +12,7 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.repository.model; +package org.eclipse.vorto.repository.api.generation; /** * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/GeneratorServiceInfo.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/generation/GeneratorInfo.java similarity index 89% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/GeneratorServiceInfo.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/generation/GeneratorInfo.java index b62da3a23c..fa087a081d 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/GeneratorServiceInfo.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/generation/GeneratorInfo.java @@ -12,9 +12,9 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.repository.model; +package org.eclipse.vorto.repository.api.generation; -public class GeneratorServiceInfo { +public class GeneratorInfo { private String key; private String name; private String description; @@ -25,7 +25,7 @@ public class GeneratorServiceInfo { private ServiceClassifier classifier; private String[] tags; private GeneratorRating rating; - private String generatorInfoUrl; + private String infoUrl; public String getKey() { return key; @@ -86,11 +86,11 @@ public void setClassifier(ServiceClassifier classifier) { public void performRating(int invocationCount) { this.rating = GeneratorRating.performRating(invocationCount); } - public String getGeneratorInfoUrl() { - return generatorInfoUrl; + public String getInfoUrl() { + return infoUrl; } - public void setGeneratorInfoUrl(String generatorInfoUrl) { - this.generatorInfoUrl = generatorInfoUrl; + public void setInfoUrl(String generatorInfoUrl) { + this.infoUrl = generatorInfoUrl; } public String[] getTags() { return tags; diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/GeneratorRating.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/generation/GeneratorRating.java similarity index 95% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/GeneratorRating.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/generation/GeneratorRating.java index a2470eac7c..263f6532d9 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/GeneratorRating.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/generation/GeneratorRating.java @@ -12,7 +12,7 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.repository.model; +package org.eclipse.vorto.repository.api.generation; /** * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/ServiceClassifier.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/generation/ServiceClassifier.java similarity index 93% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/ServiceClassifier.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/generation/ServiceClassifier.java index ed6d38431c..dc7d8ec7d9 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/ServiceClassifier.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/generation/ServiceClassifier.java @@ -12,7 +12,7 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.repository.model; +package org.eclipse.vorto.repository.api.generation; /** * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. diff --git a/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/resolver/BluetoothQuery.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/resolver/BluetoothQuery.java new file mode 100644 index 0000000000..dcdb38fe78 --- /dev/null +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/resolver/BluetoothQuery.java @@ -0,0 +1,9 @@ +package org.eclipse.vorto.repository.api.resolver; + +public class BluetoothQuery extends ResolveQuery { + + public BluetoothQuery(String modelNumber) { + super("bluetooth", "modelNumber", modelNumber, "DeviceInfoProfile"); + } + +} diff --git a/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/resolver/LWM2MQuery.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/resolver/LWM2MQuery.java new file mode 100644 index 0000000000..915409b1fd --- /dev/null +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/resolver/LWM2MQuery.java @@ -0,0 +1,9 @@ +package org.eclipse.vorto.repository.api.resolver; + +public class LWM2MQuery extends ResolveQuery { + + public LWM2MQuery(String attributeValue) { + super("lwm2m", "ObjectID", attributeValue, "Object"); + } + +} diff --git a/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/resolver/ResolveQuery.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/resolver/ResolveQuery.java new file mode 100644 index 0000000000..b2512c0776 --- /dev/null +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/resolver/ResolveQuery.java @@ -0,0 +1,36 @@ +package org.eclipse.vorto.repository.api.resolver; + +public class ResolveQuery { + + private String targetPlatformKey; + private String attributeId; + private String attributeValue; + private String stereoType; + + public ResolveQuery(String targetPlatformKey, String attributeId, String attributeValue, String stereoType) { + super(); + this.targetPlatformKey = targetPlatformKey; + this.attributeId = attributeId; + this.attributeValue = attributeValue; + this.stereoType = stereoType; + } + + public String getTargetPlatformKey() { + return targetPlatformKey; + } + + public String getAttributeId() { + return attributeId; + } + + public String getAttributeValue() { + return attributeValue; + } + + public String getStereoType() { + return stereoType; + } + + + +} diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/ModelHandle.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/upload/ModelHandle.java similarity index 91% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/ModelHandle.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/upload/ModelHandle.java index b38d7a7e7a..af74bea999 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/ModelHandle.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/upload/ModelHandle.java @@ -12,7 +12,9 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.repository.model; +package org.eclipse.vorto.repository.api.upload; + +import org.eclipse.vorto.repository.api.ModelId; /** * Model class to hold file handle id and associated model details. diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/ModelUploadHandle.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/upload/ModelUploadHandle.java similarity index 89% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/ModelUploadHandle.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/upload/ModelUploadHandle.java index f9a113e364..7c8f9af7a5 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/ModelUploadHandle.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/upload/ModelUploadHandle.java @@ -12,7 +12,10 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.repository.model; +package org.eclipse.vorto.repository.api.upload; + +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelType; /** * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. diff --git a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ServerResponseDto.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/upload/ServerResponse.java similarity index 88% rename from server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ServerResponseDto.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/upload/ServerResponse.java index 6b6fbdeaed..0865f898b4 100644 --- a/server/repo/repo-http-models/src/main/java/org/eclipse/vorto/http/model/ServerResponseDto.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/upload/ServerResponse.java @@ -12,14 +12,14 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.http.model; +package org.eclipse.vorto.repository.api.upload; /** * Generic server response type for client request. * @author Nagavijay Sivakumar - Robert Bosch (SEA) Pte. Ltd. * */ -public class ServerResponseDto { +public class ServerResponse { private String message = null; private Boolean isSuccess = null; @@ -28,11 +28,11 @@ public class ServerResponseDto { /* * Dummy constructor needed by ResponseEntity for JSON parsing of http response */ - public ServerResponseDto() { + public ServerResponse() { } - public ServerResponseDto(String message, Boolean isSuccess, Object obj) { + public ServerResponse(String message, Boolean isSuccess, Object obj) { this.message = message; this.isSuccess = isSuccess; this.obj = obj; diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/UploadModelResult.java b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/upload/UploadModelResult.java similarity index 51% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/UploadModelResult.java rename to server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/upload/UploadModelResult.java index fe077b4ec3..9803387bf3 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/UploadModelResult.java +++ b/server/repo/repository-api/src/main/java/org/eclipse/vorto/repository/api/upload/UploadModelResult.java @@ -12,27 +12,24 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.repository.model; +package org.eclipse.vorto.repository.api.upload; import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import org.eclipse.vorto.repository.internal.service.validation.ValidationException; -import org.eclipse.vorto.repository.internal.service.validation.exception.CouldNotResolveReferenceException; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; /** * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. */ public class UploadModelResult { private String handleId = null; - private ModelResource modelResource = null; + private ModelInfo modelResource = null; private boolean valid = false; private String errorMessage = null; private Collection unresolvedReferences; - private UploadModelResult(String handleId, ModelResource modelResource, boolean valid, String errorMessage) { + public UploadModelResult(String handleId, ModelInfo modelResource, boolean valid, String errorMessage) { super(); this.handleId = handleId; this.modelResource = modelResource; @@ -40,61 +37,26 @@ private UploadModelResult(String handleId, ModelResource modelResource, boolean this.errorMessage = errorMessage; } - private UploadModelResult(String handleId, ModelResource modelResource, boolean valid, String errorMessage, + public UploadModelResult(String handleId, ModelInfo modelResource, boolean valid, String errorMessage, Collection missingReferences) { this(handleId, modelResource, valid, errorMessage); this.unresolvedReferences = missingReferences; } - public static UploadModelResult invalid(ValidationException... validationExceptions) { - Objects.requireNonNull(validationExceptions); - if (validationExceptions.length <= 0) { - throw new IllegalArgumentException("There ought to be more than 1 validation exception for this function."); - } - - StringBuffer errorMessage = new StringBuffer(); - List missingReferences = Collections.emptyList(); - for(int i=0; i < validationExceptions.length; i++) { - if (validationExceptions[i] instanceof CouldNotResolveReferenceException) { - missingReferences = ((CouldNotResolveReferenceException) validationExceptions[i]).getMissingReferences(); - } - - if (errorMessage.length() != 0) { - errorMessage.append("\n"); - } - errorMessage.append((i + 1)); - errorMessage.append(") "); - errorMessage.append(validationExceptions[i].getMessage()); - } - - return new UploadModelResult(null, validationExceptions[0].getModelResource(), false, - errorMessage.toString(), missingReferences); - } - - public static UploadModelResult invalid(CouldNotResolveReferenceException validationException) { - return new UploadModelResult(null, validationException.getModelResource(), false, - validationException.getMessage(), validationException.getMissingReferences()); - } - - public static UploadModelResult invalid(ValidationException validationException) { - return new UploadModelResult(null, validationException.getModelResource(), false, - validationException.getMessage()); - } - - public static UploadModelResult invalid(ModelResource modelResource, String msg) { + public static UploadModelResult invalid(ModelInfo modelResource, String msg) { return new UploadModelResult(null, modelResource, false, msg); } - public static UploadModelResult valid(String uploadHandle, ModelResource modelResource) { + public static UploadModelResult valid(String uploadHandle, ModelInfo modelResource) { return new UploadModelResult(uploadHandle, modelResource, true, null); } - public static UploadModelResult valid(ModelResource modelResource) { + public static UploadModelResult valid(ModelInfo modelResource) { return new UploadModelResult(null, modelResource, true, null); } - public ModelResource getModelResource() { + public ModelInfo getModelResource() { return modelResource; } diff --git a/server/repo/repo-ui/Dockerfile b/server/repo/repository-server/Dockerfile similarity index 100% rename from server/repo/repo-ui/Dockerfile rename to server/repo/repository-server/Dockerfile diff --git a/server/repo/repo-ui/Readme.md b/server/repo/repository-server/Readme.md similarity index 100% rename from server/repo/repo-ui/Readme.md rename to server/repo/repository-server/Readme.md diff --git a/server/repo/repo-ui/pom.xml b/server/repo/repository-server/pom.xml similarity index 55% rename from server/repo/repo-ui/pom.xml rename to server/repo/repository-server/pom.xml index e29a0013cd..a35c14863a 100644 --- a/server/repo/repo-ui/pom.xml +++ b/server/repo/repository-server/pom.xml @@ -7,29 +7,116 @@ repo 0.9.0-SNAPSHOT - repo-ui + repository-server jar Vorto Model Repository UI - org.eclipse.vorto - repo-core + repository-api ${project.version} org.eclipse.vorto - repo-http-models + org.eclipse.vorto.server.commons ${project.version} + + + org.eclipse.core + org.eclipse.core.runtime + 3.7.0 + + + org.eclipse.vorto - org.eclipse.vorto.server.commons - ${project.version} + org.eclipse.vorto.core + + + org.eclipse.vorto + org.eclipse.vorto.editor + + + org.eclipse.vorto + org.eclipse.vorto.editor.datatype + + + org.eclipse.vorto + org.eclipse.vorto.editor.functionblock + + + org.eclipse.vorto + org.eclipse.vorto.editor.infomodel + + + org.eclipse.vorto + org.eclipse.vorto.editor.mapping + + + org.eclipse.xtext + org.eclipse.xtext + + + com.google.guava + guava + + + + + org.eclipse.xtext + org.eclipse.xtext.xbase + + + asm + org.ow2.asm + + + com.google.guava + guava + + + + + + + javax.jcr + jcr + + + org.modeshape + modeshape-sequencer-xml + + + org.modeshape + modeshape-jcr + + + org.modeshape + modeshape-jcr-api + + + org.modeshape + modeshape-common + + + org.modeshape + modeshape-unit-test + test + + + + + com.sun.mail + javax.mail + + + + org.freemarker + freemarker - @@ -42,6 +129,10 @@ spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-data-jpa + org.springframework.boot spring-boot-starter-security @@ -53,10 +144,10 @@ - com.h2database - h2 - - + com.h2database + h2 + + @@ -70,6 +161,12 @@ spring-test test + + + org.subethamail + subethasmtp + test + diff --git a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/VortoRepository.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/VortoRepository.java similarity index 100% rename from server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/VortoRepository.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/VortoRepository.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/model/DefaultModelContent.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/model/DefaultModelContent.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/model/DefaultModelContent.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/model/DefaultModelContent.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/model/ModelEMFResource.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/model/ModelEMFResource.java similarity index 89% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/model/ModelEMFResource.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/model/ModelEMFResource.java index c07f1660fc..deaea635f0 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/model/ModelEMFResource.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/model/ModelEMFResource.java @@ -26,15 +26,15 @@ import org.eclipse.vorto.core.api.model.mapping.MappingModel; import org.eclipse.vorto.core.api.model.model.Model; import org.eclipse.vorto.core.api.model.model.ModelReference; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ModelResource; -import org.eclipse.vorto.repository.model.ModelType; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; +import org.eclipse.vorto.repository.api.ModelType; /** * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. */ -public class ModelEMFResource extends ModelResource { +public class ModelEMFResource extends ModelInfo { private Model model; @@ -86,7 +86,7 @@ public byte[] toXMI() throws Exception { } public byte[] toDSL() throws Exception { - Resource resource = model.eResource().getResourceSet().createResource(URI.createURI(model.getName()+this.modelType.getExtension())); + Resource resource = model.eResource().getResourceSet().createResource(URI.createURI(model.getName()+this.type.getExtension())); resource.getContents().add(model); ByteArrayOutputStream baos = new ByteArrayOutputStream(); resource.save(baos, null); @@ -94,7 +94,7 @@ public byte[] toDSL() throws Exception { } public boolean matchesTargetPlatform(String targetPlatform) { - return this.modelType == ModelType.Mapping && ((MappingModel)model).getTargetPlatform().equalsIgnoreCase(targetPlatform); + return this.type == ModelType.Mapping && ((MappingModel)model).getTargetPlatform().equalsIgnoreCase(targetPlatform); } public String getTargetPlatform() { diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/resolver/AbstractResolver.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/resolver/AbstractResolver.java similarity index 60% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/resolver/AbstractResolver.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/resolver/AbstractResolver.java index 5135f1af94..f9d7f46cd5 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/resolver/AbstractResolver.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/resolver/AbstractResolver.java @@ -19,40 +19,45 @@ import java.util.Optional; import org.eclipse.vorto.core.api.model.mapping.MappingModel; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; +import org.eclipse.vorto.repository.api.ModelType; +import org.eclipse.vorto.repository.api.resolver.ResolveQuery; import org.eclipse.vorto.repository.model.IModelContent; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ModelResource; -import org.eclipse.vorto.repository.model.ModelType; -import org.eclipse.vorto.repository.resolver.IModelIdResolver; +import org.eclipse.vorto.repository.service.IModelIdResolver; import org.eclipse.vorto.repository.service.IModelRepository; import org.eclipse.vorto.repository.service.IModelRepository.ContentType; +import org.springframework.beans.factory.annotation.Autowired; public abstract class AbstractResolver implements IModelIdResolver { + @Autowired protected IModelRepository repository; - private String serviceKey; - - public AbstractResolver(IModelRepository repository, String serviceKey) { - this.repository = repository; - this.serviceKey = serviceKey; - } - @Override - public ModelId resolve(String id) { - List mappings = this.repository.search(ModelType.Mapping.name()); + public ModelId resolve(final ResolveQuery query) { + List mappings = this.repository.search(ModelType.Mapping.name()); Optional foundId = mappings.stream() - .filter(resource -> matchesServiceKey(resource)) - .map(r -> doResolve(r,id)) + .filter(resource -> matchesServiceKey(resource,query.getTargetPlatformKey())) + .map(r -> doResolve(r,query)) .filter(modelId -> Objects.nonNull(modelId)).findFirst(); return foundId.isPresent() ? foundId.get() : null; } - private boolean matchesServiceKey(ModelResource resource) { + private boolean matchesServiceKey(ModelInfo resource, String targetPlatformKey) { IModelContent content = this.repository.getModelContent(resource.getId(), ContentType.DSL); - return ((MappingModel)content.getModel()).getTargetPlatform().equals(this.serviceKey); + return ((MappingModel)content.getModel()).getTargetPlatform().equals(targetPlatformKey); } - protected abstract ModelId doResolve(ModelResource mappingModelResource, String id); + protected abstract ModelId doResolve(ModelInfo mappingModelResource, ResolveQuery query); + + public IModelRepository getRepository() { + return repository; + } + public void setRepository(IModelRepository repository) { + this.repository = repository; + } + + } diff --git a/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/resolver/DefaultResolver.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/resolver/DefaultResolver.java new file mode 100644 index 0000000000..673fac8327 --- /dev/null +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/resolver/DefaultResolver.java @@ -0,0 +1,34 @@ +package org.eclipse.vorto.repository.internal.resolver; + +import java.util.Optional; + +import org.eclipse.vorto.core.api.model.mapping.Attribute; +import org.eclipse.vorto.core.api.model.mapping.MappingModel; +import org.eclipse.vorto.core.api.model.mapping.MappingRule; +import org.eclipse.vorto.core.api.model.mapping.StereoTypeTarget; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; +import org.eclipse.vorto.repository.api.resolver.ResolveQuery; +import org.eclipse.vorto.repository.model.IModelContent; +import org.eclipse.vorto.repository.service.IModelRepository.ContentType; +import org.springframework.stereotype.Service; + +@Service +public class DefaultResolver extends AbstractResolver { + + @Override + protected ModelId doResolve(ModelInfo mappingModelResource, ResolveQuery query) { + IModelContent content = this.repository.getModelContent(mappingModelResource.getId(), ContentType.DSL); + MappingModel mappingModel = (MappingModel)content.getModel(); + Optional objectRule = mappingModel.getRules().stream().filter(rule -> rule.getTarget() instanceof StereoTypeTarget && ((StereoTypeTarget)rule.getTarget()).getName().equals(query.getStereoType())).findFirst(); + + if (objectRule.isPresent()) { + Optional objectIdAttribute = ((StereoTypeTarget)objectRule.get().getTarget()).getAttributes().stream().filter(attribute -> attribute.getName().equals(query.getAttributeId())).findFirst(); + if (objectIdAttribute.isPresent() && objectIdAttribute.get().getValue().equals(query.getAttributeValue())) { + return ModelId.fromReference(mappingModel.getReferences().get(0).getImportedNamespace(),mappingModel.getReferences().get(0).getVersion()); + } + } + return null; + } + +} diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/resolver/UnknownModelIdResolverException.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/resolver/UnknownModelIdResolverException.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/resolver/UnknownModelIdResolverException.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/resolver/UnknownModelIdResolverException.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/CommentRepository.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/CommentRepository.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/CommentRepository.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/CommentRepository.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/DefaultRepositoryManager.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/DefaultRepositoryManager.java similarity index 88% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/DefaultRepositoryManager.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/DefaultRepositoryManager.java index 16aab22389..ebcb9c69c4 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/DefaultRepositoryManager.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/DefaultRepositoryManager.java @@ -25,8 +25,9 @@ import javax.jcr.RepositoryException; import javax.jcr.Session; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ModelResource; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; +import org.eclipse.vorto.repository.internal.service.utils.ModelIdHelper; import org.eclipse.vorto.repository.service.FatalModelRepositoryException; import org.eclipse.vorto.repository.service.IModelRepository; import org.eclipse.vorto.repository.service.IRepositoryManager; @@ -78,13 +79,14 @@ public void setModelRepository(IModelRepository modelRepository) { @Override public void removeModel(ModelId modelId) { try { - ModelResource modelResource = this.modelRepository.getById(modelId); + ModelInfo modelResource = this.modelRepository.getById(modelId); if (!modelResource.getReferencedBy().isEmpty()) { throw new ModelReferentialIntegrityException( "Cannot remove model because it is referenced by other model(s)", modelResource.getReferencedBy()); } - Item item = session.getItem(modelId.getFullPath()); + ModelIdHelper modelIdHelper = new ModelIdHelper(modelId); + Item item = session.getItem(modelIdHelper.getFullPath()); item.remove(); session.save(); } catch (RepositoryException e) { @@ -94,7 +96,7 @@ public void removeModel(ModelId modelId) { private void removeAll() throws Exception { Set rootNodes = new HashSet<>(); - for (ModelResource resource : this.modelRepository.search("*")) { + for (ModelInfo resource : this.modelRepository.search("*")) { final String org = resource.getId().getNamespace().substring(0, resource.getId().getNamespace().indexOf(".")); rootNodes.add(org); diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/IModelParser.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/IModelParser.java similarity index 90% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/IModelParser.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/IModelParser.java index 5b42988c9d..99fb666e3a 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/IModelParser.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/IModelParser.java @@ -16,7 +16,8 @@ import java.io.InputStream; -import org.eclipse.vorto.repository.model.ModelResource; +import org.eclipse.vorto.repository.api.ModelInfo; + /** * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. @@ -28,5 +29,5 @@ public interface IModelParser { * @param is the actual content containing model related meta data * @return */ - ModelResource parse(InputStream is); + ModelInfo parse(InputStream is); } diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/ITemporaryStorage.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/ITemporaryStorage.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/ITemporaryStorage.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/ITemporaryStorage.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/InMemoryTemporaryStorage.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/InMemoryTemporaryStorage.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/InMemoryTemporaryStorage.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/InMemoryTemporaryStorage.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/JcrModelRepository.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/JcrModelRepository.java similarity index 83% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/JcrModelRepository.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/JcrModelRepository.java index 0cbaffd411..4ccfeae710 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/JcrModelRepository.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/JcrModelRepository.java @@ -42,10 +42,16 @@ import org.apache.commons.io.IOUtils; import org.apache.log4j.Logger; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; +import org.eclipse.vorto.repository.api.ModelType; +import org.eclipse.vorto.repository.api.exception.ModelNotFoundException; +import org.eclipse.vorto.repository.api.upload.UploadModelResult; import org.eclipse.vorto.repository.internal.model.DefaultModelContent; import org.eclipse.vorto.repository.internal.model.ModelEMFResource; import org.eclipse.vorto.repository.internal.service.notification.INotificationService; import org.eclipse.vorto.repository.internal.service.notification.message.CheckinMessage; +import org.eclipse.vorto.repository.internal.service.utils.ModelIdHelper; import org.eclipse.vorto.repository.internal.service.utils.ModelReferencesHelper; import org.eclipse.vorto.repository.internal.service.utils.ModelSearchUtil; import org.eclipse.vorto.repository.internal.service.validation.DuplicateModelValidation; @@ -53,15 +59,10 @@ import org.eclipse.vorto.repository.internal.service.validation.ModelReferencesValidation; import org.eclipse.vorto.repository.internal.service.validation.ValidationException; import org.eclipse.vorto.repository.model.IModelContent; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ModelResource; -import org.eclipse.vorto.repository.model.ModelType; -import org.eclipse.vorto.repository.model.UploadModelResult; import org.eclipse.vorto.repository.model.User; import org.eclipse.vorto.repository.service.FatalModelRepositoryException; import org.eclipse.vorto.repository.service.IModelRepository; import org.eclipse.vorto.repository.service.IUserRepository; -import org.eclipse.vorto.repository.service.ModelNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -95,12 +96,12 @@ public class JcrModelRepository implements IModelRepository { private static Logger logger = Logger.getLogger(JcrModelRepository.class); @Override - public List search(String queryExpression) { + public List search(String queryExpression) { if (queryExpression == null || queryExpression.isEmpty()) { queryExpression = "*"; } try { - List modelResources = new ArrayList<>(); + List modelResources = new ArrayList<>(); Query query = modelSearchUtil.createQueryFromExpression(session, queryExpression); @@ -126,8 +127,8 @@ public List search(String queryExpression) { } } - private ModelResource createModelResource(Node node) throws RepositoryException { - ModelResource resource = new ModelResource(ModelId.fromPath(node.getParent().getPath()), + private ModelInfo createModelResource(Node node) throws RepositoryException { + ModelInfo resource = new ModelInfo(ModelIdHelper.fromPath(node.getParent().getPath()), ModelType.valueOf(node.getProperty("vorto:type").getString())); resource.setDescription(node.getProperty("vorto:description").getString()); resource.setDisplayName(node.getProperty("vorto:displayname").getString()); @@ -150,7 +151,7 @@ private ModelResource createModelResource(Node node) throws RepositoryException String nodeUuid = referValue.getString(); Node referencedNode = session.getNodeByIdentifier(nodeUuid); referenceHelper.addModelReference( - ModelId.fromPath(referencedNode.getParent().getPath()).getPrettyFormat()); + ModelIdHelper.fromPath(referencedNode.getParent().getPath()).getPrettyFormat()); } resource.setReferences(referenceHelper.getReferences()); } @@ -160,7 +161,7 @@ private ModelResource createModelResource(Node node) throws RepositoryException while (propIter.hasNext()) { Property prop = propIter.nextProperty(); Node referencedByFileNode = prop.getParent(); - final ModelId referencedById = ModelId.fromPath(referencedByFileNode.getParent().getPath()); + final ModelId referencedById = ModelIdHelper.fromPath(referencedByFileNode.getParent().getPath()); resource.getReferencedBy().add(referencedById); } @@ -175,7 +176,8 @@ private ModelResource createModelResource(Node node) throws RepositoryException @Override public IModelContent getModelContent(ModelId modelId, ContentType contentType) { try { - Node folderNode = session.getNode(modelId.getFullPath()); + ModelIdHelper modelIdHelper = new ModelIdHelper(modelId); + Node folderNode = session.getNode(modelIdHelper.getFullPath()); Node fileNode = (Node) folderNode.getNodes(modelId.getName() + "*").next(); Node fileItem = (Node) fileNode.getPrimaryItem(); InputStream is = fileItem.getProperty("jcr:data").getBinary().getStream(); @@ -198,7 +200,7 @@ public IModelContent getModelContent(ModelId modelId, ContentType contentType) { public UploadModelResult upload(byte[] content, String fileName) { try { - ModelResource resource = ModelParserFactory.getParser(fileName).parse(new ByteArrayInputStream(content)); + ModelInfo resource = ModelParserFactory.getParser(fileName).parse(new ByteArrayInputStream(content)); List validationExceptions = new ArrayList(); for (IModelValidator validator : validators) { @@ -210,13 +212,13 @@ public UploadModelResult upload(byte[] content, String fileName) { } if (validationExceptions.size() <= 0) { - return UploadModelResult.valid(createUploadHandle(content, resource.getModelType()), resource); + return UploadModelResult.valid(createUploadHandle(content, resource.getType()), resource); } else { - return UploadModelResult - .invalid(validationExceptions.toArray(new ValidationException[validationExceptions.size()])); + return UploadModelResultFactory + .create(validationExceptions.toArray(new ValidationException[validationExceptions.size()])); } } catch (ValidationException e) { - return UploadModelResult.invalid(e); + return UploadModelResultFactory.invalid(e); } } @@ -233,12 +235,12 @@ public void checkin(String handleId, String author) { throw new IllegalArgumentException("No model found for handleId '" + handleId + "'"); } - final ModelResource resource = ModelParserFactory.getParser(handleId) + final ModelInfo resource = ModelParserFactory.getParser(handleId) .parse(new ByteArrayInputStream((byte[])uploadedItem.getValue())); try { Node folderNode = createNodeForModelId(resource.getId()); - Node fileNode = folderNode.addNode(resource.getId().getName() + resource.getModelType().getExtension(), + Node fileNode = folderNode.addNode(resource.getId().getName() + resource.getType().getExtension(), "nt:file"); fileNode.addMixin("vorto:meta"); fileNode.addMixin("mix:referenceable"); @@ -257,7 +259,7 @@ public void checkin(String handleId, String author) { } } - private void notifyWatchers(ModelResource resource, String author) { + private void notifyWatchers(ModelInfo resource, String author) { resource.setAuthor(author); for (User recipient : userRepository.findAll()) { if (recipient.getHasWatchOnRepository()) { @@ -270,8 +272,10 @@ private void notifyWatchers(ModelResource resource, String author) { } private Node createNodeForModelId(ModelId id) throws RepositoryException { + ModelIdHelper modelIdHelper = new ModelIdHelper(id); + StringBuilder pathBuilder = new StringBuilder(); - Iterator modelIdIterator = id.iterator(); + Iterator modelIdIterator = modelIdHelper.iterator(); Node rootNode = session.getRootNode(); while (modelIdIterator.hasNext()) { String nextPathFragment = modelIdIterator.next(); @@ -284,18 +288,20 @@ private Node createNodeForModelId(ModelId id) throws RepositoryException { } } - return rootNode.getNode(id.getFullPath().substring(1)); + return rootNode.getNode(modelIdHelper.getFullPath().substring(1)); } @Override - public ModelResource getById(ModelId modelId) { + public ModelInfo getById(ModelId modelId) { try { - Node folderNode = session.getNode(modelId.getFullPath()); + ModelIdHelper modelIdHelper = new ModelIdHelper(modelId); + + Node folderNode = session.getNode(modelIdHelper.getFullPath()); Node modelFileNode = folderNode.getNodes("*.type | *.fbmodel | *.infomodel | *.mapping").nextNode(); - ModelResource modelResource = createModelResource(modelFileNode); - if (modelResource.getModelType() == ModelType.InformationModel) { + ModelInfo modelResource = createModelResource(modelFileNode); + if (modelResource.getType() == ModelType.InformationModel) { NodeIterator imageNodeIterator = folderNode.getNodes("img.png*"); if (imageNodeIterator.hasNext()) { modelResource.setHasImage(true); @@ -324,13 +330,13 @@ public void setSession(Session session) { } @Override - public List getMappingModelsForTargetPlatform(ModelId modelId, String targetPlatform) { - List mappingResources = new ArrayList<>(); - ModelResource modelResource = getById(modelId); + public List getMappingModelsForTargetPlatform(ModelId modelId, String targetPlatform) { + List mappingResources = new ArrayList<>(); + ModelInfo modelResource = getById(modelId); if (modelResource != null) { for (ModelId referenceeModelId : modelResource.getReferencedBy()) { - ModelResource referenceeModelResources = getById(referenceeModelId); - if (referenceeModelResources.getModelType() == ModelType.Mapping + ModelInfo referenceeModelResources = getById(referenceeModelId); + if (referenceeModelResources.getType() == ModelType.Mapping && isTargetPlatformMapping(referenceeModelResources, targetPlatform)) { mappingResources.add(referenceeModelResources); } @@ -342,7 +348,7 @@ && isTargetPlatformMapping(referenceeModelResources, targetPlatform)) { return mappingResources; } - private boolean isTargetPlatformMapping(ModelResource model, String targetPlatform) { + private boolean isTargetPlatformMapping(ModelInfo model, String targetPlatform) { try { ModelEMFResource emfResource = getEMFResource(model.getId()); return emfResource.matchesTargetPlatform(targetPlatform); @@ -353,7 +359,9 @@ private boolean isTargetPlatformMapping(ModelResource model, String targetPlatfo private ModelEMFResource getEMFResource(ModelId modelId) { try { - Node folderNode = session.getNode(modelId.getFullPath()); + ModelIdHelper modelIdHelper = new ModelIdHelper(modelId); + + Node folderNode = session.getNode(modelIdHelper.getFullPath()); Node fileNode = (Node) folderNode.getNodes().next(); Node fileItem = (Node) fileNode.getPrimaryItem(); InputStream is = fileItem.getProperty("jcr:data").getBinary().getStream(); @@ -366,7 +374,8 @@ private ModelEMFResource getEMFResource(ModelId modelId) { @Override public void addModelImage(ModelId modelId, byte[] imageContent) { try { - Node modelFolderNode = session.getNode(modelId.getFullPath()); + ModelIdHelper modelIdHelper = new ModelIdHelper(modelId); + Node modelFolderNode = session.getNode(modelIdHelper.getFullPath()); Node contentNode = null; if (modelFolderNode.hasNode("img.png")) { Node imageNode = (Node) modelFolderNode.getNode("img.png"); @@ -389,7 +398,9 @@ public void addModelImage(ModelId modelId, byte[] imageContent) { @Override public byte[] getModelImage(ModelId modelId) { try { - Node folderNode = session.getNode(modelId.getFullPath()); + ModelIdHelper modelIdHelper = new ModelIdHelper(modelId); + + Node folderNode = session.getNode(modelIdHelper.getFullPath()); if (folderNode.hasNode("img.png")) { Node imageNode = folderNode.getNode("img.png"); Node fileItem = (Node) imageNode.getPrimaryItem(); diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/JcrRepositoryFactory.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/JcrRepositoryFactory.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/JcrRepositoryFactory.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/JcrRepositoryFactory.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/JcrSessionFactory.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/JcrSessionFactory.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/JcrSessionFactory.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/JcrSessionFactory.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/ModelParserFactory.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/ModelParserFactory.java similarity index 96% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/ModelParserFactory.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/ModelParserFactory.java index 7ab16de705..7a48875391 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/ModelParserFactory.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/ModelParserFactory.java @@ -14,11 +14,11 @@ */ package org.eclipse.vorto.repository.internal.service; +import org.eclipse.vorto.core.api.model.model.ModelType; import org.eclipse.vorto.repository.internal.service.emf.DatatypeModelParser; import org.eclipse.vorto.repository.internal.service.emf.FunctionblockModelParser; import org.eclipse.vorto.repository.internal.service.emf.InformationModelParser; import org.eclipse.vorto.repository.internal.service.emf.MappingModelParser; -import org.eclipse.vorto.repository.model.ModelType; /** * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/StorageItem.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/StorageItem.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/StorageItem.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/StorageItem.java diff --git a/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/UploadModelResultFactory.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/UploadModelResultFactory.java new file mode 100644 index 0000000000..c0e0af833a --- /dev/null +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/UploadModelResultFactory.java @@ -0,0 +1,50 @@ +package org.eclipse.vorto.repository.internal.service; + +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.upload.UploadModelResult; +import org.eclipse.vorto.repository.internal.service.validation.CouldNotResolveReferenceException; +import org.eclipse.vorto.repository.internal.service.validation.ValidationException; + +public class UploadModelResultFactory { + + + public static UploadModelResult create(ValidationException... validationExceptions) { + Objects.requireNonNull(validationExceptions); + if (validationExceptions.length <= 0) { + throw new IllegalArgumentException("There ought to be more than 1 validation exception for this function."); + } + + StringBuffer errorMessage = new StringBuffer(); + List missingReferences = Collections.emptyList(); + for(int i=0; i < validationExceptions.length; i++) { + if (validationExceptions[i] instanceof CouldNotResolveReferenceException) { + missingReferences = ((CouldNotResolveReferenceException) validationExceptions[i]).getMissingReferences(); + } + + if (errorMessage.length() != 0) { + errorMessage.append("\n"); + } + errorMessage.append((i + 1)); + errorMessage.append(") "); + errorMessage.append(validationExceptions[i].getMessage()); + } + + return new UploadModelResult(null, validationExceptions[0].getModelResource(), false, + errorMessage.toString(), missingReferences); + } + + public static UploadModelResult invalid(CouldNotResolveReferenceException validationException) { + return new UploadModelResult(null, validationException.getModelResource(), false, + validationException.getMessage(), validationException.getMissingReferences()); + } + + public static UploadModelResult invalid(ValidationException validationException) { + return new UploadModelResult(null, validationException.getModelResource(), false, + validationException.getMessage()); + } + +} diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/comment/CommentService.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/comment/CommentService.java similarity index 86% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/comment/CommentService.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/comment/CommentService.java index 1c90ad53e7..1a9f292fec 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/comment/CommentService.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/comment/CommentService.java @@ -19,14 +19,14 @@ import javax.jcr.PathNotFoundException; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.exception.ModelNotFoundException; import org.eclipse.vorto.repository.internal.service.CommentRepository; import org.eclipse.vorto.repository.model.Comment; -import org.eclipse.vorto.repository.model.ModelId; import org.eclipse.vorto.repository.model.User; import org.eclipse.vorto.repository.service.ICommentService; import org.eclipse.vorto.repository.service.IModelRepository; import org.eclipse.vorto.repository.service.IUserRepository; -import org.eclipse.vorto.repository.service.ModelNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -47,10 +47,10 @@ public class CommentService implements ICommentService{ public void createComment(Comment comment) { - final ModelId id = ModelId.fromPath(comment.getModelId()); + final ModelId id = ModelId.fromPrettyFormat(comment.getModelId()); if (modelRepository.getById(id) != null){ - comment.setModelId(id.getFullPath()); + comment.setModelId(id.getPrettyFormat()); comment.setDate(new Date()); commentRepository.save(comment); } else { @@ -60,7 +60,7 @@ public void createComment(Comment comment) { public List getCommentsforModelId(ModelId modelId){ - for (Comment comment : commentRepository.findByModelId(modelId.getFullPath())){ + for (Comment comment : commentRepository.findByModelId(modelId.getPrettyFormat())){ final User user = userRepository.findByUsername(comment.getAuthor()); if (user.getFirstName() != null && user.getLastName() != null){ comment.setFirstname(user.getFirstName()); @@ -68,6 +68,6 @@ public List getCommentsforModelId(ModelId modelId){ } } - return commentRepository.findByModelId(modelId.getFullPath()); + return commentRepository.findByModelId(modelId.getPrettyFormat()); } } diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/emf/AbstractModelParser.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/emf/AbstractModelParser.java similarity index 92% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/emf/AbstractModelParser.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/emf/AbstractModelParser.java index 48fe5209d4..84b6a87d2b 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/emf/AbstractModelParser.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/emf/AbstractModelParser.java @@ -23,12 +23,12 @@ import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.vorto.core.api.model.model.Model; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; +import org.eclipse.vorto.repository.api.ModelType; import org.eclipse.vorto.repository.internal.model.ModelEMFResource; import org.eclipse.vorto.repository.internal.service.IModelParser; import org.eclipse.vorto.repository.internal.service.validation.ValidationException; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ModelResource; -import org.eclipse.vorto.repository.model.ModelType; import org.eclipse.xtext.linking.impl.XtextLinkingDiagnostic; import org.eclipse.xtext.resource.XtextResource; import org.eclipse.xtext.resource.XtextResourceSet; @@ -47,7 +47,7 @@ public AbstractModelParser(String fileName) { } @Override - public ModelResource parse(InputStream is) { + public ModelInfo parse(InputStream is) { XtextResourceSet resourceSet = getInjector().getInstance(XtextResourceSet.class); resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE); Resource resource = resourceSet.createResource(URI.createURI("dummy:/" + fileName)); @@ -59,7 +59,7 @@ public ModelResource parse(InputStream is) { List grammarErrors = getGrammarErrors(resource.getErrors()); if (!grammarErrors.isEmpty()) { - ModelResource invalidModelResource = new ModelResource(parseModelIdFromFileName(), + ModelInfo invalidModelResource = new ModelInfo(parseModelIdFromFileName(), ModelType.fromFileName(fileName)); throw new ValidationException(grammarErrors.get(0).getMessage(), invalidModelResource); } diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/emf/DatatypeModelParser.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/emf/DatatypeModelParser.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/emf/DatatypeModelParser.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/emf/DatatypeModelParser.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/emf/FunctionblockModelParser.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/emf/FunctionblockModelParser.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/emf/FunctionblockModelParser.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/emf/FunctionblockModelParser.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/emf/InformationModelParser.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/emf/InformationModelParser.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/emf/InformationModelParser.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/emf/InformationModelParser.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/emf/MappingModelParser.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/emf/MappingModelParser.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/emf/MappingModelParser.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/emf/MappingModelParser.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/generation/GenerationDelegateProxyService.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/generation/GenerationDelegateProxyService.java similarity index 85% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/generation/GenerationDelegateProxyService.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/generation/GenerationDelegateProxyService.java index e32d12894a..bac904a1d1 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/generation/GenerationDelegateProxyService.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/generation/GenerationDelegateProxyService.java @@ -23,18 +23,18 @@ import java.util.Map; import java.util.Set; -import org.eclipse.vorto.repository.model.GeneratedOutput; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; +import org.eclipse.vorto.repository.api.ModelType; +import org.eclipse.vorto.repository.api.exception.GenerationException; +import org.eclipse.vorto.repository.api.exception.ModelNotFoundException; +import org.eclipse.vorto.repository.api.generation.GeneratedOutput; +import org.eclipse.vorto.repository.api.generation.GeneratorInfo; +import org.eclipse.vorto.repository.api.generation.ServiceClassifier; import org.eclipse.vorto.repository.model.Generator; -import org.eclipse.vorto.repository.model.GeneratorServiceInfo; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ModelResource; -import org.eclipse.vorto.repository.model.ModelType; -import org.eclipse.vorto.repository.model.ServiceClassifier; -import org.eclipse.vorto.repository.service.GenerationException; import org.eclipse.vorto.repository.service.GeneratorAlreadyExistsException; import org.eclipse.vorto.repository.service.IGeneratorService; import org.eclipse.vorto.repository.service.IModelRepository; -import org.eclipse.vorto.repository.service.ModelNotFoundException; import org.modeshape.common.collection.Collections; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -94,21 +94,21 @@ public Set getRegisteredGeneratorServiceKeys(ServiceClassifier classifie } @Override - public GeneratorServiceInfo getGeneratorServiceInfo(String serviceKey) { + public GeneratorInfo getGeneratorServiceInfo(String serviceKey) { Generator generatorEntity = getGenerator(serviceKey); - GeneratorServiceInfo generatorInfo = restTemplate.getForObject(generatorEntity.getGenerationInfoUrl(), GeneratorServiceInfo.class); - generatorInfo.setGeneratorInfoUrl(generatorEntity.getGenerationInfoUrl()); + GeneratorInfo generatorInfo = restTemplate.getForObject(generatorEntity.getGenerationInfoUrl(), GeneratorInfo.class); + generatorInfo.setInfoUrl(generatorEntity.getGenerationInfoUrl()); generatorInfo.performRating(generatorEntity.getInvocationCount()); return generatorInfo; } @Override public GeneratedOutput generate(ModelId modelId, String serviceKey, Map requestParams) { - ModelResource modelResource = modelRepositoryService.getById(modelId); + ModelInfo modelResource = modelRepositoryService.getById(modelId); if (modelResource == null) { throw new ModelNotFoundException("Model with the given ID does not exist",null); } - if (modelResource.getModelType() == ModelType.Datatype || modelResource.getModelType() == ModelType.Mapping) { + if (modelResource.getType() == ModelType.Datatype || modelResource.getType() == ModelType.Mapping) { throw new GenerationException("Provided model is neither an information model nor a function block model!"); } restTemplate.getMessageConverters().add(new ByteArrayHttpMessageConverter()); @@ -160,7 +160,7 @@ private Generator getGenerator(String serviceKey) { } @Override - public Collection getMostlyUsedGenerators(int top) { + public Collection getMostlyUsedGenerators(int top) { List topResult = new ArrayList(); for (Generator entity : this.registeredGeneratorsRepository.findByClassifier(ServiceClassifier.platform.name())) { @@ -181,7 +181,7 @@ public int compare(Generator o1, Generator o2) { } }); - List result = new ArrayList<>(top); + List result = new ArrayList<>(top); int counter = 0; for (Generator entity : topResult) { if (counter < top) { diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/generation/IGeneratorLookupRepository.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/generation/IGeneratorLookupRepository.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/generation/IGeneratorLookupRepository.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/generation/IGeneratorLookupRepository.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/notification/EmailNotificationService.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/notification/EmailNotificationService.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/notification/EmailNotificationService.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/notification/EmailNotificationService.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/notification/IMessage.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/notification/IMessage.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/notification/IMessage.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/notification/IMessage.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/notification/INotificationService.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/notification/INotificationService.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/notification/INotificationService.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/notification/INotificationService.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/notification/message/AbstractMessage.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/notification/message/AbstractMessage.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/notification/message/AbstractMessage.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/notification/message/AbstractMessage.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/notification/message/CheckinMessage.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/notification/message/CheckinMessage.java similarity index 84% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/notification/message/CheckinMessage.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/notification/message/CheckinMessage.java index c12173f22f..878b2a078a 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/notification/message/CheckinMessage.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/notification/message/CheckinMessage.java @@ -17,16 +17,16 @@ import java.util.HashMap; import java.util.Map; -import org.eclipse.vorto.repository.model.ModelResource; +import org.eclipse.vorto.repository.api.ModelInfo; import org.eclipse.vorto.repository.model.User; public class CheckinMessage extends AbstractMessage { - private ModelResource modelResource; + private ModelInfo modelResource; private TemplateRenderer renderer; - public CheckinMessage(User recipient, ModelResource modelResource) { + public CheckinMessage(User recipient, ModelInfo modelResource) { super(recipient); this.modelResource = modelResource; this.renderer = new TemplateRenderer("checkin_watch.ftl"); @@ -34,7 +34,7 @@ public CheckinMessage(User recipient, ModelResource modelResource) { @Override public String getSubject() { - return modelResource.getModelType().name()+" was added to the Vorto Repository"; + return modelResource.getType().name()+" was added to the Vorto Repository"; } @Override diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/notification/message/RegistrationMessage.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/notification/message/RegistrationMessage.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/notification/message/RegistrationMessage.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/notification/message/RegistrationMessage.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/notification/message/TemplateRenderer.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/notification/message/TemplateRenderer.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/notification/message/TemplateRenderer.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/notification/message/TemplateRenderer.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/sequencer/ModelSequencer.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/sequencer/ModelSequencer.java similarity index 87% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/sequencer/ModelSequencer.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/sequencer/ModelSequencer.java index 9fdf1c47a2..02185c5fd7 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/sequencer/ModelSequencer.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/sequencer/ModelSequencer.java @@ -25,10 +25,11 @@ import javax.jcr.RepositoryException; import javax.jcr.Value; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; import org.eclipse.vorto.repository.internal.service.ModelParserFactory; +import org.eclipse.vorto.repository.internal.service.utils.ModelIdHelper; import org.eclipse.vorto.repository.internal.service.utils.ModelReferencesHelper; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ModelResource; import org.modeshape.common.util.CheckArg; import org.modeshape.jcr.api.nodetype.NodeTypeManager; import org.modeshape.jcr.api.sequencer.Sequencer; @@ -56,12 +57,12 @@ public boolean execute(Property inputProperty, Node outputNode, Binary binaryValue = inputProperty.getBinary(); CheckArg.isNotNull(binaryValue, "binary"); - ModelResource modelResource = ModelParserFactory.getParser(outputNode.getPath()).parse(binaryValue.getStream()); + ModelInfo modelResource = ModelParserFactory.getParser(outputNode.getPath()).parse(binaryValue.getStream()); outputNode.setProperty("vorto:description", modelResource .getDescription() != null ? modelResource.getDescription() : ""); - outputNode.setProperty("vorto:type", modelResource.getModelType() + outputNode.setProperty("vorto:type", modelResource.getType() .name()); outputNode.setProperty("vorto:displayname", modelResource.getDisplayName()); @@ -73,7 +74,8 @@ public boolean execute(Property inputProperty, Node outputNode, if (referencesHelper.hasReferences()) { List references = new ArrayList(); for (ModelId modelId : referencesHelper.getReferences()) { - Node referencedFolder = outputNode.getSession().getNode(modelId.getFullPath()); + ModelIdHelper modelIdHelper = new ModelIdHelper(modelId); + Node referencedFolder = outputNode.getSession().getNode(modelIdHelper.getFullPath()); Node reference = referencedFolder.getNodes().nextNode(); references.add(context.valueFactory().createValue(reference)); } diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/signup/DefaultRegistrationService.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/signup/DefaultRegistrationService.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/signup/DefaultRegistrationService.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/signup/DefaultRegistrationService.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/utils/BulkUploadHelper.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/utils/BulkUploadHelper.java similarity index 88% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/utils/BulkUploadHelper.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/utils/BulkUploadHelper.java index 8d771632d8..e1455df59a 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/utils/BulkUploadHelper.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/utils/BulkUploadHelper.java @@ -27,17 +27,18 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; +import org.eclipse.vorto.repository.api.ModelInfo; +import org.eclipse.vorto.repository.api.ModelType; +import org.eclipse.vorto.repository.api.upload.UploadModelResult; import org.eclipse.vorto.repository.internal.model.ModelEMFResource; import org.eclipse.vorto.repository.internal.service.ITemporaryStorage; import org.eclipse.vorto.repository.internal.service.ModelParserFactory; +import org.eclipse.vorto.repository.internal.service.UploadModelResultFactory; import org.eclipse.vorto.repository.internal.service.validation.BulkModelDuplicateIdValidation; import org.eclipse.vorto.repository.internal.service.validation.BulkModelReferencesValidation; import org.eclipse.vorto.repository.internal.service.validation.DuplicateModelValidation; import org.eclipse.vorto.repository.internal.service.validation.IModelValidator; import org.eclipse.vorto.repository.internal.service.validation.ValidationException; -import org.eclipse.vorto.repository.model.ModelResource; -import org.eclipse.vorto.repository.model.ModelType; -import org.eclipse.vorto.repository.model.UploadModelResult; import org.eclipse.vorto.repository.service.FatalModelRepositoryException; import org.eclipse.vorto.repository.service.IModelRepository; import org.springframework.util.StringUtils; @@ -63,7 +64,7 @@ public List uploadMultiple(byte[] content, String zipFileName List invalidResult = new ArrayList(); List validResult = new ArrayList(); - Set parsedModels = new HashSet<>(); + Set parsedModels = new HashSet<>(); ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(content)); ZipEntry entry = null; @@ -75,7 +76,7 @@ public List uploadMultiple(byte[] content, String zipFileName try { parsedModels.add(ModelParserFactory.getParser(fileName).parse(new ByteArrayInputStream(copyStream(zis,entry)))); } catch (ValidationException grammarProblem) { - invalidResult.add(UploadModelResult.invalid(grammarProblem)); + invalidResult.add(UploadModelResultFactory.create(grammarProblem)); } } @@ -88,7 +89,7 @@ public List uploadMultiple(byte[] content, String zipFileName List bulkUploadValidators = constructBulkUploadValidators(parsedModels); - for (ModelResource modelResource : parsedModels) { + for (ModelInfo modelResource : parsedModels) { try { for (IModelValidator validator : bulkUploadValidators) { validator.validate(modelResource); @@ -100,7 +101,7 @@ public List uploadMultiple(byte[] content, String zipFileName } } catch (ValidationException validationException) { - invalidResult.add(UploadModelResult.invalid(validationException)); + invalidResult.add(UploadModelResultFactory.create(validationException)); } } @@ -123,11 +124,11 @@ public List uploadMultiple(byte[] content, String zipFileName /** * @param zipFileName */ - private List safelyUpload(Collection resources) throws Exception { + private List safelyUpload(Collection resources) throws Exception { List result = new ArrayList(); - for (ModelResource resource : resources) { - result.add(UploadModelResult.valid(createUploadHandle(((ModelEMFResource)resource).toDSL(),resource.getModelType()), resource)); + for (ModelInfo resource : resources) { + result.add(UploadModelResult.valid(createUploadHandle(((ModelEMFResource)resource).toDSL(),resource.getType()), resource)); } return result; @@ -142,7 +143,7 @@ private boolean isValid(String file) { return !StringUtils.isEmpty(file) && StringUtils.endsWithIgnoreCase(file, ".zip"); } - private List constructBulkUploadValidators(Set modelResources) { + private List constructBulkUploadValidators(Set modelResources) { List bulkUploadValidators = new LinkedList(); bulkUploadValidators.add(new DuplicateModelValidation(this.repositoryService)); bulkUploadValidators.add(new BulkModelDuplicateIdValidation(this.repositoryService, modelResources)); diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/utils/DependencyManager.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/utils/DependencyManager.java similarity index 65% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/utils/DependencyManager.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/utils/DependencyManager.java index 1cd9b84672..d6b31a13d1 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/utils/DependencyManager.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/utils/DependencyManager.java @@ -19,38 +19,38 @@ import java.util.List; import java.util.Set; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ModelResource; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; public class DependencyManager { - private Set resources = new HashSet<>(); + private Set resources = new HashSet<>(); public DependencyManager() { } - public DependencyManager(Set resources) { + public DependencyManager(Set resources) { this.resources = resources; } - public void addResource(ModelResource resource) { + public void addResource(ModelInfo resource) { this.resources.add(resource); } - public List getSorted() { - List sorted = new ArrayList<>(); + public List getSorted() { + List sorted = new ArrayList<>(); - for (ModelResource resource : resources) { + for (ModelInfo resource : resources) { addResourceRecursive(resource, sorted); } return sorted; } - private void addResourceRecursive(ModelResource resource, List sorted) { + private void addResourceRecursive(ModelInfo resource, List sorted) { for (ModelId reference : resource.getReferences()) { - ModelResource referencedResource = findResource(reference); + ModelInfo referencedResource = findResource(reference); if (referencedResource != null) { addResourceRecursive(referencedResource, sorted); } @@ -60,8 +60,8 @@ private void addResourceRecursive(ModelResource resource, List so } } - private ModelResource findResource(final ModelId modelId) { - for (ModelResource resource : this.resources) { + private ModelInfo findResource(final ModelId modelId) { + for (ModelInfo resource : this.resources) { if (resource.getId().equals(modelId)) { return resource; } diff --git a/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/utils/ModelIdHelper.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/utils/ModelIdHelper.java new file mode 100644 index 0000000000..44c2867be0 --- /dev/null +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/utils/ModelIdHelper.java @@ -0,0 +1,84 @@ +package org.eclipse.vorto.repository.internal.service.utils; + +import java.util.Iterator; +import java.util.StringTokenizer; + +import org.eclipse.vorto.repository.api.ModelId; + +public class ModelIdHelper { + + private ModelId modelId; + + private static final String PATH_DELIMITER = "/"; + + public ModelIdHelper(ModelId modelId) { + this.modelId = modelId; + } + + public String getFullPath() { + StringBuilder path = new StringBuilder(getNamespacePath()); + path.append(PATH_DELIMITER); + path.append(modelId.getName()); + path.append(PATH_DELIMITER); + path.append(modelId.getVersion()); + return path.toString(); + } + + public String getNamespacePath() { + StringBuilder path = new StringBuilder(PATH_DELIMITER); + StringTokenizer tokenizer = new StringTokenizer(modelId.getNamespace(), "."); + while(tokenizer.hasMoreTokens()) { + path.append(tokenizer.nextToken()); + if (tokenizer.hasMoreTokens()) { + path.append(PATH_DELIMITER); + } + } + return path.toString(); + } + + /** + * Example path: /org/eclipse/vorto/color/1.0.0/ + * @param path + * @return + */ + public static ModelId fromPath(String path) { + String[] pathFragments = path.substring(1).split("/"); + return new ModelId(pathFragments[pathFragments.length-2],convertToNamespace(pathFragments),pathFragments[pathFragments.length-1]); + } + + private static String convertToNamespace(String[] fragments) { + StringBuilder namespaceBuilder = new StringBuilder(); + for (int i = 0; i < fragments.length-2;i++) { + namespaceBuilder.append(fragments[i]); + if (i < fragments.length-3) { + namespaceBuilder.append("."); + } + } + return namespaceBuilder.toString(); + } + public Iterator iterator() { + return new StringTokenizerIterator(getFullPath()); + } + + private static class StringTokenizerIterator implements Iterator { + + private StringTokenizer enumeration; + + public StringTokenizerIterator(String fullPath) { + this.enumeration = new StringTokenizer(fullPath.substring(1),"/"); + } + + public boolean hasNext() { + return this.enumeration.hasMoreElements(); + } + + public String next() { + return this.enumeration.nextToken(); + } + + public void remove() throws UnsupportedOperationException { + throw new UnsupportedOperationException(); + } + } + +} diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/utils/ModelReferencesHelper.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/utils/ModelReferencesHelper.java similarity index 97% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/utils/ModelReferencesHelper.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/utils/ModelReferencesHelper.java index ae9e6fbede..bb85cd1e84 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/utils/ModelReferencesHelper.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/utils/ModelReferencesHelper.java @@ -17,7 +17,7 @@ import java.util.ArrayList; import java.util.List; -import org.eclipse.vorto.repository.model.ModelId; +import org.eclipse.vorto.repository.api.ModelId; /** * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/utils/ModelSearchUtil.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/utils/ModelSearchUtil.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/utils/ModelSearchUtil.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/utils/ModelSearchUtil.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/validation/BulkModelDuplicateIdValidation.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/validation/BulkModelDuplicateIdValidation.java similarity index 82% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/validation/BulkModelDuplicateIdValidation.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/validation/BulkModelDuplicateIdValidation.java index 60cc95007e..a2a4e883c3 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/validation/BulkModelDuplicateIdValidation.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/validation/BulkModelDuplicateIdValidation.java @@ -19,19 +19,19 @@ import java.util.Set; import java.util.stream.Collectors; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ModelResource; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; import org.eclipse.vorto.repository.service.IModelRepository; public class BulkModelDuplicateIdValidation extends ModelReferencesValidation { private List zipModelIds; - public BulkModelDuplicateIdValidation(IModelRepository modelRepository, Set modelResources) { + public BulkModelDuplicateIdValidation(IModelRepository modelRepository, Set modelResources) { super(modelRepository); - zipModelIds = modelResources.stream().map(new java.util.function.Function() { + zipModelIds = modelResources.stream().map(new java.util.function.Function() { @Override - public ModelId apply(ModelResource resource) { + public ModelId apply(ModelInfo resource) { return resource.getId(); } @@ -39,7 +39,7 @@ public ModelId apply(ModelResource resource) { } @Override - public void validate(ModelResource modelResource) throws ValidationException { + public void validate(ModelInfo modelResource) throws ValidationException { Set nonduplicates = new HashSet<>(); for (ModelId modelId : zipModelIds) { diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/validation/BulkModelReferencesValidation.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/validation/BulkModelReferencesValidation.java similarity index 77% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/validation/BulkModelReferencesValidation.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/validation/BulkModelReferencesValidation.java index 9abf957fff..6b029c74a5 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/validation/BulkModelReferencesValidation.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/validation/BulkModelReferencesValidation.java @@ -19,9 +19,8 @@ import java.util.Set; import java.util.stream.Collectors; -import org.eclipse.vorto.repository.internal.service.validation.exception.CouldNotResolveReferenceException; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ModelResource; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; import org.eclipse.vorto.repository.service.IModelRepository; /** @@ -33,11 +32,11 @@ public class BulkModelReferencesValidation extends ModelReferencesValidation { private List zipModelIds; - public BulkModelReferencesValidation(IModelRepository modelRepository, Set modelResources) { + public BulkModelReferencesValidation(IModelRepository modelRepository, Set modelResources) { super(modelRepository); - zipModelIds = modelResources.stream().map(new java.util.function.Function() { + zipModelIds = modelResources.stream().map(new java.util.function.Function() { @Override - public ModelId apply(ModelResource resource) { + public ModelId apply(ModelInfo resource) { return resource.getId(); } @@ -45,13 +44,13 @@ public ModelId apply(ModelResource resource) { } @Override - public void validate(ModelResource modelResource) throws ValidationException { + public void validate(ModelInfo modelResource) throws ValidationException { validateInRepository(modelResource); //Validate other references in zip files. validateInZipFiles(modelResource); } - private List validateInRepository(ModelResource modelResource) { + private List validateInRepository(ModelInfo modelResource) { List missingReferences = new ArrayList(); try { super.validate(modelResource); @@ -66,7 +65,7 @@ private boolean isNotInRepository(ModelId modelId) { } - private void validateInZipFiles(ModelResource modelResource) { + private void validateInZipFiles(ModelInfo modelResource) { List references = modelResource.getReferences(); List missingReferences = new ArrayList(); for (ModelId modelId : references) { diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/validation/exception/CouldNotResolveReferenceException.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/validation/CouldNotResolveReferenceException.java similarity index 80% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/validation/exception/CouldNotResolveReferenceException.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/validation/CouldNotResolveReferenceException.java index 1df75636d3..1693617b98 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/validation/exception/CouldNotResolveReferenceException.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/validation/CouldNotResolveReferenceException.java @@ -12,21 +12,20 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.repository.internal.service.validation.exception; +package org.eclipse.vorto.repository.internal.service.validation; import java.util.List; import java.util.Objects; -import org.eclipse.vorto.repository.internal.service.validation.ValidationException; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ModelResource; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; public class CouldNotResolveReferenceException extends ValidationException { private static final long serialVersionUID = -6078848052990402848L; private List missingReferences; - public CouldNotResolveReferenceException(ModelResource resource, List missingReferences) { + public CouldNotResolveReferenceException(ModelInfo resource, List missingReferences) { super(createErrorMessage(resource, missingReferences), resource); this.missingReferences = Objects.requireNonNull(missingReferences); if (missingReferences.size() <= 0) { @@ -38,7 +37,7 @@ public List getMissingReferences() { return missingReferences; } - private static String createErrorMessage(ModelResource resource, + private static String createErrorMessage(ModelInfo resource, List missingReferences) { if (missingReferences.size() > 1) { return "Cannot resolve multiple references."; diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/validation/DuplicateModelValidation.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/validation/DuplicateModelValidation.java similarity index 91% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/validation/DuplicateModelValidation.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/validation/DuplicateModelValidation.java index 820534558f..f6abf402c7 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/validation/DuplicateModelValidation.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/validation/DuplicateModelValidation.java @@ -14,7 +14,7 @@ */ package org.eclipse.vorto.repository.internal.service.validation; -import org.eclipse.vorto.repository.model.ModelResource; +import org.eclipse.vorto.repository.api.ModelInfo; import org.eclipse.vorto.repository.service.IModelRepository; /** @@ -29,7 +29,7 @@ public DuplicateModelValidation(IModelRepository modelRepository) { } @Override - public void validate(ModelResource modelResource) + public void validate(ModelInfo modelResource) throws ValidationException { if (modelRepository.getById(modelResource.getId()) != null) { throw new ValidationException("Model already exists", modelResource); diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/validation/IModelValidator.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/validation/IModelValidator.java similarity index 86% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/validation/IModelValidator.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/validation/IModelValidator.java index 467cebd49a..60df3f9be1 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/validation/IModelValidator.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/validation/IModelValidator.java @@ -14,7 +14,7 @@ */ package org.eclipse.vorto.repository.internal.service.validation; -import org.eclipse.vorto.repository.model.ModelResource; +import org.eclipse.vorto.repository.api.ModelInfo; /** * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. @@ -26,5 +26,5 @@ public interface IModelValidator { * @param modelResource * @throws ValidationException */ - void validate(ModelResource modelResource) throws ValidationException; + void validate(ModelInfo modelResource) throws ValidationException; } diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/validation/ModelReferencesValidation.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/validation/ModelReferencesValidation.java similarity index 79% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/validation/ModelReferencesValidation.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/validation/ModelReferencesValidation.java index e21464247c..0049aac9a9 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/validation/ModelReferencesValidation.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/validation/ModelReferencesValidation.java @@ -17,9 +17,8 @@ import java.util.ArrayList; import java.util.List; -import org.eclipse.vorto.repository.internal.service.validation.exception.CouldNotResolveReferenceException; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ModelResource; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; import org.eclipse.vorto.repository.service.IModelRepository; /** @@ -38,7 +37,7 @@ public IModelRepository getModelRepository() { } @Override - public void validate(ModelResource modelResource) + public void validate(ModelInfo modelResource) throws ValidationException { List missingReferences = new ArrayList(); if (!modelResource.getReferences().isEmpty()) { @@ -50,9 +49,9 @@ public void validate(ModelResource modelResource) } } - private void checkReferencesRecursive(ModelResource modelResource, List accumulator) { + private void checkReferencesRecursive(ModelInfo modelResource, List accumulator) { for (ModelId modelId : modelResource.getReferences()) { - ModelResource reference = modelRepository.getById(modelId); + ModelInfo reference = modelRepository.getById(modelId); if (reference == null) { accumulator.add(modelId); } else { diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/validation/ValidationException.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/validation/ValidationException.java similarity index 76% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/validation/ValidationException.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/validation/ValidationException.java index 0e861cc710..35dc5ab3bd 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/internal/service/validation/ValidationException.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/internal/service/validation/ValidationException.java @@ -14,7 +14,7 @@ */ package org.eclipse.vorto.repository.internal.service.validation; -import org.eclipse.vorto.repository.model.ModelResource; +import org.eclipse.vorto.repository.api.ModelInfo; /** * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. @@ -26,19 +26,19 @@ public class ValidationException extends RuntimeException { */ private static final long serialVersionUID = 1L; - private ModelResource modelResource = null; + private ModelInfo modelResource = null; - public ValidationException(String msg, ModelResource modelResource) { + public ValidationException(String msg, ModelInfo modelResource) { super(msg); this.modelResource = modelResource; } - public ValidationException(String msg, ModelResource modelResource, Throwable t) { + public ValidationException(String msg, ModelInfo modelResource, Throwable t) { super(msg,t); this.modelResource = modelResource; } - public ModelResource getModelResource() { + public ModelInfo getModelResource() { return modelResource; } } diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/Comment.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/model/Comment.java similarity index 96% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/Comment.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/model/Comment.java index 057005ff90..212d488915 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/Comment.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/model/Comment.java @@ -24,6 +24,8 @@ import javax.persistence.Id; import javax.validation.constraints.NotNull; +import org.eclipse.vorto.repository.api.ModelId; + /** * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. */ @@ -51,7 +53,7 @@ public class Comment { public Comment(){} public Comment (ModelId modelId, String author, String content) { - this.modelId = modelId.getFullPath(); + this.modelId = modelId.getPrettyFormat(); this.author = author; this.content = content; this.createdOn = ""; diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/Generator.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/model/Generator.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/Generator.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/model/Generator.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/IModelContent.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/model/IModelContent.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/IModelContent.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/model/IModelContent.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/Role.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/model/Role.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/Role.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/model/Role.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/User.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/model/User.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/User.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/model/User.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/UserDto.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/model/UserDto.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/model/UserDto.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/model/UserDto.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/FatalModelRepositoryException.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/FatalModelRepositoryException.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/FatalModelRepositoryException.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/FatalModelRepositoryException.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/GeneratorAlreadyExistsException.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/GeneratorAlreadyExistsException.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/GeneratorAlreadyExistsException.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/GeneratorAlreadyExistsException.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/ICommentService.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/ICommentService.java similarity index 94% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/ICommentService.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/ICommentService.java index 23f931f1a9..4b3c31780b 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/ICommentService.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/ICommentService.java @@ -16,8 +16,8 @@ import java.util.List; +import org.eclipse.vorto.repository.api.ModelId; import org.eclipse.vorto.repository.model.Comment; -import org.eclipse.vorto.repository.model.ModelId; /** * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/IGeneratorService.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/IGeneratorService.java similarity index 84% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/IGeneratorService.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/IGeneratorService.java index a9b574b84c..bb5d449de9 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/IGeneratorService.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/IGeneratorService.java @@ -18,10 +18,11 @@ import java.util.Map; import java.util.Set; -import org.eclipse.vorto.repository.model.GeneratedOutput; -import org.eclipse.vorto.repository.model.GeneratorServiceInfo; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ServiceClassifier; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.exception.GenerationException; +import org.eclipse.vorto.repository.api.generation.GeneratedOutput; +import org.eclipse.vorto.repository.api.generation.GeneratorInfo; +import org.eclipse.vorto.repository.api.generation.ServiceClassifier; /** * This service is a facade service to communicate to all registered Vorto Generators @@ -58,14 +59,14 @@ public interface IGeneratorService { * @param serviceKey * @return */ - GeneratorServiceInfo getGeneratorServiceInfo(String serviceKey); + GeneratorInfo getGeneratorServiceInfo(String serviceKey); /** * Returns the mostly used generators * @param top the upper limit of results, e.g. top 3 or top 10 * @return */ - Collection getMostlyUsedGenerators(int top); + Collection getMostlyUsedGenerators(int top); /** * Invokes a code generator for a information model Id diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/resolver/IModelIdResolver.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/IModelIdResolver.java similarity index 78% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/resolver/IModelIdResolver.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/IModelIdResolver.java index 45c3591a1c..e2f22ed017 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/resolver/IModelIdResolver.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/IModelIdResolver.java @@ -12,16 +12,16 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log */ -package org.eclipse.vorto.repository.resolver; +package org.eclipse.vorto.repository.service; -import org.eclipse.vorto.repository.model.ModelId; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.resolver.ResolveQuery; public interface IModelIdResolver { /** * Tries to resolve the given platform specific id to {@link ModelId} - * @param id * @return resolved model id or null */ - ModelId resolve(String id); + ModelId resolve(ResolveQuery query); } diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/IModelRepository.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/IModelRepository.java similarity index 84% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/IModelRepository.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/IModelRepository.java index b3156d3a48..53ec764c4e 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/IModelRepository.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/IModelRepository.java @@ -16,10 +16,11 @@ import java.util.List; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; +import org.eclipse.vorto.repository.api.exception.ModelNotFoundException; +import org.eclipse.vorto.repository.api.upload.UploadModelResult; import org.eclipse.vorto.repository.model.IModelContent; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ModelResource; -import org.eclipse.vorto.repository.model.UploadModelResult; /** * @@ -33,14 +34,14 @@ public interface IModelRepository { * @param queryExpression * @return */ - List search(String queryExpression); + List search(String queryExpression); /** * Gets a model resource for the given model id * @param modelId * @return */ - ModelResource getById(ModelId modelId); + ModelInfo getById(ModelId modelId); /** * Returns the actual model content for the given model id @@ -92,7 +93,7 @@ public interface IModelRepository { * @param targetPlatform * @return */ - List getMappingModelsForTargetPlatform(ModelId modelId, String targetPlatform); + List getMappingModelsForTargetPlatform(ModelId modelId, String targetPlatform); public enum ContentType { XMI,DSL diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/IRegistrationService.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/IRegistrationService.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/IRegistrationService.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/IRegistrationService.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/IRepositoryManager.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/IRepositoryManager.java similarity index 95% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/IRepositoryManager.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/IRepositoryManager.java index a69ae902d6..842343cba2 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/IRepositoryManager.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/IRepositoryManager.java @@ -15,7 +15,7 @@ package org.eclipse.vorto.repository.service; -import org.eclipse.vorto.repository.model.ModelId; +import org.eclipse.vorto.repository.api.ModelId; public interface IRepositoryManager { diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/IUserRepository.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/IUserRepository.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/IUserRepository.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/IUserRepository.java diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/ModelReferentialIntegrityException.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/ModelReferentialIntegrityException.java similarity index 95% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/ModelReferentialIntegrityException.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/ModelReferentialIntegrityException.java index a13fa93413..0412261ac5 100644 --- a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/ModelReferentialIntegrityException.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/ModelReferentialIntegrityException.java @@ -17,7 +17,7 @@ import java.util.ArrayList; import java.util.List; -import org.eclipse.vorto.repository.model.ModelId; +import org.eclipse.vorto.repository.api.ModelId; /** * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd. diff --git a/server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/ModelRepositoryException.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/ModelRepositoryException.java similarity index 100% rename from server/repo/repo-core/src/main/java/org/eclipse/vorto/repository/service/ModelRepositoryException.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/service/ModelRepositoryException.java diff --git a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/AbstractRepositoryController.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/AbstractRepositoryController.java similarity index 89% rename from server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/AbstractRepositoryController.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/AbstractRepositoryController.java index 44d4dc9caa..9cf9e0deea 100644 --- a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/AbstractRepositoryController.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/AbstractRepositoryController.java @@ -14,8 +14,8 @@ */ package org.eclipse.vorto.repository.web; -import org.eclipse.vorto.repository.service.GenerationException; -import org.eclipse.vorto.repository.service.ModelNotFoundException; +import org.eclipse.vorto.repository.api.exception.GenerationException; +import org.eclipse.vorto.repository.api.exception.ModelNotFoundException; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/AdminController.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/AdminController.java similarity index 97% rename from server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/AdminController.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/AdminController.java index 5b574c5862..12c3c95b03 100644 --- a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/AdminController.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/AdminController.java @@ -23,8 +23,7 @@ import javax.servlet.http.HttpServletResponse; import org.apache.commons.io.IOUtils; -import org.eclipse.vorto.http.model.ModelIdDto; -import org.eclipse.vorto.repository.model.ModelId; +import org.eclipse.vorto.repository.api.ModelId; import org.eclipse.vorto.repository.service.IRepositoryManager; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.annotation.Secured; diff --git a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/AngularCsrfHeaderFilter.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/AngularCsrfHeaderFilter.java similarity index 100% rename from server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/AngularCsrfHeaderFilter.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/AngularCsrfHeaderFilter.java diff --git a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/HomeController.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/HomeController.java similarity index 100% rename from server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/HomeController.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/HomeController.java diff --git a/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/ModelDtoFactory.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/ModelDtoFactory.java new file mode 100644 index 0000000000..ecd7e95224 --- /dev/null +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/ModelDtoFactory.java @@ -0,0 +1,293 @@ +/** + * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v1.0 which accompany this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * The Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Bosch Software Innovations GmbH - Please refer to git log + */ +package org.eclipse.vorto.repository.web; + +import java.util.List; +import java.util.stream.Collectors; + +import org.eclipse.vorto.core.api.model.datatype.BooleanPropertyAttribute; +import org.eclipse.vorto.core.api.model.datatype.Entity; +import org.eclipse.vorto.core.api.model.datatype.Enum; +import org.eclipse.vorto.core.api.model.datatype.EnumLiteralPropertyAttribute; +import org.eclipse.vorto.core.api.model.datatype.ObjectPropertyType; +import org.eclipse.vorto.core.api.model.datatype.PrimitivePropertyType; +import org.eclipse.vorto.core.api.model.datatype.PrimitiveType; +import org.eclipse.vorto.core.api.model.datatype.Property; +import org.eclipse.vorto.core.api.model.datatype.PropertyAttribute; +import org.eclipse.vorto.core.api.model.functionblock.Event; +import org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel; +import org.eclipse.vorto.core.api.model.functionblock.PrimitiveParam; +import org.eclipse.vorto.core.api.model.functionblock.RefParam; +import org.eclipse.vorto.core.api.model.functionblock.ReturnObjectType; +import org.eclipse.vorto.core.api.model.functionblock.ReturnPrimitiveType; +import org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty; +import org.eclipse.vorto.core.api.model.informationmodel.InformationModel; +import org.eclipse.vorto.core.api.model.mapping.MappingModel; +import org.eclipse.vorto.core.api.model.model.Model; +import org.eclipse.vorto.core.api.model.model.ModelReference; +import org.eclipse.vorto.repository.api.AbstractModel; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; +import org.eclipse.vorto.repository.api.ModelType; +import org.eclipse.vorto.repository.api.content.BooleanAttributeProperty; +import org.eclipse.vorto.repository.api.content.BooleanAttributePropertyType; +import org.eclipse.vorto.repository.api.content.Constraint; +import org.eclipse.vorto.repository.api.content.ConstraintType; +import org.eclipse.vorto.repository.api.content.EntityModel; +import org.eclipse.vorto.repository.api.content.EnumAttributeProperty; +import org.eclipse.vorto.repository.api.content.EnumAttributePropertyType; +import org.eclipse.vorto.repository.api.content.EnumLiteral; +import org.eclipse.vorto.repository.api.content.EnumModel; +import org.eclipse.vorto.repository.api.content.IPropertyAttribute; +import org.eclipse.vorto.repository.api.content.Infomodel; +import org.eclipse.vorto.repository.api.content.ModelEvent; +import org.eclipse.vorto.repository.api.content.ModelProperty; +import org.eclipse.vorto.repository.api.content.Operation; +import org.eclipse.vorto.repository.api.content.Param; +import org.eclipse.vorto.repository.api.content.ReturnType; + +/** + * Converts the EMF Model to POJO's + * + */ +public class ModelDtoFactory { + + public static ModelInfo createDto(ModelInfo resource) { + ModelInfo dto = new ModelInfo(createDto(resource.getId()), ModelType.valueOf(resource.getType().name())); + dto.setAuthor(resource.getAuthor()); + dto.setCreationDate(resource.getCreationDate()); + dto.setDescription(resource.getDescription()); + dto.setDisplayName(resource.getDisplayName()); + dto.setHasImage(resource.isHasImage()); + dto.setReferencedBy(resource.getReferencedBy().stream().map(r -> createDto(r)).collect(Collectors.toList())); + dto.setReferences(resource.getReferences().stream().map(r -> createDto(r)).collect(Collectors.toList())); + dto.setSupportedTargetPlatforms(resource.getSupportedTargetPlatforms()); + return dto; + } + + public static ModelId createDto(ModelId modelId) { + return new ModelId(modelId.getName(), modelId.getNamespace(), modelId.getVersion()); + } + + public static AbstractModel createResource(Model model) { + if (model instanceof InformationModel) { + return createResource((InformationModel) model); + } else if (model instanceof FunctionblockModel) { + return createResource((FunctionblockModel) model); + } else if (model instanceof Entity) { + return createResource((Entity) model); + } else if (model instanceof Enum) { + return createResource((Enum) model); + } else if (model instanceof MappingModel) { + return new ModelInfo(new ModelId(model.getName(), model.getNamespace(), model.getVersion()), + ModelType.Mapping); + } else { + throw new UnsupportedOperationException(); + } + } + + public static Infomodel createResource(InformationModel model) { + Infomodel infoResource = new Infomodel(new ModelId(model.getName(), model.getNamespace(), model.getVersion()), + ModelType.InformationModel); + + for (FunctionblockProperty property : model.getProperties()) { + infoResource.getFunctionblocks().add(createProperty(property)); + } + + infoResource.setDescription(model.getDescription()); + infoResource.setDisplayName(model.getDisplayname()); + infoResource.setReferences( + model.getReferences().stream().map(reference -> createModelId(reference)).collect(Collectors.toList())); + + return infoResource; + } + + private static ModelId createModelId(Model model) { + return new ModelId(model.getName(), model.getNamespace(), model.getVersion()); + } + + private static ModelId createModelId(ModelReference reference) { + ModelId modelId = ModelId.fromReference(reference.getImportedNamespace(), reference.getVersion()); + return new ModelId(modelId.getName(), modelId.getNamespace(), modelId.getVersion()); + } + + public static org.eclipse.vorto.repository.api.content.FunctionblockModel createResource(FunctionblockModel model) { + org.eclipse.vorto.repository.api.content.FunctionblockModel resource = new org.eclipse.vorto.repository.api.content.FunctionblockModel( + new ModelId(model.getName(), model.getNamespace(), model.getVersion()), ModelType.Functionblock); + resource.setDescription(model.getDescription()); + resource.setDisplayName(model.getDisplayname()); + resource.setReferences( + model.getReferences().stream().map(reference -> createModelId(reference)).collect(Collectors.toList())); + + if (model.getFunctionblock().getConfiguration() != null) { + resource.setConfigurationProperties(model.getFunctionblock().getConfiguration().getProperties().stream() + .map(p -> createProperty(p)).collect(Collectors.toList())); + } + if (model.getFunctionblock().getStatus() != null) { + resource.setStatusProperties(model.getFunctionblock().getStatus().getProperties().stream() + .map(p -> createProperty(p)).collect(Collectors.toList())); + } + + if (model.getFunctionblock().getFault() != null) { + resource.setFaultProperties(model.getFunctionblock().getFault().getProperties().stream() + .map(p -> createProperty(p)).collect(Collectors.toList())); + } + + if (model.getFunctionblock().getEvents() != null) { + resource.setEvents(model.getFunctionblock().getEvents().stream().map(e -> createEvent(e)) + .collect(Collectors.toList())); + } + + if (model.getFunctionblock().getOperations() != null) { + resource.setOperations(model.getFunctionblock().getOperations().stream().map(o -> createOperation(o)) + .collect(Collectors.toList())); + } + + return resource; + } + + 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; + } + + 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 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; + } + + private static ModelProperty createProperty(FunctionblockProperty property) { + ModelProperty p = new ModelProperty(); + p.setDescription(property.getDescription()); + p.setName(property.getName()); + p.setType(createModelId(property.getType())); + return p; + } + + private static ModelProperty createProperty(Property property) { + 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 constraints = property.getConstraintRule().getConstraints().stream() + .map(c -> createConstraint(c)).collect(Collectors.toList()); + p.setConstraints(constraints); + } + + if (property.getPropertyAttributes() != null) { + List attributes = property.getPropertyAttributes().stream().map(a -> createAttribute(a)) + .collect(Collectors.toList()); + p.setAttributes(attributes); + } + return p; + } + + private static IPropertyAttribute createAttribute(PropertyAttribute attribute) { + if (attribute instanceof BooleanPropertyAttribute) { + BooleanPropertyAttribute booleanAttribute = (BooleanPropertyAttribute) attribute; + return new BooleanAttributeProperty( + BooleanAttributePropertyType.valueOf(booleanAttribute.getType().name()), + booleanAttribute.isValue()); + } else if (attribute instanceof EnumLiteralPropertyAttribute) { + EnumLiteralPropertyAttribute enumAttribute = (EnumLiteralPropertyAttribute) attribute; + return new EnumAttributeProperty(EnumAttributePropertyType.valueOf(enumAttribute.getType().name()), + createLiteral(enumAttribute.getValue())); + } else { + throw new UnsupportedOperationException("Property Attribute cannot be mapped"); + } + } + + private static Constraint createConstraint(org.eclipse.vorto.core.api.model.datatype.Constraint c) { + return new Constraint(ConstraintType.valueOf(c.getType().name()), c.getConstraintValues()); + } + + private static ModelEvent createEvent(Event event) { + ModelEvent modelEvent = new ModelEvent(); + modelEvent.setName(event.getName()); + modelEvent + .setProperties(event.getProperties().stream().map(p -> createProperty(p)).collect(Collectors.toList())); + return modelEvent; + } + + public static EntityModel createResource(Entity model) { + EntityModel resource = new EntityModel(new ModelId(model.getName(), model.getNamespace(), model.getVersion()), + ModelType.Datatype); + resource.setDescription(model.getDescription()); + resource.setDisplayName(model.getDisplayname()); + resource.setReferences( + model.getReferences().stream().map(reference -> createModelId(reference)).collect(Collectors.toList())); + resource.setProperties(model.getProperties().stream().map(p -> createProperty(p)).collect(Collectors.toList())); + return resource; + } + + public static EnumModel createResource(Enum model) { + EnumModel resource = new EnumModel(new ModelId(model.getName(), model.getNamespace(), model.getVersion()), + ModelType.Datatype); + resource.setDescription(model.getDescription()); + resource.setDisplayName(model.getDisplayname()); + resource.setReferences( + model.getReferences().stream().map(reference -> createModelId(reference)).collect(Collectors.toList())); + resource.setLiterals(model.getEnums().stream().map(p -> createLiteral(p)).collect(Collectors.toList())); + return resource; + } + + private static EnumLiteral createLiteral(org.eclipse.vorto.core.api.model.datatype.EnumLiteral literal) { + return new EnumLiteral(literal.getName(), literal.getDescription()); + } +} diff --git a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ModelGenerationController.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/ModelGenerationController.java similarity index 92% rename from server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ModelGenerationController.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/ModelGenerationController.java index e5a192112d..2cc3353b07 100644 --- a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ModelGenerationController.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/ModelGenerationController.java @@ -28,10 +28,10 @@ import javax.servlet.http.HttpServletResponse; import org.apache.commons.io.IOUtils; -import org.eclipse.vorto.repository.model.GeneratedOutput; -import org.eclipse.vorto.repository.model.GeneratorServiceInfo; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ServiceClassifier; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.generation.GeneratedOutput; +import org.eclipse.vorto.repository.api.generation.GeneratorInfo; +import org.eclipse.vorto.repository.api.generation.ServiceClassifier; import org.eclipse.vorto.repository.service.IGeneratorService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -98,10 +98,10 @@ public void generate( @ApiParam(value = "The namespace of vorto model, e.g. com @ApiOperation(value = "Returns all currently registered Code Generator") @RequestMapping(value = "/{classifier}", method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) - public Collection getRegisteredGeneratorServices( + public Collection getRegisteredGeneratorServices( @ApiParam(value = "Choose type of generator", allowableValues="platform,documentation", required = true) @PathVariable String classifier, @ApiParam(value = "Prioritize results with given tag", allowableValues="any given tags", required = false) @RequestParam(value = "orderBy", required=false, defaultValue="production") String orderBy) { - List generatorInfoResult = new ArrayList<>(); + List generatorInfoResult = new ArrayList<>(); for (String serviceKey : this.generatorService.getRegisteredGeneratorServiceKeys(ServiceClassifier.valueOf(classifier))) { try { @@ -140,7 +140,7 @@ private boolean contains(String[] tags, String tag) { @ApiOperation(value = "Returns the rank of code generators by usage") @RequestMapping(value = "/topused/{top}", method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) - public Collection getMostlyUsedGenerators(@ApiParam(value = "The upper limit number of top code generator list", required = true) final @PathVariable int top) { + public Collection getMostlyUsedGenerators(@ApiParam(value = "The upper limit number of top code generator list", required = true) final @PathVariable int top) { return this.generatorService.getMostlyUsedGenerators(top); } diff --git a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ModelRepositoryController.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/ModelRepositoryController.java similarity index 88% rename from server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ModelRepositoryController.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/ModelRepositoryController.java index 96ccc00be5..8c4b4aa21b 100644 --- a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ModelRepositoryController.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/ModelRepositoryController.java @@ -27,13 +27,12 @@ import org.apache.commons.io.IOUtils; import org.apache.log4j.Logger; -import org.eclipse.vorto.http.model.AbstractModelDto; -import org.eclipse.vorto.http.model.ModelResourceDto; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ModelResource; +import org.eclipse.vorto.repository.api.AbstractModel; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; +import org.eclipse.vorto.repository.api.exception.ModelNotFoundException; import org.eclipse.vorto.repository.service.IModelRepository; import org.eclipse.vorto.repository.service.IModelRepository.ContentType; -import org.eclipse.vorto.repository.service.ModelNotFoundException; import org.eclipse.vorto.server.commons.ModelZipFileExtractor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; @@ -69,8 +68,8 @@ public class ModelRepositoryController extends AbstractRepositoryController { @ApiOperation(value = "Find a model by a free-text search expression") @RequestMapping(value = "/query={expression:.*}", method = RequestMethod.GET) - public List searchByExpression(@ApiParam(value = "a free-text search expression", required = true) @PathVariable String expression) { - List modelResources = modelRepository.search(expression); + public List searchByExpression(@ApiParam(value = "a free-text search expression", required = true) @PathVariable String expression) { + List modelResources = modelRepository.search(expression); logger.info("searchByExpression: [" + expression + "] Rows returned: " + modelResources.size()); return modelResources.stream().map(resource -> ModelDtoFactory.createDto(resource)).collect(Collectors.toList()); } @@ -78,7 +77,7 @@ public List searchByExpression(@ApiParam(value = "a free-text @ApiOperation(value = "Returns a model by its full qualified model ID") @ApiResponses(value = { @ApiResponse(code = 400, message = "Wrong input"), @ApiResponse(code = 404, message = "Model not found")}) @RequestMapping(value = "/{namespace}/{name}/{version:.+}", method = RequestMethod.GET) - public ModelResourceDto getModelResource( @ApiParam(value = "The namespace of vorto model, e.g. com.mycompany", required = true) final @PathVariable String namespace, + public ModelInfo getModelResource( @ApiParam(value = "The namespace of vorto model, e.g. com.mycompany", required = true) final @PathVariable String namespace, @ApiParam(value = "The name of vorto model, e.g. NewInfomodel", required = true) final @PathVariable String name, @ApiParam(value = "The version of vorto model, e.g. 1.0.0", required = true) final @PathVariable String version) { Objects.requireNonNull(namespace, "namespace must not be null"); @@ -86,8 +85,8 @@ public ModelResourceDto getModelResource( @ApiParam(value = "The namespace of vo Objects.requireNonNull(version, "version must not be null"); final ModelId modelId = new ModelId(name, namespace, version); - logger.info("getModelResource: [" + modelId.toString() + "] - Fullpath: [" + modelId.getFullPath() + "]"); - ModelResource resource = modelRepository.getById(modelId); + logger.info("getModelResource: [" + modelId.toString() + "]"); + ModelInfo resource = modelRepository.getById(modelId); if (resource == null) { throw new ModelNotFoundException("Model does not exist", null); } @@ -97,7 +96,7 @@ public ModelResourceDto getModelResource( @ApiParam(value = "The namespace of vo @ApiOperation(value = "Returns the model content") @ApiResponses(value = { @ApiResponse(code = 400, message = "Wrong input"), @ApiResponse(code = 404, message = "Model not found")}) @RequestMapping(value = "/content/{namespace}/{name}/{version:.+}", method = RequestMethod.GET) - public AbstractModelDto getModelContent(@ApiParam(value = "The namespace of vorto model, e.g. com.mycompany", required = true) final @PathVariable String namespace, + public AbstractModel getModelContent(@ApiParam(value = "The namespace of vorto model, e.g. com.mycompany", required = true) final @PathVariable String namespace, @ApiParam(value = "The name of vorto model, e.g. NewInfomodel", required = true) final @PathVariable String name, @ApiParam(value = "The version of vorto model, e.g. 1.0.0", required = true) final @PathVariable String version) { @@ -160,7 +159,7 @@ public void downloadModelById( @ApiParam(value = "The namespace of vorto model, final ModelId modelId = new ModelId(name, namespace, version); - logger.info("downloadModelById: [" + modelId.toString() + "] - Fullpath: [" + modelId.getFullPath() + "]"); + logger.info("downloadModelById: [" + modelId.toString() + "]"); final ContentType contentType = outputType; @@ -200,7 +199,7 @@ private byte[] createZipWithAllDependencies(ModelId modelId, ContentType content private void createSingleModelContent(ModelId modelId, ContentType contentType, HttpServletResponse response) { byte[] modelContent = modelRepository.getModelContent(modelId, contentType).getContent(); if (modelContent != null && modelContent.length > 0) { - final ModelResource modelResource = modelRepository.getById(modelId); + final ModelInfo modelResource = modelRepository.getById(modelId); response.setHeader(CONTENT_DISPOSITION, ATTACHMENT_FILENAME + getFileName(modelResource, contentType)); response.setContentType(APPLICATION_OCTET_STREAM); try { @@ -216,7 +215,7 @@ private void createSingleModelContent(ModelId modelId, ContentType contentType, private void addModelToZip(ZipOutputStream zipOutputStream, ModelId modelId, ContentType contentType) throws Exception { byte[] modelContent = modelRepository.getModelContent(modelId,contentType).getContent(); - ModelResource modelResource = modelRepository.getById(modelId); + ModelInfo modelResource = modelRepository.getById(modelId); try { ZipEntry zipEntry = new ZipEntry(getFileName(modelResource, contentType)); @@ -232,11 +231,11 @@ private void addModelToZip(ZipOutputStream zipOutputStream, ModelId modelId, Con } } - private String getFileName(ModelResource modelResource, ContentType contentType) { + private String getFileName(ModelInfo modelResource, ContentType contentType) { if (contentType == ContentType.XMI) { return modelResource.getId().getName() + XMI; } else { - return modelResource.getId().getName() + modelResource.getModelType().getExtension(); + return modelResource.getId().getName() + modelResource.getType().getExtension(); } } @@ -252,7 +251,7 @@ public void getMappingResources( @ApiParam(value = "The namespace of vorto mode final ModelId modelId = new ModelId(name, namespace, version); - List mappingResources = modelRepository.getMappingModelsForTargetPlatform(modelId, targetPlatform); + List mappingResources = modelRepository.getMappingModelsForTargetPlatform(modelId, targetPlatform); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ZipOutputStream zos = new ZipOutputStream(baos); @@ -260,7 +259,7 @@ public void getMappingResources( @ApiParam(value = "The namespace of vorto mode final ContentType contentType = ContentType.DSL; try { - for (ModelResource mappingResource : mappingResources) { + for (ModelInfo mappingResource : mappingResources) { addModelToZip(zos, mappingResource.getId(), contentType); } diff --git a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ModelResolveController.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/ModelResolveController.java similarity index 68% rename from server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ModelResolveController.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/ModelResolveController.java index bab3f038d2..692216771f 100644 --- a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ModelResolveController.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/ModelResolveController.java @@ -14,12 +14,11 @@ */ package org.eclipse.vorto.repository.web; -import org.eclipse.vorto.http.model.ModelIdDto; -import org.eclipse.vorto.repository.internal.resolver.ModelIdResolverFactory; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.exception.ModelNotFoundException; +import org.eclipse.vorto.repository.api.resolver.ResolveQuery; import org.eclipse.vorto.repository.internal.resolver.UnknownModelIdResolverException; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.resolver.IModelIdResolver; -import org.eclipse.vorto.repository.service.ModelNotFoundException; +import org.eclipse.vorto.repository.service.IModelIdResolver; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ExceptionHandler; @@ -41,15 +40,18 @@ public class ModelResolveController { @Autowired - private ModelIdResolverFactory resolverFactory; + private IModelIdResolver resolver; @ApiOperation(value = "Resolves a vorto model by a platform specific object identifier, defined in model mappings") @ApiResponses(value = { @ApiResponse(code = 404, message = "Resolver not found for specified generator service key")}) - @RequestMapping(value = "/{serviceKey}/{id}", method = RequestMethod.GET) - public ModelIdDto resolve(@ApiParam(value = "Generator service key, e.g. LWM2M", required = true) @PathVariable("serviceKey") final String serviceKey, @ApiParam(value = "Platform specific id defined in mappings", required = true) @PathVariable("id") final String id) throws Exception{ - IModelIdResolver resolver = resolverFactory.getResolver(serviceKey); + @RequestMapping(value = "/{serviceKey}/{stereoType}/{attributeId}/{attributeValue}", method = RequestMethod.GET) + public ModelId resolve(@ApiParam(value = "Generator service key, e.g. LWM2M", required = true) @PathVariable("serviceKey") final String serviceKey, + @ApiParam(value = "Platform specific stereotype name defined in mappings", required = true) @PathVariable("stereoType") final String stereoType, + @ApiParam(value = "Platform specific attributeId defined in mappings", required = true) @PathVariable("attributeId") final String attributeId, + @ApiParam(value = "Platform specific attributeValue defined in mappings", required = true) @PathVariable("attributeValue") final String attributeValue) throws Exception{ + - ModelId resolvedId = resolver.resolve(id); + ModelId resolvedId = resolver.resolve(new ResolveQuery(serviceKey,attributeId, attributeValue,stereoType)); if (resolvedId != null) { return ModelDtoFactory.createDto(resolvedId); diff --git a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ShareModelController.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/ShareModelController.java similarity index 72% rename from server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ShareModelController.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/ShareModelController.java index c08ee8c9f5..d397c55bce 100644 --- a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ShareModelController.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/ShareModelController.java @@ -18,11 +18,11 @@ import java.text.MessageFormat; import java.util.List; -import org.eclipse.vorto.http.model.ServerResponseDto; +import org.eclipse.vorto.repository.api.upload.ModelHandle; +import org.eclipse.vorto.repository.api.upload.ServerResponse; +import org.eclipse.vorto.repository.api.upload.UploadModelResult; import org.eclipse.vorto.repository.internal.service.ITemporaryStorage; import org.eclipse.vorto.repository.internal.service.utils.BulkUploadHelper; -import org.eclipse.vorto.repository.model.ModelHandle; -import org.eclipse.vorto.repository.model.UploadModelResult; import org.eclipse.vorto.repository.service.IModelRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -67,34 +67,34 @@ public class ShareModelController { @ApiOperation(value = "Upload and validate a single vorto model") @RequestMapping(method = RequestMethod.POST) - public ResponseEntity uploadModel(@ApiParam(value = "The vorto model file to upload", required = true) @RequestParam("file") MultipartFile file) { + public ResponseEntity uploadModel(@ApiParam(value = "The vorto model file to upload", required = true) @RequestParam("file") MultipartFile file) { LOGGER.info("uploadModel: [" + file.getOriginalFilename() + "]"); try { uploadModelResult = modelRepository.upload(file.getBytes(), file.getOriginalFilename()); List uploadModelResults = Lists.newArrayList(); uploadModelResults.add(uploadModelResult); String message = "Uploaded model " + file.getOriginalFilename() + (uploadModelResult.isValid() ? " is valid to check in." : " has errors. Cannot check in.") ; - return validResponse(new ServerResponseDto(message,true, uploadModelResults)); + return validResponse(new ServerResponse(message,true, uploadModelResults)); } catch (IOException e) { LOGGER.error("Error upload model." + e.getStackTrace()); - ServerResponseDto errorResponse = new ServerResponseDto("Error during upload. Try again. " + e.getMessage(), + ServerResponse errorResponse = new ServerResponse("Error during upload. Try again. " + e.getMessage(), false, null); - return new ResponseEntity(errorResponse, HttpStatus.INTERNAL_SERVER_ERROR); + return new ResponseEntity(errorResponse, HttpStatus.INTERNAL_SERVER_ERROR); } } @ApiOperation(value = "Upload and validate multiple vorto models") @RequestMapping(value = "multiple", method = RequestMethod.POST) - public ResponseEntity uploadMultipleModels(@ApiParam(value = "The vorto model files to upload", required = true) @RequestParam("file") MultipartFile file) { + public ResponseEntity uploadMultipleModels(@ApiParam(value = "The vorto model files to upload", required = true) @RequestParam("file") MultipartFile file) { LOGGER.info("Bulk upload Models: [" + file.getOriginalFilename() + "]"); try { BulkUploadHelper bulkUploadService = new BulkUploadHelper(this.modelRepository,uploadStorage); List uploadModelResults = bulkUploadService.uploadMultiple(file.getBytes(),file.getOriginalFilename()); LOGGER.info("Models Uploaded: [" + uploadModelResults.size() + "]"); - ServerResponseDto serverResponse = (uploadModelResults.size() == 0) - ? new ServerResponseDto("Uploaded file doesn't have any valid models.", false, uploadModelResults) - : new ServerResponseDto(constructUserResponseMessage(uploadModelResults), true, uploadModelResults); + ServerResponse serverResponse = (uploadModelResults.size() == 0) + ? new ServerResponse("Uploaded file doesn't have any valid models.", false, uploadModelResults) + : new ServerResponse(constructUserResponseMessage(uploadModelResults), true, uploadModelResults); return validResponse(serverResponse); } catch (Exception e) { LOGGER.error("Error bulk upload models.",e); @@ -104,11 +104,11 @@ public ResponseEntity uploadMultipleModels(@ApiParam(value = @ApiOperation(value = "Checkin an uploaded vorto model into the repository") @RequestMapping(value = "/{handleId:.+}", method = RequestMethod.PUT) - public ResponseEntity checkin(@ApiParam(value = "The file name of uploaded vorto model", required = true) final @PathVariable String handleId) { + public ResponseEntity checkin(@ApiParam(value = "The file name of uploaded vorto model", required = true) final @PathVariable String handleId) { LOGGER.info("Check in Model " + handleId); try { modelRepository.checkin(handleId, SecurityContextHolder.getContext().getAuthentication().getName()); - ServerResponseDto successModelResponse = new ServerResponseDto("Model has been checkin successfully.",true, null); + ServerResponse successModelResponse = new ServerResponse("Model has been checkin successfully.",true, null); return validResponse(successModelResponse); } catch (Exception e) { LOGGER.error("Error checkin model. " + handleId, e); @@ -118,13 +118,13 @@ public ResponseEntity checkin(@ApiParam(value = "The file nam @ApiOperation(value = "Checkin multiple uploaded vorto models into the repository") @RequestMapping(value = "/checkInMultiple", method = RequestMethod.PUT) - public ResponseEntity checkInMultiple(@ApiParam(value = "The file name of uploaded vorto model", required=true) final @RequestBody ModelHandle[] modelHandles) { + public ResponseEntity checkInMultiple(@ApiParam(value = "The file name of uploaded vorto model", required=true) final @RequestBody ModelHandle[] modelHandles) { LOGGER.info("Bulk check in models."); try { for (ModelHandle handle : modelHandles) { modelRepository.checkin(handle.getHandleId(), SecurityContextHolder.getContext().getAuthentication().getName()); } - ServerResponseDto successModelResponse = new ServerResponseDto("All the models has been checked in Successfully.",true, null); + ServerResponse successModelResponse = new ServerResponse("All the models has been checked in Successfully.",true, null); return validResponse(successModelResponse); } catch (Exception e) { LOGGER.error("Error bulk checkin models.", e); @@ -132,14 +132,14 @@ public ResponseEntity checkInMultiple(@ApiParam(value = "The } } - private ResponseEntity validResponse(ServerResponseDto successModelResponse) { - return new ResponseEntity(successModelResponse, HttpStatus.OK); + private ResponseEntity validResponse(ServerResponse successModelResponse) { + return new ResponseEntity(successModelResponse, HttpStatus.OK); } - private ResponseEntity erroredResponse(String errorMessage) { - ServerResponseDto errorResponse = new ServerResponseDto("Error during checkin. Try again. " + errorMessage, + private ResponseEntity erroredResponse(String errorMessage) { + ServerResponse errorResponse = new ServerResponse("Error during checkin. Try again. " + errorMessage, false, null); - return new ResponseEntity(errorResponse, HttpStatus.INTERNAL_SERVER_ERROR); + return new ResponseEntity(errorResponse, HttpStatus.INTERNAL_SERVER_ERROR); } private String constructUserResponseMessage(List uploadModelResults) { diff --git a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/SwaggerController.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/SwaggerController.java similarity index 100% rename from server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/SwaggerController.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/SwaggerController.java diff --git a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/comment/CommentController.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/comment/CommentController.java similarity index 98% rename from server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/comment/CommentController.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/comment/CommentController.java index 985d9cee57..45b95b3aef 100644 --- a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/comment/CommentController.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/comment/CommentController.java @@ -18,8 +18,8 @@ import javax.validation.Valid; +import org.eclipse.vorto.repository.api.ModelId; import org.eclipse.vorto.repository.model.Comment; -import org.eclipse.vorto.repository.model.ModelId; import org.eclipse.vorto.repository.service.ICommentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; diff --git a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/config/CloudConfiguration.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/config/RepositoryConfiguration.java similarity index 68% rename from server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/config/CloudConfiguration.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/config/RepositoryConfiguration.java index 9c8f7dc257..20fc1b905c 100644 --- a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/config/CloudConfiguration.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/config/RepositoryConfiguration.java @@ -14,18 +14,18 @@ */ package org.eclipse.vorto.repository.web.config; -import org.modeshape.jcr.RepositoryConfiguration; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; import org.springframework.core.io.ClassPathResource; @Configuration -@Profile("cloud") -public class CloudConfiguration { +public class RepositoryConfiguration { + @Value("${repo.configFile}") + private String repositoryConfigFile = null; @Bean - public RepositoryConfiguration repoConfiguration() throws Exception { - return RepositoryConfiguration.read(new ClassPathResource("vorto-repository-config-h2.json").getURL()); + public org.modeshape.jcr.RepositoryConfiguration repoConfiguration() throws Exception { + return org.modeshape.jcr.RepositoryConfiguration.read(new ClassPathResource(repositoryConfigFile).getURL()); } } diff --git a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/config/LocalConfiguration.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/config/RepositoryConfigurationLocal.java similarity index 81% rename from server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/config/LocalConfiguration.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/config/RepositoryConfigurationLocal.java index 1e943e8f33..b0caa56b52 100644 --- a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/config/LocalConfiguration.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/config/RepositoryConfigurationLocal.java @@ -19,18 +19,15 @@ import org.eclipse.vorto.repository.model.Role; import org.eclipse.vorto.repository.model.User; import org.eclipse.vorto.repository.service.IUserRepository; -import org.modeshape.jcr.RepositoryConfiguration; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; -import org.springframework.core.io.ClassPathResource; import org.springframework.security.crypto.password.PasswordEncoder; @Configuration @Profile("local") -public class LocalConfiguration { - +public class RepositoryConfigurationLocal extends org.eclipse.vorto.repository.web.config.RepositoryConfiguration { + @Autowired private IUserRepository userRepository; @@ -56,9 +53,4 @@ public void setUpTestUser() { userRepository.save(user); } - - @Bean - public RepositoryConfiguration repoConfiguration() throws Exception { - return RepositoryConfiguration.read(new ClassPathResource("vorto-repository-config-file.json").getURL()); - } } diff --git a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/identity/UserController.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/identity/UserController.java similarity index 100% rename from server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/identity/UserController.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/identity/UserController.java diff --git a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/listeners/RESTAuthenticationEntryPoint.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/listeners/RESTAuthenticationEntryPoint.java similarity index 100% rename from server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/listeners/RESTAuthenticationEntryPoint.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/listeners/RESTAuthenticationEntryPoint.java diff --git a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/listeners/RESTAuthenticationFailureHandler.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/listeners/RESTAuthenticationFailureHandler.java similarity index 100% rename from server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/listeners/RESTAuthenticationFailureHandler.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/listeners/RESTAuthenticationFailureHandler.java diff --git a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/listeners/RESTAuthenticationSuccessHandler.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/listeners/RESTAuthenticationSuccessHandler.java similarity index 100% rename from server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/listeners/RESTAuthenticationSuccessHandler.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/listeners/RESTAuthenticationSuccessHandler.java diff --git a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/security/UsersDetailsServiceImpl.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/security/UsersDetailsServiceImpl.java similarity index 100% rename from server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/security/UsersDetailsServiceImpl.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/security/UsersDetailsServiceImpl.java diff --git a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ui/ModelDetailsResolver.java b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/ui/ModelDetailsResolver.java similarity index 73% rename from server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ui/ModelDetailsResolver.java rename to server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/ui/ModelDetailsResolver.java index c2ec648fce..110c806d2b 100644 --- a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ui/ModelDetailsResolver.java +++ b/server/repo/repository-server/src/main/java/org/eclipse/vorto/repository/web/ui/ModelDetailsResolver.java @@ -14,11 +14,11 @@ */ package org.eclipse.vorto.repository.web.ui; -import org.eclipse.vorto.repository.internal.resolver.ModelIdResolverFactory; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.exception.ModelNotFoundException; +import org.eclipse.vorto.repository.api.resolver.ResolveQuery; import org.eclipse.vorto.repository.internal.resolver.UnknownModelIdResolverException; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.resolver.IModelIdResolver; -import org.eclipse.vorto.repository.service.ModelNotFoundException; +import org.eclipse.vorto.repository.service.IModelIdResolver; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; @@ -33,13 +33,15 @@ public class ModelDetailsResolver { @Autowired - private ModelIdResolverFactory resolverFactory; + private IModelIdResolver resolver; - @RequestMapping(value = "/{serviceKey}/{id}", method = RequestMethod.GET) - public String resolve(@PathVariable("serviceKey") final String serviceKey, @PathVariable("id") final String id) throws Exception{ - IModelIdResolver resolver = resolverFactory.getResolver(serviceKey); - - ModelId resolvedId = resolver.resolve(id); + @RequestMapping(value = "/{serviceKey}/{stereotype}/{attributeId}/{attributeValue}", method = RequestMethod.GET) + public String resolve(@PathVariable("serviceKey") final String serviceKey, + @PathVariable("stereotype") final String stereoType, + @PathVariable("attributeId") final String attributeId, + @PathVariable("attributeValue") final String attributeValue) throws Exception{ + ModelId resolvedId = resolver.resolve(new ResolveQuery(serviceKey,attributeId, attributeValue,stereoType)); + if (resolvedId != null) { return "redirect:/#/details/"+resolvedId.getNamespace()+"/"+resolvedId.getName()+"/"+resolvedId.getVersion(); } else { diff --git a/server/repo/repo-ui/src/main/resources/.gitignore b/server/repo/repository-server/src/main/resources/.gitignore similarity index 100% rename from server/repo/repo-ui/src/main/resources/.gitignore rename to server/repo/repository-server/src/main/resources/.gitignore diff --git a/server/repo/repo-ui/src/main/resources/application-eclipse.yml b/server/repo/repository-server/src/main/resources/application-local.yml similarity index 91% rename from server/repo/repo-ui/src/main/resources/application-eclipse.yml rename to server/repo/repository-server/src/main/resources/application-local.yml index b2b09ac575..68b0821eae 100644 --- a/server/repo/repo-ui/src/main/resources/application-eclipse.yml +++ b/server/repo/repository-server/src/main/resources/application-local.yml @@ -1,7 +1,7 @@ server: port: 8080 contextPath: /infomodelrepository - + mail: smtp: host: localhost diff --git a/server/repo/repository-server/src/main/resources/application.properties b/server/repo/repository-server/src/main/resources/application.properties new file mode 100644 index 0000000000..3efc5417d3 --- /dev/null +++ b/server/repo/repository-server/src/main/resources/application.properties @@ -0,0 +1,4 @@ +spring.profiles.active=local +spring.jackson.serialization.write-dates-as-timestamps:false + +repo.configFile: vorto-repository-config-file.json diff --git a/server/repo/repo-core/src/main/resources/emailtemplates/checkin_watch.ftl b/server/repo/repository-server/src/main/resources/emailtemplates/checkin_watch.ftl similarity index 100% rename from server/repo/repo-core/src/main/resources/emailtemplates/checkin_watch.ftl rename to server/repo/repository-server/src/main/resources/emailtemplates/checkin_watch.ftl diff --git a/server/repo/repo-core/src/main/resources/emailtemplates/registration.ftl b/server/repo/repository-server/src/main/resources/emailtemplates/registration.ftl similarity index 100% rename from server/repo/repo-core/src/main/resources/emailtemplates/registration.ftl rename to server/repo/repository-server/src/main/resources/emailtemplates/registration.ftl diff --git a/server/repo/repo-ui/src/main/resources/infinispan-configuration.xml b/server/repo/repository-server/src/main/resources/infinispan-configuration.xml similarity index 100% rename from server/repo/repo-ui/src/main/resources/infinispan-configuration.xml rename to server/repo/repository-server/src/main/resources/infinispan-configuration.xml diff --git a/server/repo/repo-core/src/main/resources/sequencer-model.cnd b/server/repo/repository-server/src/main/resources/sequencer-model.cnd similarity index 100% rename from server/repo/repo-core/src/main/resources/sequencer-model.cnd rename to server/repo/repository-server/src/main/resources/sequencer-model.cnd diff --git a/server/repo/repo-ui/src/main/resources/static/css/comment.css b/server/repo/repository-server/src/main/resources/static/css/comment.css similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/css/comment.css rename to server/repo/repository-server/src/main/resources/static/css/comment.css diff --git a/server/repo/repo-ui/src/main/resources/static/css/dashboard.css b/server/repo/repository-server/src/main/resources/static/css/dashboard.css similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/css/dashboard.css rename to server/repo/repository-server/src/main/resources/static/css/dashboard.css diff --git a/server/repo/repo-ui/src/main/resources/static/css/style.css b/server/repo/repository-server/src/main/resources/static/css/style.css similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/css/style.css rename to server/repo/repository-server/src/main/resources/static/css/style.css diff --git a/server/repo/repo-ui/src/main/resources/static/css/swagger-custom.css b/server/repo/repository-server/src/main/resources/static/css/swagger-custom.css similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/css/swagger-custom.css rename to server/repo/repository-server/src/main/resources/static/css/swagger-custom.css diff --git a/server/repo/repo-ui/src/main/resources/static/images/cli.png b/server/repo/repository-server/src/main/resources/static/images/cli.png similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/images/cli.png rename to server/repo/repository-server/src/main/resources/static/images/cli.png diff --git a/server/repo/repo-ui/src/main/resources/static/images/dt.png b/server/repo/repository-server/src/main/resources/static/images/dt.png similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/images/dt.png rename to server/repo/repository-server/src/main/resources/static/images/dt.png diff --git a/server/repo/repo-ui/src/main/resources/static/images/eclipse.png b/server/repo/repository-server/src/main/resources/static/images/eclipse.png similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/images/eclipse.png rename to server/repo/repository-server/src/main/resources/static/images/eclipse.png diff --git a/server/repo/repo-ui/src/main/resources/static/images/favicon.png b/server/repo/repository-server/src/main/resources/static/images/favicon.png similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/images/favicon.png rename to server/repo/repository-server/src/main/resources/static/images/favicon.png diff --git a/server/repo/repo-ui/src/main/resources/static/images/fb.png b/server/repo/repository-server/src/main/resources/static/images/fb.png similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/images/fb.png rename to server/repo/repository-server/src/main/resources/static/images/fb.png diff --git a/server/repo/repo-ui/src/main/resources/static/images/im.png b/server/repo/repository-server/src/main/resources/static/images/im.png similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/images/im.png rename to server/repo/repository-server/src/main/resources/static/images/im.png diff --git a/server/repo/repo-ui/src/main/resources/static/index.html b/server/repo/repository-server/src/main/resources/static/index.html similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/index.html rename to server/repo/repository-server/src/main/resources/static/index.html diff --git a/server/repo/repo-ui/src/main/resources/static/js/app.js b/server/repo/repository-server/src/main/resources/static/js/app.js similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/js/app.js rename to server/repo/repository-server/src/main/resources/static/js/app.js diff --git a/server/repo/repo-ui/src/main/resources/static/js/controllers.js b/server/repo/repository-server/src/main/resources/static/js/controllers.js similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/js/controllers.js rename to server/repo/repository-server/src/main/resources/static/js/controllers.js diff --git a/server/repo/repo-ui/src/main/resources/static/js/directives.js b/server/repo/repository-server/src/main/resources/static/js/directives.js similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/js/directives.js rename to server/repo/repository-server/src/main/resources/static/js/directives.js diff --git a/server/repo/repo-ui/src/main/resources/static/js/services.js b/server/repo/repository-server/src/main/resources/static/js/services.js similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/js/services.js rename to server/repo/repository-server/src/main/resources/static/js/services.js diff --git a/server/repo/repo-ui/src/main/resources/static/partials/admin-template.html b/server/repo/repository-server/src/main/resources/static/partials/admin-template.html similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/partials/admin-template.html rename to server/repo/repository-server/src/main/resources/static/partials/admin-template.html diff --git a/server/repo/repo-ui/src/main/resources/static/partials/details-template.html b/server/repo/repository-server/src/main/resources/static/partials/details-template.html similarity index 95% rename from server/repo/repo-ui/src/main/resources/static/partials/details-template.html rename to server/repo/repository-server/src/main/resources/static/partials/details-template.html index bea91831dd..e5dd14e47a 100644 --- a/server/repo/repo-ui/src/main/resources/static/partials/details-template.html +++ b/server/repo/repository-server/src/main/resources/static/partials/details-template.html @@ -35,7 +35,7 @@

Admin

{{model.displayName}}

-
+
No Image Yet
@@ -94,14 +94,14 @@

Client Tools

XMI DSL - {{documentationGenerator.name}} + {{documentationGenerator.name}}
-
+
diff --git a/server/repo/repo-ui/src/main/resources/static/partials/generators-template.html b/server/repo/repository-server/src/main/resources/static/partials/generators-template.html similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/partials/generators-template.html rename to server/repo/repository-server/src/main/resources/static/partials/generators-template.html diff --git a/server/repo/repo-ui/src/main/resources/static/partials/login-template.html b/server/repo/repository-server/src/main/resources/static/partials/login-template.html similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/partials/login-template.html rename to server/repo/repository-server/src/main/resources/static/partials/login-template.html diff --git a/server/repo/repo-ui/src/main/resources/static/partials/rest-api-template.html b/server/repo/repository-server/src/main/resources/static/partials/rest-api-template.html similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/partials/rest-api-template.html rename to server/repo/repository-server/src/main/resources/static/partials/rest-api-template.html diff --git a/server/repo/repo-ui/src/main/resources/static/partials/search-template.html b/server/repo/repository-server/src/main/resources/static/partials/search-template.html similarity index 91% rename from server/repo/repo-ui/src/main/resources/static/partials/search-template.html rename to server/repo/repository-server/src/main/resources/static/partials/search-template.html index da24086ffa..d2f9c8e629 100644 --- a/server/repo/repo-ui/src/main/resources/static/partials/search-template.html +++ b/server/repo/repository-server/src/main/resources/static/partials/search-template.html @@ -33,7 +33,7 @@ Search Results: {{models.length}} - Type + Type Name Namespace Version @@ -43,13 +43,13 @@ - + - + - + {{ model.id.name }} diff --git a/server/repo/repo-ui/src/main/resources/static/partials/settings-template.html b/server/repo/repository-server/src/main/resources/static/partials/settings-template.html similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/partials/settings-template.html rename to server/repo/repository-server/src/main/resources/static/partials/settings-template.html diff --git a/server/repo/repo-ui/src/main/resources/static/partials/signup-template.html b/server/repo/repository-server/src/main/resources/static/partials/signup-template.html similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/partials/signup-template.html rename to server/repo/repository-server/src/main/resources/static/partials/signup-template.html diff --git a/server/repo/repo-ui/src/main/resources/static/partials/upload-template.html b/server/repo/repository-server/src/main/resources/static/partials/upload-template.html similarity index 100% rename from server/repo/repo-ui/src/main/resources/static/partials/upload-template.html rename to server/repo/repository-server/src/main/resources/static/partials/upload-template.html diff --git a/server/repo/repo-ui/src/main/resources/vorto-repository-config-file.json b/server/repo/repository-server/src/main/resources/vorto-repository-config-file.json similarity index 100% rename from server/repo/repo-ui/src/main/resources/vorto-repository-config-file.json rename to server/repo/repository-server/src/main/resources/vorto-repository-config-file.json diff --git a/server/repo/repo-ui/src/main/resources/vorto-repository-config-h2.json b/server/repo/repository-server/src/main/resources/vorto-repository-config-h2.json similarity index 100% rename from server/repo/repo-ui/src/main/resources/vorto-repository-config-h2.json rename to server/repo/repository-server/src/main/resources/vorto-repository-config-h2.json diff --git a/server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/resolver/BlueToothDeviceInfoProfileResolverTest.java b/server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/resolver/BlueToothDeviceInfoProfileResolverTest.java similarity index 73% rename from server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/resolver/BlueToothDeviceInfoProfileResolverTest.java rename to server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/resolver/BlueToothDeviceInfoProfileResolverTest.java index 3a7d794168..9e54f45539 100644 --- a/server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/resolver/BlueToothDeviceInfoProfileResolverTest.java +++ b/server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/resolver/BlueToothDeviceInfoProfileResolverTest.java @@ -17,8 +17,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import org.eclipse.vorto.repository.internal.resolver.BlueToothUUIDResolver; -import org.eclipse.vorto.repository.model.ModelId; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.resolver.BluetoothQuery; +import org.eclipse.vorto.repository.internal.resolver.DefaultResolver; import org.eclipse.vorto.repository.service.AbstractIntegrationTest; import org.junit.Test; @@ -30,10 +31,11 @@ public void testResolveInfoModelByDeviceInfoProfileSerialNo() { checkinModel("bluetooth/ColorLightIM.infomodel"); checkinModel("bluetooth/ColorLight_bluetooth.mapping"); - BlueToothUUIDResolver resolver = new BlueToothUUIDResolver(this.modelRepository,"bluetooth"); - assertEquals(new ModelId("ColorLightIM", "com.mycompany", "1.0.0"),resolver.resolve("4810")); + DefaultResolver resolver = new DefaultResolver(); + resolver.setRepository(this.modelRepository); + assertEquals(new ModelId("ColorLightIM", "com.mycompany", "1.0.0"),resolver.resolve(new BluetoothQuery("4810"))); - assertNotNull(this.modelRepository.getById(resolver.resolve("4810"))); + assertNotNull(this.modelRepository.getById(resolver.resolve(new BluetoothQuery("4810")))); } } diff --git a/server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/resolver/Lwm2mObjectIdResolverTest.java b/server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/resolver/Lwm2mObjectIdResolverTest.java similarity index 71% rename from server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/resolver/Lwm2mObjectIdResolverTest.java rename to server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/resolver/Lwm2mObjectIdResolverTest.java index 46bbc2cbed..8fd35e0b10 100644 --- a/server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/resolver/Lwm2mObjectIdResolverTest.java +++ b/server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/resolver/Lwm2mObjectIdResolverTest.java @@ -18,8 +18,9 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import org.eclipse.vorto.repository.internal.resolver.Lwm2mObjectIdResolver; -import org.eclipse.vorto.repository.model.ModelId; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.resolver.LWM2MQuery; +import org.eclipse.vorto.repository.internal.resolver.DefaultResolver; import org.eclipse.vorto.repository.service.AbstractIntegrationTest; import org.junit.Test; @@ -30,10 +31,11 @@ public void testResolveForExistingObjectId() { checkinModel("lwm2m/ColorLight.fbmodel"); checkinModel("lwm2m/ColorLight_lwm2m.mapping"); - Lwm2mObjectIdResolver lwm2mResolver = new Lwm2mObjectIdResolver(this.modelRepository,"lwm2m"); - assertEquals(new ModelId("ColorLight", "com.mycompany.fb", "1.0.0"),lwm2mResolver.resolve("2")); + DefaultResolver lwm2mResolver = new DefaultResolver(); + lwm2mResolver.setRepository(this.modelRepository); + assertEquals(new ModelId("ColorLight", "com.mycompany.fb", "1.0.0"),lwm2mResolver.resolve(new LWM2MQuery("2"))); - assertNotNull(this.modelRepository.getById(lwm2mResolver.resolve("2"))); + assertNotNull(this.modelRepository.getById(lwm2mResolver.resolve(new LWM2MQuery("2")))); } @Test @@ -41,7 +43,8 @@ public void testResolveResourceId() { checkinModel("lwm2m/ColorLight.fbmodel"); checkinModel("lwm2m/ColorLight_lwm2m.mapping"); - Lwm2mObjectIdResolver lwm2mResolver = new Lwm2mObjectIdResolver(this.modelRepository,"lwm2m"); - assertNull(lwm2mResolver.resolve("3")); + DefaultResolver lwm2mResolver = new DefaultResolver(); + lwm2mResolver.setRepository(this.modelRepository); + assertNull(lwm2mResolver.resolve(new LWM2MQuery("3"))); } } diff --git a/server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/service/AbstractIntegrationTest.java b/server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/service/AbstractIntegrationTest.java similarity index 97% rename from server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/service/AbstractIntegrationTest.java rename to server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/service/AbstractIntegrationTest.java index 0e7a44ebf0..9b44a8d95c 100644 --- a/server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/service/AbstractIntegrationTest.java +++ b/server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/service/AbstractIntegrationTest.java @@ -5,11 +5,11 @@ import java.util.Collections; import org.apache.commons.io.IOUtils; +import org.eclipse.vorto.repository.api.upload.UploadModelResult; import org.eclipse.vorto.repository.internal.service.InMemoryTemporaryStorage; import org.eclipse.vorto.repository.internal.service.JcrModelRepository; import org.eclipse.vorto.repository.internal.service.notification.INotificationService; import org.eclipse.vorto.repository.internal.service.utils.ModelSearchUtil; -import org.eclipse.vorto.repository.model.UploadModelResult; import org.junit.Before; import org.mockito.InjectMocks; import org.mockito.Mock; diff --git a/server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/service/BulkUploadTest.java b/server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/service/BulkUploadTest.java similarity index 96% rename from server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/service/BulkUploadTest.java rename to server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/service/BulkUploadTest.java index fbfb53cf66..9ab9c08f1a 100644 --- a/server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/service/BulkUploadTest.java +++ b/server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/service/BulkUploadTest.java @@ -22,9 +22,9 @@ import java.util.List; import org.apache.commons.io.IOUtils; +import org.eclipse.vorto.repository.api.upload.UploadModelResult; import org.eclipse.vorto.repository.internal.service.InMemoryTemporaryStorage; import org.eclipse.vorto.repository.internal.service.utils.BulkUploadHelper; -import org.eclipse.vorto.repository.model.UploadModelResult; import org.junit.Test; import org.springframework.core.io.ClassPathResource; diff --git a/server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/service/DependencyManagerTest.java b/server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/service/DependencyManagerTest.java similarity index 63% rename from server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/service/DependencyManagerTest.java rename to server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/service/DependencyManagerTest.java index dc7098013b..18449b80b4 100644 --- a/server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/service/DependencyManagerTest.java +++ b/server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/service/DependencyManagerTest.java @@ -5,10 +5,10 @@ import java.util.Arrays; import java.util.stream.Collectors; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; +import org.eclipse.vorto.repository.api.ModelType; import org.eclipse.vorto.repository.internal.service.utils.DependencyManager; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ModelResource; -import org.eclipse.vorto.repository.model.ModelType; import org.junit.Before; import org.junit.Test; @@ -23,9 +23,9 @@ public void setUp() { @Test public void testDependentDatatypes() { - ModelResource subunit = create("Subunit",ModelType.Datatype); - ModelResource unit = create("Unit",ModelType.Datatype,subunit); - ModelResource temp = create("Temperature",ModelType.Datatype,unit); + ModelInfo subunit = create("Subunit",ModelType.Datatype); + ModelInfo unit = create("Unit",ModelType.Datatype,subunit); + ModelInfo temp = create("Temperature",ModelType.Datatype,unit); dm.addResource(subunit); dm.addResource(unit); @@ -38,10 +38,10 @@ public void testDependentDatatypes() { @Test public void testDependentTypesWithFB() { - ModelResource subunit = create("Subunit",ModelType.Datatype); - ModelResource unit = create("Unit",ModelType.Datatype,subunit); - ModelResource temp = create("Temperature",ModelType.Datatype,unit); - ModelResource fridge = create("Fridge",ModelType.Functionblock,temp); + ModelInfo subunit = create("Subunit",ModelType.Datatype); + ModelInfo unit = create("Unit",ModelType.Datatype,subunit); + ModelInfo temp = create("Temperature",ModelType.Datatype,unit); + ModelInfo fridge = create("Fridge",ModelType.Functionblock,temp); dm.addResource(unit); dm.addResource(subunit); @@ -56,11 +56,11 @@ public void testDependentTypesWithFB() { @Test public void testDependentTypesWithFB2() { - ModelResource subunit = create("Subunit",ModelType.Datatype); - ModelResource unit = create("Unit",ModelType.Datatype,subunit); - ModelResource temp = create("Temperature",ModelType.Datatype,unit); - ModelResource superFridge = create("SuperFridge",ModelType.Functionblock,temp); - ModelResource fridge = create("Fridge",ModelType.Functionblock,superFridge); + ModelInfo subunit = create("Subunit",ModelType.Datatype); + ModelInfo unit = create("Unit",ModelType.Datatype,subunit); + ModelInfo temp = create("Temperature",ModelType.Datatype,unit); + ModelInfo superFridge = create("SuperFridge",ModelType.Functionblock,temp); + ModelInfo fridge = create("Fridge",ModelType.Functionblock,superFridge); dm.addResource(unit); dm.addResource(subunit); @@ -75,9 +75,9 @@ public void testDependentTypesWithFB2() { assertEquals(fridge.getId(),dm.getSorted().get(4).getId()); } - protected ModelResource create(String name, ModelType type, ModelResource... references) { + protected ModelInfo create(String name, ModelType type, ModelInfo... references) { final ModelId id = new ModelId(name, "org.eclipse.vorto", "1.0.0"); - ModelResource resource = new ModelResource(id, type); + ModelInfo resource = new ModelInfo(id, type); resource.setReferences(Arrays.asList(references).stream().map(reference -> reference.getId()).collect(Collectors.toList())); Arrays.asList(references).stream().forEach(it -> it.addReferencedBy(id)); return resource; diff --git a/server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/service/ModelRepositoryTest.java b/server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/service/ModelRepositoryTest.java similarity index 96% rename from server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/service/ModelRepositoryTest.java rename to server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/service/ModelRepositoryTest.java index 516d25b76e..99cc969ac8 100644 --- a/server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/service/ModelRepositoryTest.java +++ b/server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/service/ModelRepositoryTest.java @@ -27,10 +27,10 @@ import java.util.Collection; import org.apache.commons.io.IOUtils; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ModelResource; -import org.eclipse.vorto.repository.model.ModelType; -import org.eclipse.vorto.repository.model.UploadModelResult; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; +import org.eclipse.vorto.repository.api.ModelType; +import org.eclipse.vorto.repository.api.upload.UploadModelResult; import org.eclipse.vorto.repository.model.User; import org.eclipse.vorto.repository.service.IModelRepository.ContentType; import org.junit.Test; @@ -53,11 +53,11 @@ public void tesUploadValidModel() throws IOException { assertEquals(true, uploadResult.isValid()); assertNull(uploadResult.getErrorMessage()); assertNotNull(uploadResult.getHandleId()); - ModelResource resource = uploadResult.getModelResource(); + ModelInfo resource = uploadResult.getModelResource(); assertEquals("org.eclipse.vorto.examples.type", resource.getId().getNamespace()); assertEquals("Color", resource.getId().getName()); assertEquals("1.0.0", resource.getId().getVersion()); - assertEquals(ModelType.Datatype, resource.getModelType()); + assertEquals(ModelType.Datatype, resource.getType()); assertEquals(0, resource.getReferences().size()); assertEquals("Color", resource.getDisplayName()); assertNull(resource.getDescription()); @@ -106,7 +106,7 @@ public void testCheckinInvalidModel() throws Exception { public void testGetModelById() throws Exception { checkinModel("Color.type"); assertEquals(1, modelRepository.search("*").size()); - ModelResource result = modelRepository + ModelInfo result = modelRepository .getById(ModelId.fromReference("org.eclipse.vorto.examples.type.Color", "1.0.0")); assertNotNull(result); } @@ -138,7 +138,7 @@ public void testGetReferencesFromModel() throws Exception { checkinModel("Color.type"); checkinModel("Colorlight.fbmodel"); assertEquals(2, modelRepository.search("*").size()); - ModelResource result = modelRepository + ModelInfo result = modelRepository .getById(ModelId.fromReference("org.eclipse.vorto.examples.fb.ColorLight", "1.0.0")); assertEquals(1, result.getReferences().size()); assertEquals("org.eclipse.vorto.examples.type.Color:1.0.0", result.getReferences().get(0).getPrettyFormat()); @@ -149,7 +149,7 @@ public void testGetReferencedBy() throws Exception { checkinModel("Color.type"); checkinModel("Colorlight.fbmodel"); assertEquals(2, modelRepository.search("*").size()); - ModelResource result = modelRepository + ModelInfo result = modelRepository .getById(ModelId.fromReference("org.eclipse.vorto.examples.type.Color", "1.0.0")); assertEquals(1, result.getReferencedBy().size()); assertEquals("org.eclipse.vorto.examples.fb.ColorLight:1.0.0", @@ -183,11 +183,11 @@ public void tesUploadMapping() throws IOException { assertEquals(true, uploadResult.isValid()); assertNull(uploadResult.getErrorMessage()); assertNotNull(uploadResult.getHandleId()); - ModelResource resource = uploadResult.getModelResource(); + ModelInfo resource = uploadResult.getModelResource(); assertEquals("org.eclipse.vorto.examples.type", resource.getId().getNamespace()); assertEquals("Color", resource.getId().getName()); assertEquals("1.0.0", resource.getId().getVersion()); - assertEquals(ModelType.Datatype, resource.getModelType()); + assertEquals(ModelType.Datatype, resource.getType()); assertEquals(0, resource.getReferences().size()); assertEquals("Color", resource.getDisplayName()); assertNull(resource.getDescription()); diff --git a/server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/service/NotificationServiceTest.java b/server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/service/NotificationServiceTest.java similarity index 92% rename from server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/service/NotificationServiceTest.java rename to server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/service/NotificationServiceTest.java index e2fac48fac..30d02d46f3 100644 --- a/server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/service/NotificationServiceTest.java +++ b/server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/service/NotificationServiceTest.java @@ -19,12 +19,12 @@ import java.util.Date; +import org.eclipse.vorto.repository.api.ModelId; +import org.eclipse.vorto.repository.api.ModelInfo; +import org.eclipse.vorto.repository.api.ModelType; import org.eclipse.vorto.repository.internal.service.notification.EmailNotificationService; import org.eclipse.vorto.repository.internal.service.notification.message.CheckinMessage; import org.eclipse.vorto.repository.internal.service.notification.message.RegistrationMessage; -import org.eclipse.vorto.repository.model.ModelId; -import org.eclipse.vorto.repository.model.ModelResource; -import org.eclipse.vorto.repository.model.ModelType; import org.eclipse.vorto.repository.model.User; import org.junit.AfterClass; import org.junit.Before; @@ -100,7 +100,7 @@ public void testSendCheckedModelEmail() throws Exception { user.setEmail("alexander.edelmann@bosch-si.com"); user.setUsername("aedelmann"); - ModelResource resource = new ModelResource(new ModelId("Fridge","org.eclipse.vorto.examples","1.0.0"), ModelType.Functionblock); + ModelInfo resource = new ModelInfo(new ModelId("Fridge","org.eclipse.vorto.examples","1.0.0"), ModelType.Functionblock); resource.setAuthor("andreas"); resource.setCreationDate(new Date()); resource.setDescription("A fridge keeps groceries fresh"); diff --git a/server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/service/RepositoryAdminTest.java b/server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/service/RepositoryAdminTest.java similarity index 98% rename from server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/service/RepositoryAdminTest.java rename to server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/service/RepositoryAdminTest.java index e9a32824ec..17e6220062 100644 --- a/server/repo/repo-core/src/test/java/org/eclipse/vorto/repository/service/RepositoryAdminTest.java +++ b/server/repo/repository-server/src/test/java/org/eclipse/vorto/repository/service/RepositoryAdminTest.java @@ -6,8 +6,8 @@ import static org.junit.Assert.fail; import org.apache.commons.io.IOUtils; +import org.eclipse.vorto.repository.api.ModelId; import org.eclipse.vorto.repository.internal.service.DefaultRepositoryManager; -import org.eclipse.vorto.repository.model.ModelId; import org.junit.Test; import org.springframework.core.io.ClassPathResource; diff --git a/server/repo/repo-core/src/test/resources/application-context.xml b/server/repo/repository-server/src/test/resources/application-context.xml similarity index 100% rename from server/repo/repo-core/src/test/resources/application-context.xml rename to server/repo/repository-server/src/test/resources/application-context.xml diff --git a/server/repo/repo-ui/src/main/resources/application-mysql.yml b/server/repo/repository-server/src/test/resources/application-mysql.yml similarity index 100% rename from server/repo/repo-ui/src/main/resources/application-mysql.yml rename to server/repo/repository-server/src/test/resources/application-mysql.yml diff --git a/server/repo/repo-core/src/test/resources/infinispan-configuration.xml b/server/repo/repository-server/src/test/resources/infinispan-configuration.xml similarity index 100% rename from server/repo/repo-core/src/test/resources/infinispan-configuration.xml rename to server/repo/repository-server/src/test/resources/infinispan-configuration.xml diff --git a/server/repo/repo-core/src/test/resources/sample_models/Color.type b/server/repo/repository-server/src/test/resources/sample_models/Color.type similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/Color.type rename to server/repo/repository-server/src/test/resources/sample_models/Color.type diff --git a/server/repo/repo-core/src/test/resources/sample_models/Color.xmi b/server/repo/repository-server/src/test/resources/sample_models/Color.xmi similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/Color.xmi rename to server/repo/repository-server/src/test/resources/sample_models/Color.xmi diff --git a/server/repo/repo-core/src/test/resources/sample_models/ColorLightIM.infomodel b/server/repo/repository-server/src/test/resources/sample_models/ColorLightIM.infomodel similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/ColorLightIM.infomodel rename to server/repo/repository-server/src/test/resources/sample_models/ColorLightIM.infomodel diff --git a/server/repo/repo-core/src/test/resources/sample_models/Colorlight.fbmodel b/server/repo/repository-server/src/test/resources/sample_models/Colorlight.fbmodel similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/Colorlight.fbmodel rename to server/repo/repository-server/src/test/resources/sample_models/Colorlight.fbmodel diff --git a/server/repo/repo-core/src/test/resources/sample_models/Corrupt-model_missingVersion.type b/server/repo/repository-server/src/test/resources/sample_models/Corrupt-model_missingVersion.type similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/Corrupt-model_missingVersion.type rename to server/repo/repository-server/src/test/resources/sample_models/Corrupt-model_missingVersion.type diff --git a/server/repo/repo-core/src/test/resources/sample_models/Corrupt-model_namespace.type b/server/repo/repository-server/src/test/resources/sample_models/Corrupt-model_namespace.type similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/Corrupt-model_namespace.type rename to server/repo/repository-server/src/test/resources/sample_models/Corrupt-model_namespace.type diff --git a/server/repo/repo-core/src/test/resources/sample_models/Corrupt-model_olderVersionOfMetaModel.fbmodel b/server/repo/repository-server/src/test/resources/sample_models/Corrupt-model_olderVersionOfMetaModel.fbmodel similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/Corrupt-model_olderVersionOfMetaModel.fbmodel rename to server/repo/repository-server/src/test/resources/sample_models/Corrupt-model_olderVersionOfMetaModel.fbmodel diff --git a/server/repo/repo-core/src/test/resources/sample_models/HueLightStrips.infomodel b/server/repo/repository-server/src/test/resources/sample_models/HueLightStrips.infomodel similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/HueLightStrips.infomodel rename to server/repo/repository-server/src/test/resources/sample_models/HueLightStrips.infomodel diff --git a/server/repo/repo-core/src/test/resources/sample_models/Switcher.fbmodel b/server/repo/repository-server/src/test/resources/sample_models/Switcher.fbmodel similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/Switcher.fbmodel rename to server/repo/repository-server/src/test/resources/sample_models/Switcher.fbmodel diff --git a/server/repo/repo-core/src/test/resources/sample_models/backup-withImages.xml b/server/repo/repository-server/src/test/resources/sample_models/backup-withImages.xml similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/backup-withImages.xml rename to server/repo/repository-server/src/test/resources/sample_models/backup-withImages.xml diff --git a/server/repo/repo-core/src/test/resources/sample_models/backup1.xml b/server/repo/repository-server/src/test/resources/sample_models/backup1.xml similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/backup1.xml rename to server/repo/repository-server/src/test/resources/sample_models/backup1.xml diff --git a/server/repo/repo-core/src/test/resources/sample_models/bluetooth/ColorLight.fbmodel b/server/repo/repository-server/src/test/resources/sample_models/bluetooth/ColorLight.fbmodel similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/bluetooth/ColorLight.fbmodel rename to server/repo/repository-server/src/test/resources/sample_models/bluetooth/ColorLight.fbmodel diff --git a/server/repo/repo-core/src/test/resources/sample_models/bluetooth/ColorLightIM.infomodel b/server/repo/repository-server/src/test/resources/sample_models/bluetooth/ColorLightIM.infomodel similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/bluetooth/ColorLightIM.infomodel rename to server/repo/repository-server/src/test/resources/sample_models/bluetooth/ColorLightIM.infomodel diff --git a/server/repo/repo-core/src/test/resources/sample_models/bluetooth/ColorLight_bluetooth.mapping b/server/repo/repository-server/src/test/resources/sample_models/bluetooth/ColorLight_bluetooth.mapping similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/bluetooth/ColorLight_bluetooth.mapping rename to server/repo/repository-server/src/test/resources/sample_models/bluetooth/ColorLight_bluetooth.mapping diff --git a/server/repo/repo-core/src/test/resources/sample_models/invalid-models.zip b/server/repo/repository-server/src/test/resources/sample_models/invalid-models.zip similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/invalid-models.zip rename to server/repo/repository-server/src/test/resources/sample_models/invalid-models.zip diff --git a/server/repo/repo-core/src/test/resources/sample_models/lwm2m/ColorLight.fbmodel b/server/repo/repository-server/src/test/resources/sample_models/lwm2m/ColorLight.fbmodel similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/lwm2m/ColorLight.fbmodel rename to server/repo/repository-server/src/test/resources/sample_models/lwm2m/ColorLight.fbmodel diff --git a/server/repo/repo-core/src/test/resources/sample_models/lwm2m/ColorLight_lwm2m.mapping b/server/repo/repository-server/src/test/resources/sample_models/lwm2m/ColorLight_lwm2m.mapping similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/lwm2m/ColorLight_lwm2m.mapping rename to server/repo/repository-server/src/test/resources/sample_models/lwm2m/ColorLight_lwm2m.mapping diff --git a/server/repo/repo-core/src/test/resources/sample_models/missing-models.zip b/server/repo/repository-server/src/test/resources/sample_models/missing-models.zip similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/missing-models.zip rename to server/repo/repository-server/src/test/resources/sample_models/missing-models.zip diff --git a/server/repo/repo-core/src/test/resources/sample_models/modelsWithSameId.zip b/server/repo/repository-server/src/test/resources/sample_models/modelsWithSameId.zip similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/modelsWithSameId.zip rename to server/repo/repository-server/src/test/resources/sample_models/modelsWithSameId.zip diff --git a/server/repo/repo-core/src/test/resources/sample_models/modelsWithWrongGrammar.zip b/server/repo/repository-server/src/test/resources/sample_models/modelsWithWrongGrammar.zip similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/modelsWithWrongGrammar.zip rename to server/repo/repository-server/src/test/resources/sample_models/modelsWithWrongGrammar.zip diff --git a/server/repo/repo-core/src/test/resources/sample_models/sample.mapping b/server/repo/repository-server/src/test/resources/sample_models/sample.mapping similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/sample.mapping rename to server/repo/repository-server/src/test/resources/sample_models/sample.mapping diff --git a/server/repo/repo-core/src/test/resources/sample_models/sample.png b/server/repo/repository-server/src/test/resources/sample_models/sample.png similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/sample.png rename to server/repo/repository-server/src/test/resources/sample_models/sample.png diff --git a/server/repo/repo-core/src/test/resources/sample_models/valid-models.zip b/server/repo/repository-server/src/test/resources/sample_models/valid-models.zip similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/valid-models.zip rename to server/repo/repository-server/src/test/resources/sample_models/valid-models.zip diff --git a/server/repo/repo-core/src/test/resources/sample_models/valid-models1.zip b/server/repo/repository-server/src/test/resources/sample_models/valid-models1.zip similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/valid-models1.zip rename to server/repo/repository-server/src/test/resources/sample_models/valid-models1.zip diff --git a/server/repo/repo-core/src/test/resources/sample_models/validmodels_withmappings.zip b/server/repo/repository-server/src/test/resources/sample_models/validmodels_withmappings.zip similarity index 100% rename from server/repo/repo-core/src/test/resources/sample_models/validmodels_withmappings.zip rename to server/repo/repository-server/src/test/resources/sample_models/validmodels_withmappings.zip diff --git a/server/repo/repo-core/src/test/resources/sequencer-model.cnd b/server/repo/repository-server/src/test/resources/sequencer-model.cnd similarity index 100% rename from server/repo/repo-core/src/test/resources/sequencer-model.cnd rename to server/repo/repository-server/src/test/resources/sequencer-model.cnd diff --git a/server/repo/repo-core/src/test/resources/vorto-repository.json b/server/repo/repository-server/src/test/resources/vorto-repository.json similarity index 100% rename from server/repo/repo-core/src/test/resources/vorto-repository.json rename to server/repo/repository-server/src/test/resources/vorto-repository.json