Skip to content

Commit

Permalink
Fixes #483
Browse files Browse the repository at this point in the history
  • Loading branch information
aedelmann committed Jan 15, 2017
2 parents c885803 + 9d06b52 commit 0cbebd1
Show file tree
Hide file tree
Showing 233 changed files with 1,860 additions and 1,795 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public RestClient(ConnectionInfo connectionInfo) {
this.connectionInfo = connectionInfo;
}

@SuppressWarnings("restriction")
public <Result> Result executeGet(String query, final Function<String, Result> responseConverter)
throws ClientProtocolException, IOException {
ProxyConfiguration proxyProvider = getProxyConfiguration();
Expand All @@ -75,7 +74,6 @@ public Result handleSuccess(HttpResponse response) throws ClientProtocolExceptio
});
}

@SuppressWarnings("restriction")
public Attachment executeGetAttachment(String query) throws ClientProtocolException, IOException {
ProxyConfiguration proxyProvider = getProxyConfiguration();

Expand All @@ -97,7 +95,6 @@ public Attachment handleSuccess(HttpResponse response) throws ClientProtocolExce
});
}

@SuppressWarnings("restriction")
public <Result> Result executePost(String query, HttpEntity content,
final Function<String, Result> responseConverter) throws ClientProtocolException, IOException {
ProxyConfiguration proxyProvider = getProxyConfiguration();
Expand All @@ -121,7 +118,6 @@ protected Result handleFailure(HttpResponse response) throws ClientProtocolExcep
});
}

@SuppressWarnings("restriction")
public void executePut(String query) throws ClientProtocolException, IOException {
ProxyConfiguration proxyProvider = getProxyConfiguration();

Expand All @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
public class ModelViewToModelResource implements Function<ModelView, ModelResource> {

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()));
}

private List<ModelId> transformReferences(ModelView modelView, List<ModelId> references) {
for (ModelId modelId : references) {
modelId.setModelType(getReferenceModelType(modelView.getModelType()));
modelId.setModelType(getReferenceModelType(modelView.getType()));
}
return references;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ModelId> references = new ArrayList<>();
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions server/devtool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.vorto</groupId>
<artifactId>repo-http-models</artifactId>
<artifactId>repository-api</artifactId>
<version>${project.version}</version>
</dependency>

Expand Down Expand Up @@ -99,7 +99,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.vorto</groupId>
<artifactId>repo-http-models</artifactId>
<artifactId>repository-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> referencedResourceSet);

public abstract List<ModelResourceDto> searchModelByExpression(String expression);
public abstract List<ModelInfo> searchModelByExpression(String expression);

