Skip to content

Commit

Permalink
Added project resource namespace and name
Browse files Browse the repository at this point in the history
Signed-off-by: shiv12095 <shiv12095@iiitd.ac.in>
  • Loading branch information
shiv12095 committed Aug 15, 2016
1 parent dcceac7 commit 182f53b
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 24 deletions.
Expand Up @@ -127,15 +127,15 @@ public void deleteProjectResource(

@ApiOperation(value = "Creates a new resource in the Vorto project")
@RequestMapping(value = "/{projectName}/resources/create", method = RequestMethod.POST)
public void getProjectResourceContents(
public void createProjectResource(
@RequestBody ProjectResource projectResoure,
@ApiParam(value = "ProjectName", required = true) final @PathVariable String projectName,
@ApiParam(value = "Request", required = true) final HttpServletRequest request)
throws ProjectNotFoundException {

Objects.requireNonNull(projectName, "projectName must not be null");
String sessionId = request.getSession().getId();
projectRepositoryService.createResource(sessionId, projectName, projectResoure.getName(), projectResoure.getResourceId());
projectRepositoryService.createResource(sessionId, projectName, projectResoure);
}

@ApiOperation(value = "Returns a list of resources in the Vorto project")
Expand Down
@@ -1,33 +1,55 @@
package org.eclipse.vorto.server.devtool.models;

public class ProjectResource {

private String resourceId;
private String name;
private String version;
private String namespace;

public String getResourceId() {
return resourceId;
}

public void setResourceId(String resourceId) {
this.resourceId = resourceId;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getVersion() {
return version;
}

public void setVersion(String version) {
this.version = version;
}

public String getNamespace() {
return namespace;
}

public void setNamespace(String namespace) {
this.namespace = namespace;
}

@Override
public boolean equals(Object obj) {
if(obj.getClass().equals(this.getClass())){
ProjectResource projectResource = (ProjectResource)obj;
if(projectResource.getResourceId().equals(this.resourceId)){
if (obj.getClass().equals(this.getClass())) {
ProjectResource projectResource = (ProjectResource) obj;
if (projectResource.getResourceId().equals(this.resourceId)) {
// if (projectResource.getName().endsWith(this.name)) {
// return true;
// }
return true;
}else{
return false;
}
}else{
return false;
}
}
return false;
}
}
Expand Up @@ -19,7 +19,7 @@ public interface IProjectRepositoryService {

ArrayList<ProjectResource> getProjectResources(String sessionId, String projectName) throws ProjectNotFoundException;

void createResource(String sessionId, String projectName, String resourceName, String resourceId) throws ProjectNotFoundException;
void createResource(String sessionId, String projectName, ProjectResource projectResource) throws ProjectNotFoundException;

void deleteResource(String sessionId, String projectName, String resourceId) throws ProjectNotFoundException;
}
Expand Up @@ -77,12 +77,9 @@ public ArrayList<Project> getProjects(String sessionId) {
}

@Override
public void createResource(String sessionId, String projectName, String resourceName, String resourceId) throws ProjectNotFoundException {
public void createResource(String sessionId, String projectName, ProjectResource projectResource) throws ProjectNotFoundException {
Project project = openProject(sessionId, projectName);
ArrayList<ProjectResource> resourceList = project.getResourceList();
ProjectResource projectResource = new ProjectResource();
projectResource.setResourceId(resourceId);
projectResource.setName(resourceName);
resourceList.add(projectResource);
}

Expand Down
19 changes: 14 additions & 5 deletions server/devtool/src/main/resources/static/dist/js/controllers.js
Expand Up @@ -48,7 +48,6 @@ define(["angular"], function(angular) {
$scope.getResources = function() {
$http.get('./project/' + $scope.projectName + '/resources').success(
function(data, status, headers, config) {
console.log(data);
for (i = 0; i < data.length; i++) {
$scope.openEditor(data[i]);
}
Expand Down Expand Up @@ -96,6 +95,8 @@ define(["angular"], function(angular) {
editorDivId: editorDivId,
language: language,
name: resource.name,
version: resource.version,
namespace: resource.namespace,
resourceId: resource.resourceId
};
$scope.tabs.push(tab);
Expand Down Expand Up @@ -211,9 +212,14 @@ define(["angular"], function(angular) {
var resourceId = $scope.selectedEditor.xtextServices.validationService._encodedResourceId;
var tab = $scope.tabs[$scope.selectedTabIndex];
tab['resourceId'] = resourceId;
tab['name'] = model.name;
tab['version'] = model.version;
tab['namespace'] = model.namespace;
$http.post('./project/' + $scope.projectName + '/resources/create', {
"name": model.name,
"resourceId": resourceId
"resourceId": resourceId,
"version": model.version,
"namespace": model.namespace
}).success(
function(data, status, headers, config) {}).error(function(data, status, headers, config) {});
});
Expand All @@ -239,9 +245,14 @@ define(["angular"], function(angular) {
var resourceId = $scope.selectedEditor.xtextServices.validationService._encodedResourceId;
var tab = $scope.tabs[$scope.selectedTabIndex];
tab['resourceId'] = resourceId;
tab['name'] = model.name;
tab['version'] = model.version;
tab['namespace'] = model.namespace;
$http.post('./project/' + $scope.projectName + '/resources/create', {
"name": model.name,
"resourceId": resourceId
"resourceId": resourceId,
"version": model.version,
"namespace": model.namespace
}).success(
function(data, status, headers, config) {}).error(function(data, status, headers, config) {});
});
Expand Down Expand Up @@ -322,7 +333,6 @@ define(["angular"], function(angular) {
var resources = [];
$http.get('./project/' + $scope.projectName + '/resources').success(
function(data, status, headers, config) {
console.log(data);
var modalInstance = $uibModal.open({
animation: true,
controller: 'OpenResourceModalController',
Expand Down Expand Up @@ -413,7 +423,6 @@ define(["angular"], function(angular) {
$http.get('./editor/infomodel/search=' + filter).success(
function(data, status, headers, config) {
$scope.models = data;
console.log(data);
}).error(function(data, status, headers, config) {
$scope.models = [];
});
Expand Down
Expand Up @@ -27,9 +27,8 @@ define("devtoolApp", ["angular", "angular-route", "angular-animate", "angular-ar
$rootScope.getRepositoryBasePath = function() {
$http.get('./repository/basepath').success(function(data, status, headers, config) {
$rootScope.repoBasePath = data['basepath'];
console.log($rootScope.repoBasePath);
}).error(function(data, status, headers, config) {
$rootScope.repoBasePath = "/";
$rootScope.repoBasePath = "http://vorto.eclipse.org/#/";
});
}

Expand Down
Expand Up @@ -7,7 +7,6 @@ define(["angular"], function(angular) {
link: function(scope, elem, attrs, ctrl) {
elem.on('blur', function(evt) {
scope.$apply(function() {
console.log("Calling request : " + elem.val());
if (elem.val()) {
$http.get('./project/' + elem.val() + '/check').success(
function(data, status, headers, config) {
Expand Down

0 comments on commit 182f53b

Please sign in to comment.