From 4e29c1eed57fbcd982c38bd96348b0b183f7820c Mon Sep 17 00:00:00 2001 From: gfraboni Date: Fri, 1 Sep 2017 16:39:10 -0400 Subject: New endpoints to auto populate edge properties. New endpoints created to allow v11 endpoints to have their properties automatically set based on db edge rules. Issue-Id: AAI-60 Change-Id: I9b41f654fa9924b1dcb863aca369725a763b3691 Signed-off-by: gfraboni --- .../org/openecomp/crud/dao/champ/ChampDao.java | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/main/java/org/openecomp/crud/dao/champ/ChampDao.java') diff --git a/src/main/java/org/openecomp/crud/dao/champ/ChampDao.java b/src/main/java/org/openecomp/crud/dao/champ/ChampDao.java index 5e9d10a..31bc9ab 100644 --- a/src/main/java/org/openecomp/crud/dao/champ/ChampDao.java +++ b/src/main/java/org/openecomp/crud/dao/champ/ChampDao.java @@ -95,6 +95,40 @@ public class ChampDao implements GraphDao { this.champApi = champGraph; } + @Override + public Vertex getVertex(String id) throws CrudException { + + try { + + if (logger.isDebugEnabled()) { + logger.debug("getVertex with id: " + id); + } + + long idAsLong = Long.parseLong(id); + + Optional retrievedVertex = champApi.retrieveObject(idAsLong); + + String nodeType = org.openecomp.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(); + if(retrievedVertex.isPresent() && + retrievedVertex.get().getProperties().get(nodeType)!=null) { + return vertexFromChampObject(retrievedVertex.get(), + retrievedVertex.get().getProperties().get(nodeType).toString()); + } else { + + // We didn't find a vertex with the supplied id, so just throw an + // exception. + throw new CrudException("No vertex with id " + id + " found in graph", + javax.ws.rs.core.Response.Status.NOT_FOUND); + } + + } catch (ChampUnmarshallingException | ChampTransactionException e) { + + // Something went wrong - throw an exception. + throw new CrudException(e.getMessage(), + javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR); + } + } + @Override public Vertex getVertex(String id, String type) throws CrudException { -- cgit 1.2.3-korg