From 12687d3e4f4f785074615cdc95b707f1192853f0 Mon Sep 17 00:00:00 2001 From: sebdet Date: Tue, 6 Aug 2019 14:32:55 +0200 Subject: Add Expose annotation Add expose annotations in all objects returned by the v1 interfaces Issue-ID: CLAMP-465 Change-Id: I9c98de60dc71f52f74f14810135e83efe4256ede Signed-off-by: sebdet --- .../org/onap/clamp/clds/model/CldsDictionary.java | 285 ++--- .../onap/clamp/clds/model/CldsDictionaryItem.java | 399 +++---- .../java/org/onap/clamp/clds/model/CldsInfo.java | 155 +-- .../java/org/onap/clamp/clds/model/CldsModel.java | 1146 ++++++++++---------- .../org/onap/clamp/clds/model/CldsTemplate.java | 335 +++--- .../org/onap/clamp/clds/model/CldsToscaModel.java | 9 +- .../java/org/onap/clamp/clds/model/DcaeEvent.java | 291 ++--- .../java/org/onap/clamp/clds/model/ValueItem.java | 64 +- 8 files changed, 1394 insertions(+), 1290 deletions(-) (limited to 'src/main/java/org/onap') diff --git a/src/main/java/org/onap/clamp/clds/model/CldsDictionary.java b/src/main/java/org/onap/clamp/clds/model/CldsDictionary.java index 40e547a9c..a696494e5 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsDictionary.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsDictionary.java @@ -28,146 +28,161 @@ import java.util.List; import org.onap.clamp.clds.dao.CldsDao; +import com.google.gson.annotations.Expose; + /** * Represents a CLDS Dictionary. */ public class CldsDictionary { - private String dictionaryId; - private String dictionaryName; - private String createdBy; - private String updatedBy; - private String lastUpdatedDate; - private List cldsDictionaryItems = new ArrayList<>(); - - /** - * Creates or updates dictionary item for a dictionary in DB. - * - * @param dictionaryName The dictionary name - * @param cldsDao The CldsDao - * @param userId The user ID - */ - public void save(String dictionaryName, CldsDao cldsDao, String userId) { - List list = cldsDao.getDictionary(this.getDictionaryId(), dictionaryName); - if (list != null && !list.isEmpty()) { - CldsDictionary cldsDictionary = list.stream().findFirst().get(); - if (!cldsDictionary.getDictionaryName().equalsIgnoreCase(this.getDictionaryName())) { - cldsDao.updateDictionary(cldsDictionary.getDictionaryId(), this, userId); - this.setCreatedBy(cldsDictionary.getCreatedBy()); - } else { - this.setDictionaryId(cldsDictionary.getDictionaryId()); - this.setCreatedBy(cldsDictionary.getCreatedBy()); - this.setUpdatedBy(cldsDictionary.getUpdatedBy()); - this.setLastUpdatedDate(cldsDictionary.getLastUpdatedDate()); - } - } else { - this.setCreatedBy(userId); - this.setUpdatedBy(userId); - cldsDao.insDictionary(this); - } - } - - /** - * Get the dictionary ID. - * @return the dictionaryId - */ - public String getDictionaryId() { - return dictionaryId; - } - - /** - * Set the dictionary Id. - * @param dictionaryId - * the dictionaryId to set - */ - public void setDictionaryId(String dictionaryId) { - this.dictionaryId = dictionaryId; - } - - /** - * Get the dictionary name. - * @return the dictionaryName - */ - public String getDictionaryName() { - return dictionaryName; - } - - /** - * Set the dictionary name. - * @param dictionaryName - * the dictionaryName to set - */ - public void setDictionaryName(String dictionaryName) { - this.dictionaryName = dictionaryName; - } - - /** - * Get the createdBy info. - * @return the createdBy - */ - public String getCreatedBy() { - return createdBy; - } - - /** - * Set the createdBy info. - * @param createdBy - * the createdBy to set - */ - public void setCreatedBy(String createdBy) { - this.createdBy = createdBy; - } - - /** - * Get the updatedBy info. - * @return the updatedBy - */ - public String getUpdatedBy() { - return updatedBy; - } - - /** - * Set the updatedBy info. - * @param updatedby - * the updatedBy to set - */ - public void setUpdatedBy(String updatedby) { - updatedBy = updatedby; - } - - /** - * Get the last updated date. - * @return the lastUpdatedDate - */ - public String getLastUpdatedDate() { - return lastUpdatedDate; - } - - /** - * Set the last updated date. - * @param lastUpdatedDate - * the lastUpdatedDate to set - */ - public void setLastUpdatedDate(String lastUpdatedDate) { - this.lastUpdatedDate = lastUpdatedDate; - } - - /** - * Get all the dictionary items. - * @return the cldsDictionaryItems - */ - public List getCldsDictionaryItems() { - return cldsDictionaryItems; - } - - /** - * Set the whole dictionary items. - * @param cldsDictionaryItems - * the cldsDictionaryItems to set - */ - public void setCldsDictionaryItems(List cldsDictionaryItems) { - this.cldsDictionaryItems = cldsDictionaryItems; - } + @Expose + private String dictionaryId; + @Expose + private String dictionaryName; + + @Expose + private String createdBy; + @Expose + private String updatedBy; + @Expose + private String lastUpdatedDate; + @Expose + private List cldsDictionaryItems = new ArrayList<>(); + + /** + * Creates or updates dictionary item for a dictionary in DB. + * + * @param dictionaryName The dictionary name + * @param cldsDao The CldsDao + * @param userId The user ID + */ + public void save(String dictionaryName, CldsDao cldsDao, String userId) { + List list = cldsDao.getDictionary(this.getDictionaryId(), dictionaryName); + if (list != null && !list.isEmpty()) { + CldsDictionary cldsDictionary = list.stream().findFirst().get(); + if (!cldsDictionary.getDictionaryName().equalsIgnoreCase(this.getDictionaryName())) { + cldsDao.updateDictionary(cldsDictionary.getDictionaryId(), this, userId); + this.setCreatedBy(cldsDictionary.getCreatedBy()); + } else { + this.setDictionaryId(cldsDictionary.getDictionaryId()); + this.setCreatedBy(cldsDictionary.getCreatedBy()); + this.setUpdatedBy(cldsDictionary.getUpdatedBy()); + this.setLastUpdatedDate(cldsDictionary.getLastUpdatedDate()); + } + } else { + this.setCreatedBy(userId); + this.setUpdatedBy(userId); + cldsDao.insDictionary(this); + } + } + + /** + * Get the dictionary ID. + * + * @return the dictionaryId + */ + public String getDictionaryId() { + return dictionaryId; + } + + /** + * Set the dictionary Id. + * + * @param dictionaryId the dictionaryId to set + */ + public void setDictionaryId(String dictionaryId) { + this.dictionaryId = dictionaryId; + } + + /** + * Get the dictionary name. + * + * @return the dictionaryName + */ + public String getDictionaryName() { + return dictionaryName; + } + + /** + * Set the dictionary name. + * + * @param dictionaryName the dictionaryName to set + */ + public void setDictionaryName(String dictionaryName) { + this.dictionaryName = dictionaryName; + } + + /** + * Get the createdBy info. + * + * @return the createdBy + */ + public String getCreatedBy() { + return createdBy; + } + + /** + * Set the createdBy info. + * + * @param createdBy the createdBy to set + */ + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + /** + * Get the updatedBy info. + * + * @return the updatedBy + */ + public String getUpdatedBy() { + return updatedBy; + } + + /** + * Set the updatedBy info. + * + * @param updatedby the updatedBy to set + */ + public void setUpdatedBy(String updatedby) { + updatedBy = updatedby; + } + + /** + * Get the last updated date. + * + * @return the lastUpdatedDate + */ + public String getLastUpdatedDate() { + return lastUpdatedDate; + } + + /** + * Set the last updated date. + * + * @param lastUpdatedDate the lastUpdatedDate to set + */ + public void setLastUpdatedDate(String lastUpdatedDate) { + this.lastUpdatedDate = lastUpdatedDate; + } + + /** + * Get all the dictionary items. + * + * @return the cldsDictionaryItems + */ + public List getCldsDictionaryItems() { + return cldsDictionaryItems; + } + + /** + * Set the whole dictionary items. + * + * @param cldsDictionaryItems the cldsDictionaryItems to set + */ + public void setCldsDictionaryItems(List cldsDictionaryItems) { + this.cldsDictionaryItems = cldsDictionaryItems; + } } diff --git a/src/main/java/org/onap/clamp/clds/model/CldsDictionaryItem.java b/src/main/java/org/onap/clamp/clds/model/CldsDictionaryItem.java index 871fe9037..605ede321 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsDictionaryItem.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsDictionaryItem.java @@ -27,199 +27,220 @@ import java.util.List; import org.onap.clamp.clds.dao.CldsDao; +import com.google.gson.annotations.Expose; + /** * Represents a CLDS Dictionary Item. */ public class CldsDictionaryItem { - private String dictElementId; - private String dictionaryId; - private String dictElementName; - private String dictElementShortName; - private String dictElementDesc; - private String dictElementType; - private String createdBy; - private String updatedBy; - private String lastUpdatedDate; - - /** - * Save the dictionary item. - * @param dictionaryName The name of the dictionary - * @param cldsDao The cldsDao - * @param userId The user id - */ - public void save(String dictionaryName, CldsDao cldsDao, String userId) { - // Check if dictionary exists. - List list = cldsDao.getDictionary(this.getDictionaryId(), dictionaryName); - if (list != null && !list.isEmpty()) { - // Dictionary found. We can add or update the dictionary element - CldsDictionary cldsDictionary = list.stream().findFirst().get(); - List dictionaryItems = cldsDao.getDictionaryElements(dictionaryName, - cldsDictionary.getDictionaryId(), this.getDictElementShortName()); - if (dictionaryItems != null && !dictionaryItems.isEmpty()) { - CldsDictionaryItem item = dictionaryItems.stream().findFirst().get(); - cldsDao.updateDictionaryElements(item.getDictElementId(), this, userId); - this.setCreatedBy(item.getCreatedBy()); - - } else { - this.setCreatedBy(userId); - this.setUpdatedBy(userId); - cldsDao.insDictionarElements(this, userId); - } - } - } - - /** - * Get the dictionary element id. - * @return the dictElementId - */ - public String getDictElementId() { - return dictElementId; - } - - /** - * Set the dictionary element id. - * @param dictElementId - * the dictElementId to set - */ - public void setDictElementId(String dictElementId) { - this.dictElementId = dictElementId; - } - - /** - * Get the dictionary id. - * @return the dictionaryId - */ - public String getDictionaryId() { - return dictionaryId; - } - - /** - * Set the dictionary id. - * @param dictionaryId - * the dictionaryId to set - */ - public void setDictionaryId(String dictionaryId) { - this.dictionaryId = dictionaryId; - } - - /** - * Get the dictionary name. - * @return the dictElementName - */ - public String getDictElementName() { - return dictElementName; - } - - /** - * Set the dictionary name. - * @param dictElementName - * the dictElementName to set - */ - public void setDictElementName(String dictElementName) { - this.dictElementName = dictElementName; - } - - /** - * Get the dictionary element short name. - * @return the dictElementShortName - */ - public String getDictElementShortName() { - return dictElementShortName; - } - - /** - * Set the dictionary element short name. - * @param dictElementShortName - * the dictElementShortName to set - */ - public void setDictElementShortName(String dictElementShortName) { - this.dictElementShortName = dictElementShortName; - } - - /** - * Get the dictionary element description. - * @return the dictElementDesc - */ - public String getDictElementDesc() { - return dictElementDesc; - } - - /** - * Set the dictionary element description. - * @param dictElementDesc - * the dictElementDesc to set - */ - public void setDictElementDesc(String dictElementDesc) { - this.dictElementDesc = dictElementDesc; - } - - /** - * Get the dictionary element type. - * @return the dictElementType - */ - public String getDictElementType() { - return dictElementType; - } - - /** - * Set the dictionary element type. - * @param dictElementType - * the dictElementType to set - */ - public void setDictElementType(String dictElementType) { - this.dictElementType = dictElementType; - } - - /** - * Get the createdBy info. - * @return the createdBy - */ - public String getCreatedBy() { - return createdBy; - } - - /** - * Set the createdBy info. - * @param createdBy - * the createdBy to set - */ - public void setCreatedBy(String createdBy) { - this.createdBy = createdBy; - } - - /** - * Get the updatedBy info. - * @return the updatedBy - */ - public String getUpdatedBy() { - return updatedBy; - } - - /** - * Set the updatedBy info. - * @param updatedby - * the updatedBy to set - */ - public void setUpdatedBy(String updatedby) { - updatedBy = updatedby; - } - - /** - * Get the last updated date. - * @return the lastUpdatedDate - */ - public String getLastUpdatedDate() { - return lastUpdatedDate; - } - - /** - * Set the last updated date. - * @param lastUpdatedDate - * the lastUpdatedDate to set - */ - public void setLastUpdatedDate(String lastUpdatedDate) { - this.lastUpdatedDate = lastUpdatedDate; - } + @Expose + private String dictElementId; + @Expose + private String dictionaryId; + @Expose + private String dictElementName; + @Expose + private String dictElementShortName; + @Expose + private String dictElementDesc; + @Expose + private String dictElementType; + @Expose + private String createdBy; + @Expose + private String updatedBy; + @Expose + private String lastUpdatedDate; + + /** + * Save the dictionary item. + * + * @param dictionaryName The name of the dictionary + * @param cldsDao The cldsDao + * @param userId The user id + */ + public void save(String dictionaryName, CldsDao cldsDao, String userId) { + // Check if dictionary exists. + List list = cldsDao.getDictionary(this.getDictionaryId(), dictionaryName); + if (list != null && !list.isEmpty()) { + // Dictionary found. We can add or update the dictionary element + CldsDictionary cldsDictionary = list.stream().findFirst().get(); + List dictionaryItems = cldsDao.getDictionaryElements(dictionaryName, + cldsDictionary.getDictionaryId(), this.getDictElementShortName()); + if (dictionaryItems != null && !dictionaryItems.isEmpty()) { + CldsDictionaryItem item = dictionaryItems.stream().findFirst().get(); + cldsDao.updateDictionaryElements(item.getDictElementId(), this, userId); + this.setCreatedBy(item.getCreatedBy()); + + } else { + this.setCreatedBy(userId); + this.setUpdatedBy(userId); + cldsDao.insDictionarElements(this, userId); + } + } + } + + /** + * Get the dictionary element id. + * + * @return the dictElementId + */ + public String getDictElementId() { + return dictElementId; + } + + /** + * Set the dictionary element id. + * + * @param dictElementId the dictElementId to set + */ + public void setDictElementId(String dictElementId) { + this.dictElementId = dictElementId; + } + + /** + * Get the dictionary id. + * + * @return the dictionaryId + */ + public String getDictionaryId() { + return dictionaryId; + } + + /** + * Set the dictionary id. + * + * @param dictionaryId the dictionaryId to set + */ + public void setDictionaryId(String dictionaryId) { + this.dictionaryId = dictionaryId; + } + + /** + * Get the dictionary name. + * + * @return the dictElementName + */ + public String getDictElementName() { + return dictElementName; + } + + /** + * Set the dictionary name. + * + * @param dictElementName the dictElementName to set + */ + public void setDictElementName(String dictElementName) { + this.dictElementName = dictElementName; + } + + /** + * Get the dictionary element short name. + * + * @return the dictElementShortName + */ + public String getDictElementShortName() { + return dictElementShortName; + } + + /** + * Set the dictionary element short name. + * + * @param dictElementShortName the dictElementShortName to set + */ + public void setDictElementShortName(String dictElementShortName) { + this.dictElementShortName = dictElementShortName; + } + + /** + * Get the dictionary element description. + * + * @return the dictElementDesc + */ + public String getDictElementDesc() { + return dictElementDesc; + } + + /** + * Set the dictionary element description. + * + * @param dictElementDesc the dictElementDesc to set + */ + public void setDictElementDesc(String dictElementDesc) { + this.dictElementDesc = dictElementDesc; + } + + /** + * Get the dictionary element type. + * + * @return the dictElementType + */ + public String getDictElementType() { + return dictElementType; + } + + /** + * Set the dictionary element type. + * + * @param dictElementType the dictElementType to set + */ + public void setDictElementType(String dictElementType) { + this.dictElementType = dictElementType; + } + + /** + * Get the createdBy info. + * + * @return the createdBy + */ + public String getCreatedBy() { + return createdBy; + } + + /** + * Set the createdBy info. + * + * @param createdBy the createdBy to set + */ + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + /** + * Get the updatedBy info. + * + * @return the updatedBy + */ + public String getUpdatedBy() { + return updatedBy; + } + + /** + * Set the updatedBy info. + * + * @param updatedby the updatedBy to set + */ + public void setUpdatedBy(String updatedby) { + updatedBy = updatedby; + } + + /** + * Get the last updated date. + * + * @return the lastUpdatedDate + */ + public String getLastUpdatedDate() { + return lastUpdatedDate; + } + + /** + * Set the last updated date. + * + * @param lastUpdatedDate the lastUpdatedDate to set + */ + public void setLastUpdatedDate(String lastUpdatedDate) { + this.lastUpdatedDate = lastUpdatedDate; + } } diff --git a/src/main/java/org/onap/clamp/clds/model/CldsInfo.java b/src/main/java/org/onap/clamp/clds/model/CldsInfo.java index a24885f73..cf4be7fe1 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsInfo.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsInfo.java @@ -23,79 +23,88 @@ package org.onap.clamp.clds.model; -public class CldsInfo { +import com.google.gson.annotations.Expose; - private String userName; - private String cldsVersion; - private boolean permissionReadCl; - private boolean permissionUpdateCl; - private boolean permissionReadTemplate; - private boolean permissionUpdateTemplate; - private boolean permissionReadTosca; - private boolean permissionUpdateTosca; - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getCldsVersion() { - return cldsVersion; - } - - public void setCldsVersion(String cldsVersion) { - this.cldsVersion = cldsVersion; - } - - public boolean isPermissionReadCl() { - return permissionReadCl; - } - - public void setPermissionReadCl(boolean permissionReadCl) { - this.permissionReadCl = permissionReadCl; - } - - public boolean isPermissionUpdateCl() { - return permissionUpdateCl; - } - - public void setPermissionUpdateCl(boolean permissionUpdateCl) { - this.permissionUpdateCl = permissionUpdateCl; - } - - public boolean isPermissionReadTemplate() { - return permissionReadTemplate; - } - - public void setPermissionReadTemplate(boolean permissionReadTemplate) { - this.permissionReadTemplate = permissionReadTemplate; - } - - public boolean isPermissionUpdateTemplate() { - return permissionUpdateTemplate; - } - - public void setPermissionUpdateTemplate(boolean permissionUpdateTemplate) { - this.permissionUpdateTemplate = permissionUpdateTemplate; - } - - public boolean isPermissionReadTosca() { - return permissionReadTosca; - } - - public void setPermissionReadTosca(boolean permissionReadTosca) { - this.permissionReadTosca = permissionReadTosca; - } - - public boolean isPermissionUpdateTosca() { - return permissionUpdateTosca; - } - - public void setPermissionUpdateTosca(boolean permissionUpdateTosca) { - this.permissionUpdateTosca = permissionUpdateTosca; - } +public class CldsInfo { + @Expose + private String userName; + @Expose + private String cldsVersion; + @Expose + private boolean permissionReadCl; + @Expose + private boolean permissionUpdateCl; + @Expose + private boolean permissionReadTemplate; + @Expose + private boolean permissionUpdateTemplate; + @Expose + private boolean permissionReadTosca; + @Expose + private boolean permissionUpdateTosca; + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getCldsVersion() { + return cldsVersion; + } + + public void setCldsVersion(String cldsVersion) { + this.cldsVersion = cldsVersion; + } + + public boolean isPermissionReadCl() { + return permissionReadCl; + } + + public void setPermissionReadCl(boolean permissionReadCl) { + this.permissionReadCl = permissionReadCl; + } + + public boolean isPermissionUpdateCl() { + return permissionUpdateCl; + } + + public void setPermissionUpdateCl(boolean permissionUpdateCl) { + this.permissionUpdateCl = permissionUpdateCl; + } + + public boolean isPermissionReadTemplate() { + return permissionReadTemplate; + } + + public void setPermissionReadTemplate(boolean permissionReadTemplate) { + this.permissionReadTemplate = permissionReadTemplate; + } + + public boolean isPermissionUpdateTemplate() { + return permissionUpdateTemplate; + } + + public void setPermissionUpdateTemplate(boolean permissionUpdateTemplate) { + this.permissionUpdateTemplate = permissionUpdateTemplate; + } + + public boolean isPermissionReadTosca() { + return permissionReadTosca; + } + + public void setPermissionReadTosca(boolean permissionReadTosca) { + this.permissionReadTosca = permissionReadTosca; + } + + public boolean isPermissionUpdateTosca() { + return permissionUpdateTosca; + } + + public void setPermissionUpdateTosca(boolean permissionUpdateTosca) { + this.permissionUpdateTosca = permissionUpdateTosca; + } } diff --git a/src/main/java/org/onap/clamp/clds/model/CldsModel.java b/src/main/java/org/onap/clamp/clds/model/CldsModel.java index 223d38929..0b414807c 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsModel.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsModel.java @@ -37,572 +37,594 @@ import org.onap.clamp.clds.model.actions.ActionsHandler; import org.onap.clamp.clds.model.actions.ActionsHandlerImpl; import org.onap.clamp.clds.model.status.StatusHandler; import org.onap.clamp.clds.model.status.StatusHandlerImpl; +import com.google.gson.annotations.Expose; /** * Represent a CLDS Model. */ public class CldsModel { - private static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsModel.class); - private static final int UUID_LENGTH = 36; - /** - * The constant STATUS_DESIGN. - */ - public static final String STATUS_DESIGN = "DESIGN"; - /** - * The constant STATUS_DISTRIBUTED. - */ - public static final String STATUS_DISTRIBUTED = "DISTRIBUTED"; - /** - * The constant STATUS_ACTIVE. - */ - public static final String STATUS_ACTIVE = "ACTIVE"; - /** - * The constant STATUS_STOPPED. - */ - public static final String STATUS_STOPPED = "STOPPED"; - /** - * The constant STATUS_DELETING. - */ - public static final String STATUS_DELETING = "DELETING"; - /** - * The constant STATUS_ERROR. - */ - public static final String STATUS_ERROR = "ERROR"; - /** - * The constant STATUS_UNKNOWN. - */ - public static final String STATUS_UNKNOWN = "UNKNOWN"; - private String id; - private String templateId; - private String templateName; - private String name; - private String controlNamePrefix; - private String controlNameUuid; - private String bpmnText; - private String propText; - private String imageText; - private String docText; - private String blueprintText; - private CldsEvent event; - private String status; - private List permittedActionCd; - private List cldsModelInstanceList; - // This is a transient value used to return the failure message to UI - private String errorMessageForUi; - /** - * The service type Id received from DCAE by querying it. - */ - private String typeId; - private String typeName; - private String deploymentId; - private String deploymentStatusUrl; - - // Set default handlers but this can be changed if needed. - private static StatusHandler statusHandler = new StatusHandlerImpl(); - private static ActionsHandler actionsHandler = new ActionsHandlerImpl(); - - /** - * Sets status handler. - * - * @param statHandler the stat handler - */ - public static synchronized void setStatusHandler(StatusHandler statHandler) { - statusHandler = statHandler; - } - - /** - * Sets actions handler. - * - * @param cdHandler the cd handler - */ - public static synchronized void setActionsHandler(ActionsHandler cdHandler) { - actionsHandler = cdHandler; - } - - /** - * Construct empty model. - */ - public CldsModel() { - event = new CldsEvent(); - } - - /** - * Retrieve from DB. - * - * @param cldsDao the clds dao - * @param name the name - * @param okIfNotFound the ok if not found - * @return the clds model - */ - public static CldsModel retrieve(CldsDao cldsDao, String name, boolean okIfNotFound) { - // get from db - CldsModel model = cldsDao.getModelTemplate(name); - if (model.getId() == null && !okIfNotFound) { - throw new NotFoundException(); - } - model.determineStatus(); - model.determinePermittedActionCd(); - return model; - } - - /** - * Can dcae inventory call boolean. - * - * @return the boolean - */ - public boolean canDcaeInventoryCall() { - boolean canCall = false; - /* Below checks the clds event is submit/resubmit/distribute */ - if (event.isActionCd(CldsEvent.ACTION_SUBMIT) || event.isActionCd(CldsEvent.ACTION_RESUBMIT) - || event.isActionCd(CldsEvent.ACTION_DISTRIBUTE) || event.isActionCd(CldsEvent.ACTION_SUBMITDCAE)) { - canCall = true; - } - return canCall; - } - - /** - * Save model to DB. - * - * @param cldsDao the clds dao - * @param userid the userid - * @return the clds model - */ - public CldsModel save(CldsDao cldsDao, String userid) { - CldsModel cldsModel = cldsDao.setModel(this, userid); - determineStatus(); - determinePermittedActionCd(); - return cldsModel; - } - - /** - * set the status in the model. - */ - public void determineStatus() { - status = statusHandler.determineStatusOnLastEvent(event); - } - - /** - * Determine permittedActionCd list using the actionCd from the current event. - * It's a states graph, given the next action that can be executed from the one - * that has been executed (described in the event object). ACTION_CREATE being - * the first one. - */ - public void determinePermittedActionCd() { - permittedActionCd = actionsHandler.determinePermittedActionsOnLastEvent(event, propText); - } - - /** - * Validate requestedActionCd - determine permittedActionCd and then check if - * contained in permittedActionCd Throw IllegalArgumentException if requested - * actionCd is not permitted. - * - * @param requestedActionCd the requested action cd - */ - public void validateAction(String requestedActionCd) { - determinePermittedActionCd(); - if (!permittedActionCd.contains(requestedActionCd)) { - throw new IllegalArgumentException( - "Invalid requestedActionCd: " + requestedActionCd + ". Given current actionCd: " - + actionsHandler.getCurrentActionCd(event) + ", the permittedActionCd: " + permittedActionCd); - } - } - - /** - * Extract the UUID portion of a given full control name (controlNamePrefix + - * controlNameUuid). No fields are populated other than controlNamePrefix and - * controlNameUuid. Throws BadRequestException if length of given control name - * is less than UUID_LENGTH. - * - * @param fullControlName the full control name - * @return the clds model - */ - public static CldsModel createUsingControlName(String fullControlName) { - if (fullControlName == null || fullControlName.length() < UUID_LENGTH) { - throw new BadRequestException( - "closed loop id / control name length, " + (fullControlName != null ? fullControlName.length() : 0) - + ", less than the minimum of: " + UUID_LENGTH); - } - CldsModel model = new CldsModel(); - model.setControlNamePrefix(fullControlName.substring(0, fullControlName.length() - UUID_LENGTH)); - model.setControlNameUuid(fullControlName.substring(fullControlName.length() - UUID_LENGTH)); - return model; - } - - /** - * Gets control name. - * - * @return the controlName (controlNamePrefix + controlNameUuid) - */ - public String getControlName() { - return controlNamePrefix + controlNameUuid; - } - - /** - * To insert modelInstance to the database. - * - * @param cldsDao the clds dao - * @param dcaeEvent the dcae event - * @param userid the userid - * @return the clds model - */ - public static CldsModel insertModelInstance(CldsDao cldsDao, DcaeEvent dcaeEvent, String userid) { - String controlName = dcaeEvent.getControlName(); - CldsModel cldsModel = createUsingControlName(controlName); - cldsModel = cldsDao.getModelByUuid(cldsModel.getControlNameUuid()); - cldsModel.determineStatus(); - if (dcaeEvent.getCldsActionCd().equals(CldsEvent.ACTION_UNDEPLOY) - || (dcaeEvent.getCldsActionCd().equals(CldsEvent.ACTION_DEPLOY) - && (cldsModel.getStatus().equals(STATUS_DISTRIBUTED) || cldsModel.getStatus().equals(STATUS_DESIGN)))) { - CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userid, dcaeEvent.getCldsActionCd(), - CldsEvent.ACTION_STATE_RECEIVED, null); - } - cldsDao.insModelInstance(cldsModel, dcaeEvent.getInstances()); - return cldsModel; - } - - /** - * Gets name. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Sets name. - * - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - - /** - * Gets type name. - * - * @return the typeName - */ - public String getTypeName() { - return typeName; - } - - /** - * Sets type name. - * - * @param typeName the type name - */ - public void setTypeName(String typeName) { - this.typeName = typeName; - } - - /** - * Gets template id. - * - * @return the template id - */ - public String getTemplateId() { - return templateId; - } - - /** - * Sets template id. - * - * @param templateId the template id - */ - public void setTemplateId(String templateId) { - this.templateId = templateId; - } - - /** - * Gets control name prefix. - * - * @return the controlNamePrefix - */ - public String getControlNamePrefix() { - return controlNamePrefix; - } - - /** - * Sets control name prefix. - * - * @param controlNamePrefix the controlNamePrefix to set - */ - public void setControlNamePrefix(String controlNamePrefix) { - this.controlNamePrefix = controlNamePrefix; - } - - /** - * Gets control name uuid. - * - * @return the controlNameUuid - */ - public String getControlNameUuid() { - return controlNameUuid; - } - - /** - * Sets control name uuid. - * - * @param controlNameUuid the controlNameUuid to set - */ - public void setControlNameUuid(String controlNameUuid) { - this.controlNameUuid = controlNameUuid; - } - - /** - * Gets prop text. - * - * @return the propText - */ - public String getPropText() { - return propText; - } - - /** - * Sets prop text. - * - * @param propText the propText to set - */ - public void setPropText(String propText) { - this.propText = propText; - } - - /** - * Gets event. - * - * @return the event - */ - public CldsEvent getEvent() { - return event; - } - - /** - * Gets id. - * - * @return the id - */ - public String getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(String id) { - this.id = id; - } - - /** - * Gets template name. - * - * @return the template name - */ - public String getTemplateName() { - return templateName; - } - - /** - * Sets template name. - * - * @param templateName the template name - */ - public void setTemplateName(String templateName) { - this.templateName = templateName; - } - - /** - * Sets event. - * - * @param event the event to set - */ - public void setEvent(CldsEvent event) { - this.event = event; - } - - /** - * Gets status. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * Sets status. - * - * @param status the status to set - */ - public void setStatus(String status) { - this.status = status; - } - - /** - * Gets blueprint text. - * - * @return the blueprint text - */ - public String getBlueprintText() { - return blueprintText; - } - - /** - * Sets blueprint text. - * - * @param blueprintText the blueprint text - */ - public void setBlueprintText(String blueprintText) { - this.blueprintText = blueprintText; - } - - /** - * Gets bpmn text. - * - * @return the bpmn text - */ - public String getBpmnText() { - return bpmnText; - } - - /** - * Sets bpmn text. - * - * @param bpmnText the bpmn text - */ - public void setBpmnText(String bpmnText) { - this.bpmnText = bpmnText; - } - - /** - * Gets image text. - * - * @return the image text - */ - public String getImageText() { - return imageText; - } - - /** - * Sets image text. - * - * @param imageText the image text - */ - public void setImageText(String imageText) { - this.imageText = imageText; - } - - /** - * Gets doc text. - * - * @return the doc text - */ - public String getDocText() { - return docText; - } - - /** - * Sets doc text. - * - * @param docText the doc text - */ - public void setDocText(String docText) { - this.docText = docText; - } - - /** - * Gets type id. - * - * @return the type id - */ - public String getTypeId() { - return typeId; - } - - /** - * Sets type id. - * - * @param typeId the type id - */ - public void setTypeId(String typeId) { - this.typeId = typeId; - } - - /** - * Gets clds model instance list. - * - * @return the clds model instance list - */ - public List getCldsModelInstanceList() { - if (cldsModelInstanceList == null) { - cldsModelInstanceList = new ArrayList<>(); - } - return cldsModelInstanceList; - } - - /** - * Gets deployment id. - * - * @return the deployment id - */ - public String getDeploymentId() { - return deploymentId; - } - - /** - * Sets deployment id. - * - * @param deploymentId the deployment id - */ - public void setDeploymentId(String deploymentId) { - this.deploymentId = deploymentId; - } - - /** - * Gets permitted action cd. - * - * @return the permitted action cd - */ - public List getPermittedActionCd() { - return permittedActionCd; - } - - /** - * Gets error message for ui. - * - * @return the error message for ui - */ - public String getErrorMessageForUi() { - return errorMessageForUi; - } - - /** - * Sets error message for ui. - * - * @param errorMessageForUi the error message for ui - */ - public void setErrorMessageForUi(String errorMessageForUi) { - this.errorMessageForUi = errorMessageForUi; - } - - /** - * Gets deployment status url. - * - * @return the deployment status url - */ - public String getDeploymentStatusUrl() { - return deploymentStatusUrl; - } - - /** - * Sets deployment status url. - * - * @param deploymentStatusUrl the deployment status url - */ - public void setDeploymentStatusUrl(String deploymentStatusUrl) { - this.deploymentStatusUrl = deploymentStatusUrl; - } + private static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsModel.class); + private static final int UUID_LENGTH = 36; + /** + * The constant STATUS_DESIGN. + */ + public static final String STATUS_DESIGN = "DESIGN"; + /** + * The constant STATUS_DISTRIBUTED. + */ + public static final String STATUS_DISTRIBUTED = "DISTRIBUTED"; + /** + * The constant STATUS_ACTIVE. + */ + public static final String STATUS_ACTIVE = "ACTIVE"; + /** + * The constant STATUS_STOPPED. + */ + public static final String STATUS_STOPPED = "STOPPED"; + /** + * The constant STATUS_DELETING. + */ + public static final String STATUS_DELETING = "DELETING"; + /** + * The constant STATUS_ERROR. + */ + public static final String STATUS_ERROR = "ERROR"; + /** + * The constant STATUS_UNKNOWN. + */ + public static final String STATUS_UNKNOWN = "UNKNOWN"; + + @Expose + private String id; + @Expose + private String templateId; + @Expose + private String templateName; + @Expose + private String name; + @Expose + private String controlNamePrefix; + @Expose + private String controlNameUuid; + @Expose + private String bpmnText; + @Expose + private String propText; + @Expose + private String imageText; + @Expose + private String docText; + @Expose + private String blueprintText; + @Expose + private CldsEvent event; + @Expose + private String status; + @Expose + private List permittedActionCd; + @Expose + private List cldsModelInstanceList; + // This is a transient value used to return the failure message to UI + @Expose + private String errorMessageForUi; + /** + * The service type Id received from DCAE by querying it. + */ + @Expose + private String typeId; + @Expose + private String typeName; + @Expose + private String deploymentId; + @Expose + private String deploymentStatusUrl; + + // Set default handlers but this can be changed if needed. + private static StatusHandler statusHandler = new StatusHandlerImpl(); + private static ActionsHandler actionsHandler = new ActionsHandlerImpl(); + + /** + * Sets status handler. + * + * @param statHandler the stat handler + */ + public static synchronized void setStatusHandler(StatusHandler statHandler) { + statusHandler = statHandler; + } + + /** + * Sets actions handler. + * + * @param cdHandler the cd handler + */ + public static synchronized void setActionsHandler(ActionsHandler cdHandler) { + actionsHandler = cdHandler; + } + + /** + * Construct empty model. + */ + public CldsModel() { + event = new CldsEvent(); + } + + /** + * Retrieve from DB. + * + * @param cldsDao the clds dao + * @param name the name + * @param okIfNotFound the ok if not found + * @return the clds model + */ + public static CldsModel retrieve(CldsDao cldsDao, String name, boolean okIfNotFound) { + // get from db + CldsModel model = cldsDao.getModelTemplate(name); + if (model.getId() == null && !okIfNotFound) { + throw new NotFoundException(); + } + model.determineStatus(); + model.determinePermittedActionCd(); + return model; + } + + /** + * Can dcae inventory call boolean. + * + * @return the boolean + */ + public boolean canDcaeInventoryCall() { + boolean canCall = false; + /* Below checks the clds event is submit/resubmit/distribute */ + if (event.isActionCd(CldsEvent.ACTION_SUBMIT) || event.isActionCd(CldsEvent.ACTION_RESUBMIT) + || event.isActionCd(CldsEvent.ACTION_DISTRIBUTE) || event.isActionCd(CldsEvent.ACTION_SUBMITDCAE)) { + canCall = true; + } + return canCall; + } + + /** + * Save model to DB. + * + * @param cldsDao the clds dao + * @param userid the userid + * @return the clds model + */ + public CldsModel save(CldsDao cldsDao, String userid) { + CldsModel cldsModel = cldsDao.setModel(this, userid); + determineStatus(); + determinePermittedActionCd(); + return cldsModel; + } + + /** + * set the status in the model. + */ + public void determineStatus() { + status = statusHandler.determineStatusOnLastEvent(event); + } + + /** + * Determine permittedActionCd list using the actionCd from the current event. + * It's a states graph, given the next action that can be executed from the one + * that has been executed (described in the event object). ACTION_CREATE being + * the first one. + */ + public void determinePermittedActionCd() { + permittedActionCd = actionsHandler.determinePermittedActionsOnLastEvent(event, propText); + } + + /** + * Validate requestedActionCd - determine permittedActionCd and then check if + * contained in permittedActionCd Throw IllegalArgumentException if requested + * actionCd is not permitted. + * + * @param requestedActionCd the requested action cd + */ + public void validateAction(String requestedActionCd) { + determinePermittedActionCd(); + if (!permittedActionCd.contains(requestedActionCd)) { + throw new IllegalArgumentException("Invalid requestedActionCd: " + requestedActionCd + + ". Given current actionCd: " + actionsHandler.getCurrentActionCd(event) + + ", the permittedActionCd: " + permittedActionCd); + } + } + + /** + * Extract the UUID portion of a given full control name (controlNamePrefix + + * controlNameUuid). No fields are populated other than controlNamePrefix and + * controlNameUuid. Throws BadRequestException if length of given control name + * is less than UUID_LENGTH. + * + * @param fullControlName the full control name + * @return the clds model + */ + public static CldsModel createUsingControlName(String fullControlName) { + if (fullControlName == null || fullControlName.length() < UUID_LENGTH) { + throw new BadRequestException( + "closed loop id / control name length, " + (fullControlName != null ? fullControlName.length() : 0) + + ", less than the minimum of: " + UUID_LENGTH); + } + CldsModel model = new CldsModel(); + model.setControlNamePrefix(fullControlName.substring(0, fullControlName.length() - UUID_LENGTH)); + model.setControlNameUuid(fullControlName.substring(fullControlName.length() - UUID_LENGTH)); + return model; + } + + /** + * Gets control name. + * + * @return the controlName (controlNamePrefix + controlNameUuid) + */ + public String getControlName() { + return controlNamePrefix + controlNameUuid; + } + + /** + * To insert modelInstance to the database. + * + * @param cldsDao the clds dao + * @param dcaeEvent the dcae event + * @param userid the userid + * @return the clds model + */ + public static CldsModel insertModelInstance(CldsDao cldsDao, DcaeEvent dcaeEvent, String userid) { + String controlName = dcaeEvent.getControlName(); + CldsModel cldsModel = createUsingControlName(controlName); + cldsModel = cldsDao.getModelByUuid(cldsModel.getControlNameUuid()); + cldsModel.determineStatus(); + if (dcaeEvent.getCldsActionCd().equals(CldsEvent.ACTION_UNDEPLOY) || (dcaeEvent.getCldsActionCd() + .equals(CldsEvent.ACTION_DEPLOY) + && (cldsModel.getStatus().equals(STATUS_DISTRIBUTED) || cldsModel.getStatus().equals(STATUS_DESIGN)))) { + CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userid, dcaeEvent.getCldsActionCd(), + CldsEvent.ACTION_STATE_RECEIVED, null); + } + cldsDao.insModelInstance(cldsModel, dcaeEvent.getInstances()); + return cldsModel; + } + + /** + * Gets name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * Gets type name. + * + * @return the typeName + */ + public String getTypeName() { + return typeName; + } + + /** + * Sets type name. + * + * @param typeName the type name + */ + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + /** + * Gets template id. + * + * @return the template id + */ + public String getTemplateId() { + return templateId; + } + + /** + * Sets template id. + * + * @param templateId the template id + */ + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + /** + * Gets control name prefix. + * + * @return the controlNamePrefix + */ + public String getControlNamePrefix() { + return controlNamePrefix; + } + + /** + * Sets control name prefix. + * + * @param controlNamePrefix the controlNamePrefix to set + */ + public void setControlNamePrefix(String controlNamePrefix) { + this.controlNamePrefix = controlNamePrefix; + } + + /** + * Gets control name uuid. + * + * @return the controlNameUuid + */ + public String getControlNameUuid() { + return controlNameUuid; + } + + /** + * Sets control name uuid. + * + * @param controlNameUuid the controlNameUuid to set + */ + public void setControlNameUuid(String controlNameUuid) { + this.controlNameUuid = controlNameUuid; + } + + /** + * Gets prop text. + * + * @return the propText + */ + public String getPropText() { + return propText; + } + + /** + * Sets prop text. + * + * @param propText the propText to set + */ + public void setPropText(String propText) { + this.propText = propText; + } + + /** + * Gets event. + * + * @return the event + */ + public CldsEvent getEvent() { + return event; + } + + /** + * Gets id. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(String id) { + this.id = id; + } + + /** + * Gets template name. + * + * @return the template name + */ + public String getTemplateName() { + return templateName; + } + + /** + * Sets template name. + * + * @param templateName the template name + */ + public void setTemplateName(String templateName) { + this.templateName = templateName; + } + + /** + * Sets event. + * + * @param event the event to set + */ + public void setEvent(CldsEvent event) { + this.event = event; + } + + /** + * Gets status. + * + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * Sets status. + * + * @param status the status to set + */ + public void setStatus(String status) { + this.status = status; + } + + /** + * Gets blueprint text. + * + * @return the blueprint text + */ + public String getBlueprintText() { + return blueprintText; + } + + /** + * Sets blueprint text. + * + * @param blueprintText the blueprint text + */ + public void setBlueprintText(String blueprintText) { + this.blueprintText = blueprintText; + } + + /** + * Gets bpmn text. + * + * @return the bpmn text + */ + public String getBpmnText() { + return bpmnText; + } + + /** + * Sets bpmn text. + * + * @param bpmnText the bpmn text + */ + public void setBpmnText(String bpmnText) { + this.bpmnText = bpmnText; + } + + /** + * Gets image text. + * + * @return the image text + */ + public String getImageText() { + return imageText; + } + + /** + * Sets image text. + * + * @param imageText the image text + */ + public void setImageText(String imageText) { + this.imageText = imageText; + } + + /** + * Gets doc text. + * + * @return the doc text + */ + public String getDocText() { + return docText; + } + + /** + * Sets doc text. + * + * @param docText the doc text + */ + public void setDocText(String docText) { + this.docText = docText; + } + + /** + * Gets type id. + * + * @return the type id + */ + public String getTypeId() { + return typeId; + } + + /** + * Sets type id. + * + * @param typeId the type id + */ + public void setTypeId(String typeId) { + this.typeId = typeId; + } + + /** + * Gets clds model instance list. + * + * @return the clds model instance list + */ + public List getCldsModelInstanceList() { + if (cldsModelInstanceList == null) { + cldsModelInstanceList = new ArrayList<>(); + } + return cldsModelInstanceList; + } + + /** + * Gets deployment id. + * + * @return the deployment id + */ + public String getDeploymentId() { + return deploymentId; + } + + /** + * Sets deployment id. + * + * @param deploymentId the deployment id + */ + public void setDeploymentId(String deploymentId) { + this.deploymentId = deploymentId; + } + + /** + * Gets permitted action cd. + * + * @return the permitted action cd + */ + public List getPermittedActionCd() { + return permittedActionCd; + } + + /** + * Gets error message for ui. + * + * @return the error message for ui + */ + public String getErrorMessageForUi() { + return errorMessageForUi; + } + + /** + * Sets error message for ui. + * + * @param errorMessageForUi the error message for ui + */ + public void setErrorMessageForUi(String errorMessageForUi) { + this.errorMessageForUi = errorMessageForUi; + } + + /** + * Gets deployment status url. + * + * @return the deployment status url + */ + public String getDeploymentStatusUrl() { + return deploymentStatusUrl; + } + + /** + * Sets deployment status url. + * + * @param deploymentStatusUrl the deployment status url + */ + public void setDeploymentStatusUrl(String deploymentStatusUrl) { + this.deploymentStatusUrl = deploymentStatusUrl; + } } diff --git a/src/main/java/org/onap/clamp/clds/model/CldsTemplate.java b/src/main/java/org/onap/clamp/clds/model/CldsTemplate.java index 8f3408375..7a827282e 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsTemplate.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsTemplate.java @@ -27,172 +27,187 @@ import javax.ws.rs.NotFoundException; import org.onap.clamp.clds.dao.CldsDao; +import com.google.gson.annotations.Expose; + /** * Represent a CLDS Model. */ public class CldsTemplate { - public static final String STATUS_DESIGN = "DESIGN"; - public static final String STATUS_ACTIVE = "ACTIVE"; - public static final String STATUS_STOPPED = "STOPPED"; - public static final String STATUS_DELETING = "DELETING"; - // manual intervention required - public static final String STATUS_ERROR = "ERROR"; - public static final String STATUS_UNKNOWN = "UNKNOWN"; - - private String id; - private String name; - private String controlNamePrefix; - private String controlNameUuid; - private String bpmnId; - private String bpmnUserid; - private String bpmnText; - private String imageId; - private String imageUserid; - private String imageText; - private String propId; - private String propUserid; - private String propText; - - private boolean userAuthorizedToUpdate; - - /** - * Save template to DB. - * - * @param cldsDao The cldsDao - * @param userid The user Id - */ - public void save(CldsDao cldsDao, String userid) { - cldsDao.setTemplate(this, userid); - } - - /** - * Retrieve from DB. - * - * @param cldsDao The cldsDao - * @param name The template name to retrieve - * @param okIfNotFound - * The flag indicating whether exception will be returned in case nothing is found - * @return Clds template from DB - */ - public static CldsTemplate retrieve(CldsDao cldsDao, String name, boolean okIfNotFound) { - // get from db - CldsTemplate template = cldsDao.getTemplate(name); - if (template.getId() == null && !okIfNotFound) { - throw new NotFoundException(); - } - return template; - } - - public String getBpmnUserid() { - return bpmnUserid; - } - - public void setBpmnUserid(String bpmnUserid) { - this.bpmnUserid = bpmnUserid; - } - - public String getBpmnText() { - return bpmnText; - } - - public void setBpmnText(String bpmnText) { - this.bpmnText = bpmnText; - } - - public String getImageUserid() { - return imageUserid; - } - - public void setImageUserid(String imageUserid) { - this.imageUserid = imageUserid; - } - - public String getImageText() { - return imageText; - } - - public void setImageText(String imageText) { - this.imageText = imageText; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getControlNamePrefix() { - return controlNamePrefix; - } - - public void setControlNamePrefix(String controlNamePrefix) { - this.controlNamePrefix = controlNamePrefix; - } - - public String getControlNameUuid() { - return controlNameUuid; - } - - public void setControlNameUuid(String controlNameUuid) { - this.controlNameUuid = controlNameUuid; - } - - public String getPropId() { - return propId; - } - - public void setPropId(String propId) { - this.propId = propId; - } - - public String getPropUserid() { - return propUserid; - } - - public void setPropUserid(String propUserid) { - this.propUserid = propUserid; - } - - public String getPropText() { - return propText; - } - - public void setPropText(String propText) { - this.propText = propText; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getBpmnId() { - return bpmnId; - } - - public void setBpmnId(String bpmnId) { - this.bpmnId = bpmnId; - } - - public String getImageId() { - return imageId; - } + public static final String STATUS_DESIGN = "DESIGN"; + public static final String STATUS_ACTIVE = "ACTIVE"; + public static final String STATUS_STOPPED = "STOPPED"; + public static final String STATUS_DELETING = "DELETING"; + // manual intervention required + public static final String STATUS_ERROR = "ERROR"; + public static final String STATUS_UNKNOWN = "UNKNOWN"; + + @Expose + private String id; + @Expose + private String name; + @Expose + private String controlNamePrefix; + @Expose + private String controlNameUuid; + @Expose + private String bpmnId; + @Expose + private String bpmnUserid; + @Expose + private String bpmnText; + @Expose + private String imageId; + @Expose + private String imageUserid; + @Expose + private String imageText; + @Expose + private String propId; + @Expose + private String propUserid; + @Expose + private String propText; + @Expose + private boolean userAuthorizedToUpdate; + + /** + * Save template to DB. + * + * @param cldsDao The cldsDao + * @param userid The user Id + */ + public void save(CldsDao cldsDao, String userid) { + cldsDao.setTemplate(this, userid); + } + + /** + * Retrieve from DB. + * + * @param cldsDao The cldsDao + * @param name The template name to retrieve + * @param okIfNotFound The flag indicating whether exception will be returned in + * case nothing is found + * @return Clds template from DB + */ + public static CldsTemplate retrieve(CldsDao cldsDao, String name, boolean okIfNotFound) { + // get from db + CldsTemplate template = cldsDao.getTemplate(name); + if (template.getId() == null && !okIfNotFound) { + throw new NotFoundException(); + } + return template; + } + + public String getBpmnUserid() { + return bpmnUserid; + } + + public void setBpmnUserid(String bpmnUserid) { + this.bpmnUserid = bpmnUserid; + } + + public String getBpmnText() { + return bpmnText; + } + + public void setBpmnText(String bpmnText) { + this.bpmnText = bpmnText; + } + + public String getImageUserid() { + return imageUserid; + } + + public void setImageUserid(String imageUserid) { + this.imageUserid = imageUserid; + } + + public String getImageText() { + return imageText; + } + + public void setImageText(String imageText) { + this.imageText = imageText; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getControlNamePrefix() { + return controlNamePrefix; + } + + public void setControlNamePrefix(String controlNamePrefix) { + this.controlNamePrefix = controlNamePrefix; + } + + public String getControlNameUuid() { + return controlNameUuid; + } + + public void setControlNameUuid(String controlNameUuid) { + this.controlNameUuid = controlNameUuid; + } + + public String getPropId() { + return propId; + } + + public void setPropId(String propId) { + this.propId = propId; + } + + public String getPropUserid() { + return propUserid; + } + + public void setPropUserid(String propUserid) { + this.propUserid = propUserid; + } + + public String getPropText() { + return propText; + } + + public void setPropText(String propText) { + this.propText = propText; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getBpmnId() { + return bpmnId; + } + + public void setBpmnId(String bpmnId) { + this.bpmnId = bpmnId; + } + + public String getImageId() { + return imageId; + } - public void setImageId(String imageId) { - this.imageId = imageId; - } + public void setImageId(String imageId) { + this.imageId = imageId; + } - public boolean isUserAuthorizedToUpdate() { - return userAuthorizedToUpdate; - } + public boolean isUserAuthorizedToUpdate() { + return userAuthorizedToUpdate; + } - public void setUserAuthorizedToUpdate(boolean userAuthorizedToUpdate) { - this.userAuthorizedToUpdate = userAuthorizedToUpdate; - } + public void setUserAuthorizedToUpdate(boolean userAuthorizedToUpdate) { + this.userAuthorizedToUpdate = userAuthorizedToUpdate; + } } diff --git a/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java b/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java index 961e1e328..0123f8049 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java @@ -31,11 +31,16 @@ import org.onap.clamp.clds.config.ClampProperties; import org.onap.clamp.clds.dao.CldsDao; import org.onap.clamp.clds.tosca.ToscaYamlToJsonConvertor; +import com.google.gson.annotations.Expose; + public class CldsToscaModel extends CldsToscaModelRevision { + @Expose private String id; - private String policyType; - private String toscaModelName; + @Expose + private String policyType; + @Expose + private String toscaModelName; /** * Construct. diff --git a/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java b/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java index a6ad10b72..cac84528c 100644 --- a/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java +++ b/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java @@ -27,147 +27,160 @@ import java.util.List; import javax.ws.rs.BadRequestException; +import com.google.gson.annotations.Expose; + /** * Represent a DCAE Event. */ public class DcaeEvent { - // this is an event we (clds) sends to dcae - public static final String EVENT_CREATED = "created"; - public static final String EVENT_DISTRIBUTION = "distribute"; - public static final String EVENT_DEPLOYMENT = "deployment"; - public static final String EVENT_UNDEPLOYMENT = "undeployment"; - public static final String ARTIFACT_NAME_SUFFIX = ".yml"; - - private String event; - private String serviceUuid; - private String resourceUuid; - private String artifactName; // controlName.yml - private List instances; - - /** - * Transform a DCAE Event Action to a CldsEvent.actionCd. - * - * @return The clds action. - */ - public String getCldsActionCd() { - if (event == null || event.length() == 0) { - throw new BadRequestException("action null or empty"); - } else if (event.equalsIgnoreCase(EVENT_CREATED)) { - return CldsEvent.ACTION_CREATE; - } else if (event.equalsIgnoreCase(EVENT_DISTRIBUTION)) { - return CldsEvent.ACTION_DISTRIBUTE; - } else if (event.equalsIgnoreCase(EVENT_DEPLOYMENT) && (instances == null || instances.isEmpty())) { - return CldsEvent.ACTION_DEPLOY; - } else if (event.equalsIgnoreCase(EVENT_DEPLOYMENT)) { - return CldsEvent.ACTION_DEPLOY; - // EVENT_UNDEPLOYMENT is defunct - DCAE Proxy will not undeploy - // individual instances. It will send an empty list of - // deployed instances to indicate all have been removed. Or it will - // send an updated list to indicate those that - // are still deployed with any not on the list considered - // undeployed. - } else if (event.equals(EVENT_UNDEPLOYMENT)) { - return CldsEvent.ACTION_UNDEPLOY; - } - - throw new BadRequestException("event value not valid: " + event); - } - - /** - * Derive the controlName from the artifactName. - * - * @return the controlName - */ - public String getControlName() { - if (artifactName != null && artifactName.endsWith(ARTIFACT_NAME_SUFFIX)) { - return artifactName.substring(0, artifactName.length() - ARTIFACT_NAME_SUFFIX.length()); - } else { - throw new BadRequestException("artifactName value not valid (expecting it to end with " - + ARTIFACT_NAME_SUFFIX + "): " + artifactName); - } - } - - /** - * Get the event. - * @return the event - */ - public String getEvent() { - return event; - } - - /** - * Set the event. - * @param event - * the event to set - */ - public void setEvent(String event) { - this.event = event; - } - - /** - * Get the serviceUUID. - * @return the serviceUUID - */ - public String getServiceUUID() { - return serviceUuid; - } - - /** - * Set the serviceUUID. - * @param serviceUUID - * the serviceUUID to set - */ - public void setServiceUUID(String serviceUuid) { - this.serviceUuid = serviceUuid; - } - - /** - * Get the resourceUUID. - * @return the resourceUUID - */ - public String getResourceUUID() { - return resourceUuid; - } - - /** - * Set the resourceUUID. - * @param resourceUUID - * the resourceUUID to set - */ - public void setResourceUUID(String resourceUuid) { - this.resourceUuid = resourceUuid; - } - - /** - * Get the artifact name. - * @return the artifactName - */ - public String getArtifactName() { - return artifactName; - } - - /** - * Set the artifact name. - * @param artifactName - * the artifactName to set - */ - public void setArtifactName(String artifactName) { - this.artifactName = artifactName; - } - - /** - * Get the list of instances. - * @return The list of model instances - */ - public List getInstances() { - return instances; - } - - /** - * Set the list of model instances. - * @param instances The list of model instances to set - */ - public void setInstances(List instances) { - this.instances = instances; - } + // this is an event we (clds) sends to dcae + public static final String EVENT_CREATED = "created"; + public static final String EVENT_DISTRIBUTION = "distribute"; + public static final String EVENT_DEPLOYMENT = "deployment"; + public static final String EVENT_UNDEPLOYMENT = "undeployment"; + public static final String ARTIFACT_NAME_SUFFIX = ".yml"; + + @Expose + private String event; + @Expose + private String serviceUuid; + @Expose + private String resourceUuid; + @Expose + private String artifactName; // controlName.yml + @Expose + private List instances; + + /** + * Transform a DCAE Event Action to a CldsEvent.actionCd. + * + * @return The clds action. + */ + public String getCldsActionCd() { + if (event == null || event.length() == 0) { + throw new BadRequestException("action null or empty"); + } else if (event.equalsIgnoreCase(EVENT_CREATED)) { + return CldsEvent.ACTION_CREATE; + } else if (event.equalsIgnoreCase(EVENT_DISTRIBUTION)) { + return CldsEvent.ACTION_DISTRIBUTE; + } else if (event.equalsIgnoreCase(EVENT_DEPLOYMENT) && (instances == null || instances.isEmpty())) { + return CldsEvent.ACTION_DEPLOY; + } else if (event.equalsIgnoreCase(EVENT_DEPLOYMENT)) { + return CldsEvent.ACTION_DEPLOY; + // EVENT_UNDEPLOYMENT is defunct - DCAE Proxy will not undeploy + // individual instances. It will send an empty list of + // deployed instances to indicate all have been removed. Or it will + // send an updated list to indicate those that + // are still deployed with any not on the list considered + // undeployed. + } else if (event.equals(EVENT_UNDEPLOYMENT)) { + return CldsEvent.ACTION_UNDEPLOY; + } + + throw new BadRequestException("event value not valid: " + event); + } + + /** + * Derive the controlName from the artifactName. + * + * @return the controlName + */ + public String getControlName() { + if (artifactName != null && artifactName.endsWith(ARTIFACT_NAME_SUFFIX)) { + return artifactName.substring(0, artifactName.length() - ARTIFACT_NAME_SUFFIX.length()); + } else { + throw new BadRequestException("artifactName value not valid (expecting it to end with " + + ARTIFACT_NAME_SUFFIX + "): " + artifactName); + } + } + + /** + * Get the event. + * + * @return the event + */ + public String getEvent() { + return event; + } + + /** + * Set the event. + * + * @param event the event to set + */ + public void setEvent(String event) { + this.event = event; + } + + /** + * Get the serviceUUID. + * + * @return the serviceUUID + */ + public String getServiceUUID() { + return serviceUuid; + } + + /** + * Set the serviceUUID. + * + * @param serviceUUID the serviceUUID to set + */ + public void setServiceUUID(String serviceUuid) { + this.serviceUuid = serviceUuid; + } + + /** + * Get the resourceUUID. + * + * @return the resourceUUID + */ + public String getResourceUUID() { + return resourceUuid; + } + + /** + * Set the resourceUUID. + * + * @param resourceUUID the resourceUUID to set + */ + public void setResourceUUID(String resourceUuid) { + this.resourceUuid = resourceUuid; + } + + /** + * Get the artifact name. + * + * @return the artifactName + */ + public String getArtifactName() { + return artifactName; + } + + /** + * Set the artifact name. + * + * @param artifactName the artifactName to set + */ + public void setArtifactName(String artifactName) { + this.artifactName = artifactName; + } + + /** + * Get the list of instances. + * + * @return The list of model instances + */ + public List getInstances() { + return instances; + } + + /** + * Set the list of model instances. + * + * @param instances The list of model instances to set + */ + public void setInstances(List instances) { + this.instances = instances; + } } diff --git a/src/main/java/org/onap/clamp/clds/model/ValueItem.java b/src/main/java/org/onap/clamp/clds/model/ValueItem.java index 74b369f79..4efef6ea6 100644 --- a/src/main/java/org/onap/clamp/clds/model/ValueItem.java +++ b/src/main/java/org/onap/clamp/clds/model/ValueItem.java @@ -23,39 +23,43 @@ package org.onap.clamp.clds.model; +import com.google.gson.annotations.Expose; + /** * ValueItem used for value lists. */ public class ValueItem { - private String value; - - /** - * Instantiate using value. - * - * @param value The value - */ - public ValueItem(String value) { - this.value = value; - } - - public ValueItem() { - } - - /** - * Get the value. - * @return the value - */ - public String getValue() { - return value; - } - - /** - * Set the value. - * @param value - * the value to set - */ - public void setValue(String value) { - this.value = value; - } + @Expose + private String value; + + /** + * Instantiate using value. + * + * @param value The value + */ + public ValueItem(String value) { + this.value = value; + } + + public ValueItem() { + } + + /** + * Get the value. + * + * @return the value + */ + public String getValue() { + return value; + } + + /** + * Set the value. + * + * @param value the value to set + */ + public void setValue(String value) { + this.value = value; + } } -- cgit 1.2.3-korg