protected final List<ModelResourceDto> searchModelByExpressionAndValidate(String expression,
org.eclipse.vorto.http.model.ModelTypeDto modelType) {
List<ModelResourceDto> resourceList = devtoolRestClient.searchByExpression(expression);
ArrayList<ModelResourceDto> modelResourceList = new ArrayList<ModelResourceDto>();
for (ModelResourceDto modelResource : resourceList) {
if (modelResource.getModelType().equals(modelType)) {
protected final List<ModelInfo> searchModelByExpressionAndValidate(String expression,
ModelType modelType) {
List<ModelInfo> resourceList = devtoolRestClient.searchByExpression(expression);
ArrayList<ModelInfo> modelResourceList = new ArrayList<ModelInfo>();
for (ModelInfo modelResource : resourceList) {
if (modelResource.getType().equals(modelType)) {
modelResourceList.add(modelResource);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> referencedResourceSet) {
devtoolReferenceLinker.linkDataTypeToFunctionBlock(datatypeResourceId, datatypeModelId,
resourceSet, referencedResourceSet);
Expand All @@ -51,8 +52,8 @@ public String linkModelToResource(String datatypeResourceId, ModelIdDto datatype
}

@Override
public List<ModelResourceDto> searchModelByExpression(String expression) {
List<ModelResourceDto> modelList = searchModelByExpressionAndValidate(expression + " " + org.eclipse.vorto.http.model.ModelTypeDto.Datatype.toString() , org.eclipse.vorto.http.model.ModelTypeDto.Datatype);
public List<ModelInfo> searchModelByExpression(String expression) {
List<ModelInfo> modelList = searchModelByExpressionAndValidate(expression + " " + ModelType.Datatype.toString() , ModelType.Datatype);
return modelList;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> referencedResourceSet) {
devtoolReferenceLinker.linkDataTypeToFunctionBlock(functionBlockResourceId, datatypeModelId,
resourceSet, referencedResourceSet);
Expand All @@ -49,9 +50,9 @@ public String linkModelToResource(String functionBlockResourceId, ModelIdDto dat
}
}

public List<ModelResourceDto> searchModelByExpression(String expression) {
List<ModelResourceDto> modelList = searchModelByExpressionAndValidate(expression + " " + org.eclipse.vorto.http.model.ModelTypeDto.Datatype.toString() , org.eclipse.vorto.http.model.ModelTypeDto.Datatype);
List<ModelResourceDto> functionBlockModelList = searchModelByExpressionAndValidate(expression + " " + org.eclipse.vorto.http.model.ModelTypeDto.Functionblock.toString(), org.eclipse.vorto.http.model.ModelTypeDto.Functionblock);
public List<ModelInfo> searchModelByExpression(String expression) {
List<ModelInfo> modelList = searchModelByExpressionAndValidate(expression + " " + ModelType.Datatype.toString() , ModelType.Datatype);
List<ModelInfo> functionBlockModelList = searchModelByExpressionAndValidate(expression + " " + ModelType.Functionblock.toString(), ModelType.Functionblock);
modelList.addAll(functionBlockModelList);
return modelList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> referencedResourceSet) {
devtoolReferenceLinker.linkFunctionBlockToInfoModel(infoModelResourceId, functionBlockModelId,
resourceSet, referencedResourceSet);
Expand All @@ -49,7 +50,7 @@ public String linkModelToResource(String infoModelResourceId, ModelIdDto functio
}
}

public List<ModelResourceDto> searchModelByExpression(String expression) {
return searchModelByExpressionAndValidate(expression + " " + org.eclipse.vorto.http.model.ModelTypeDto.Functionblock.toString(), org.eclipse.vorto.http.model.ModelTypeDto.Functionblock);
public List<ModelInfo> searchModelByExpression(String expression) {
return searchModelByExpressionAndValidate(expression + " " + ModelType.Functionblock.toString(), ModelType.Functionblock);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<String> referencedResourceSet) {
if (!containsResource(infoModelResourceId, resourceSet)) {
throw new RuntimeException("No resource with resourceId : " + infoModelResourceId);
Expand All @@ -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<String> referencedResourceSet) {
if (!containsResource(functionBlockResourceId, resourceSet)) {
throw new RuntimeException("No resource with resourceId : " + functionBlockResourceId);
Expand All @@ -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<String> referencedResourceSet) {
if (!containsResource(dataTypeResourceId, resourceSet)) {
throw new RuntimeException("No resource with resourceId : " + dataTypeResourceId);
Expand All @@ -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<String> referencedResourceSet) {

ModelType referenceModelType = devtoolRestClient.getModelType(referenceModelId);
Expand Down Expand Up @@ -170,13 +170,13 @@ private String generateFunctionBlockVariableName(FunctionblockModel fbm, Set<Str
return variableName;
}

private String getFileName(ModelIdDto modelId) {
private String getFileName(ModelId modelId) {
ModelType modelType = devtoolRestClient.getModelType(modelId);
return modelId.getNamespace().replace(".", "_") + "_" + modelId.getName() + "_"
+ modelId.getVersion().replace(".", "_") + modelType.getExtension();
}

private URI getURI(ModelIdDto modelId) {
private URI getURI(ModelId modelId) {
URI uri = URI.createURI("fake:/" + getFileName(modelId));
return uri;
}
Expand Down
Loading

0 comments on commit 0cbebd1

Please sign in to comment.