Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pull out json module, remove product specific names from crud interfa… #5

Merged
merged 1 commit into from
Dec 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openmbee.sdvc.sysml;
package org.openmbee.sdvc.cameo;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openmbee.sdvc.sysml;
package org.openmbee.sdvc.cameo;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openmbee.sdvc.sysml;
package org.openmbee.sdvc.cameo;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.openmbee.sdvc.sysml.controllers;
package org.openmbee.sdvc.cameo.controllers;

import org.openmbee.sdvc.sysml.services.CameoNodeService;
import org.openmbee.sdvc.cameo.services.CameoNodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.openmbee.sdvc.sysml.controllers;
package org.openmbee.sdvc.cameo.controllers;

import org.openmbee.sdvc.crud.controllers.BaseController;
import org.openmbee.sdvc.sysml.services.CameoNodeService;
import org.openmbee.sdvc.cameo.services.CameoNodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.openmbee.sdvc.cameo.services;

import org.openmbee.sdvc.json.ElementJson;
import org.openmbee.sdvc.cameo.CameoNodeType;
import org.springframework.stereotype.Component;

@Component
public class CameoHelper {

public static CameoNodeType getNodeType(ElementJson e) {
return CameoNodeType.PACKAGE;
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openmbee.sdvc.sysml.services;
package org.openmbee.sdvc.cameo.services;

import java.time.Instant;
import java.util.ArrayList;
Expand All @@ -7,14 +7,13 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.openmbee.sdvc.crud.controllers.commits.CommitJson;
import org.openmbee.sdvc.crud.controllers.elements.ElementJson;
import org.openmbee.sdvc.crud.controllers.elements.ElementsRequest;
import org.openmbee.sdvc.json.CommitJson;
import org.openmbee.sdvc.json.ElementJson;
import org.openmbee.sdvc.crud.controllers.elements.ElementsResponse;
import org.openmbee.sdvc.crud.domains.EdgeType;
import org.openmbee.sdvc.crud.domains.Node;
import org.openmbee.sdvc.crud.services.DefaultNodeService;
import org.openmbee.sdvc.crud.services.NodeService;
import org.openmbee.sdvc.cameo.CameoEdgeType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.util.Pair;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -42,19 +41,19 @@ public void extraProcessPostedElement(ElementJson element, Node node,
Set<String> oldElasticIds, CommitJson cmjs, Instant now, Map<String, Node> toSave,
Map<String, ElementJson> response) {

node.setNodeType(CameoHelper.getNodeType(element));
node.setNodeType(CameoHelper.getNodeType(element).getValue());
}

@Override
public Map<EdgeType, List<Pair<String, String>>> getEdgeInfo(Collection<ElementJson> elements) {
Map<EdgeType, List<Pair<String, String>>> res = new HashMap<>();
public Map<Integer, List<Pair<String, String>>> getEdgeInfo(Collection<ElementJson> elements) {
Map<Integer, List<Pair<String, String>>> res = new HashMap<>();
for (ElementJson e: elements) {
String owner = (String) e.get("ownerId");
if (owner != null && !owner.isEmpty()) {
if (!res.containsKey(EdgeType.CONTAINMENT)) {
res.put(EdgeType.CONTAINMENT, new ArrayList<>());
if (!res.containsKey(CameoEdgeType.CONTAINMENT.getValue())) {
res.put(CameoEdgeType.CONTAINMENT.getValue(), new ArrayList<>());
}
res.get(EdgeType.CONTAINMENT).add(Pair.of(owner, e.getId()));
res.get(CameoEdgeType.CONTAINMENT.getValue()).add(Pair.of(owner, e.getId()));
}
}
//TODO when to delete existing edges
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.openmbee.sdvc.sysml.services;
package org.openmbee.sdvc.cameo.services;

import org.openmbee.sdvc.crud.controllers.projects.ProjectJson;
import org.openmbee.sdvc.json.ProjectJson;
import org.openmbee.sdvc.crud.services.DefaultProjectService;
import org.openmbee.sdvc.crud.services.ProjectService;
import org.springframework.stereotype.Service;
Expand All @@ -10,7 +10,7 @@
public class CameoProjectService extends DefaultProjectService implements ProjectService {

public ProjectJson post(ProjectJson projectsPost) {
//TODO create elastic index with sysml specific mapping
//TODO create elastic index with cameo specific mapping
return super.post(projectsPost);
}
}
2 changes: 1 addition & 1 deletion crud/crud.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'io.spring.convention.spring-module'

dependencies {
compile project(':core')
compile project(':uml')
compile project(':json')
compile group: 'org.springframework', name: 'spring-jdbc', version: '5.0.8.RELEASE'
compile 'org.elasticsearch:elasticsearch:6.5.1'
compile 'org.elasticsearch.client:elasticsearch-rest-high-level-client:6.5.1'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package org.openmbee.sdvc.crud.controllers;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public abstract class BaseController {

protected final Logger logger = LogManager.getLogger(getClass());
protected final ObjectMapper om = new ObjectMapper();
}
108 changes: 0 additions & 108 deletions crud/src/main/java/org/openmbee/sdvc/crud/controllers/BaseJson.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.openmbee.sdvc.crud.repositories.branch.BranchDAO;
import org.openmbee.sdvc.crud.repositories.commit.CommitDAO;
import org.openmbee.sdvc.crud.services.DatabaseDefinitionService;
import org.openmbee.sdvc.json.RefJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
Expand Down Expand Up @@ -50,7 +51,7 @@ public ResponseEntity<? extends BaseResponse> handleRequest(
Branch b = new Branch();
b.setBranchId(branch.getId());
b.setBranchName(branch.getName());
b.setElasticId("blah");
b.setDescription("blah");
b.setTimestamp(Instant.now());
logger.info("Saving branch: {}", branch.getId());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;
import org.openmbee.sdvc.crud.controllers.BaseRequest;
import org.openmbee.sdvc.json.RefJson;

public class BranchesRequest extends BaseRequest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;
import org.openmbee.sdvc.crud.controllers.BaseResponse;
import org.openmbee.sdvc.crud.controllers.Constants;
import org.openmbee.sdvc.json.RefJson;

public class BranchesResponse extends BaseResponse {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;
import org.openmbee.sdvc.crud.controllers.BaseRequest;
import org.openmbee.sdvc.json.CommitJson;

public class CommitsRequest extends BaseRequest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;
import org.openmbee.sdvc.crud.controllers.BaseResponse;
import org.openmbee.sdvc.crud.controllers.Constants;
import org.openmbee.sdvc.json.CommitJson;

public class CommitsResponse extends BaseResponse {

Expand All @@ -18,5 +19,4 @@ public List<CommitJson> getCommits() {
public void setCommits(List<CommitJson> commits) {
this.put(Constants.COMMIT_KEY, commits);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;
import org.openmbee.sdvc.crud.controllers.BaseRequest;
import org.openmbee.sdvc.json.ElementJson;

public class ElementsRequest extends BaseRequest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;
import org.openmbee.sdvc.crud.controllers.BaseResponse;
import org.openmbee.sdvc.crud.controllers.Constants;
import org.openmbee.sdvc.json.ElementJson;

public class ElementsResponse extends BaseResponse {

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;
import org.openmbee.sdvc.crud.controllers.BaseRequest;
import org.openmbee.sdvc.json.OrgJson;

public class OrganizationsRequest extends BaseRequest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;
import org.openmbee.sdvc.crud.controllers.BaseResponse;
import org.openmbee.sdvc.crud.controllers.Constants;
import org.openmbee.sdvc.json.OrgJson;

public class OrganizationsResponse extends BaseResponse {

Expand Down
Loading