aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShadi Haidar <sh1986@att.com>2018-10-21 14:51:22 -0400
committerHaidar, Shadi (sh1986) <sh1986@att.com>2018-11-07 09:25:50 -0500
commitedb7b340c2f055af88e1ff9a4c7dfc0d51ac9b77 (patch)
treed13dc8e4dad93eee71fab752b299497acfbeca1f /src
parente09d200eaf5a3b36652433f3b8581192d7e0b52b (diff)
xAdd application/component.
Change-Id: Ib60ef8f3e64aa03dfa49b7c542ac7bae1e25175f Issue-ID: DCAEGEN2-879 Signed-off-by: Shadi Haidar <sh1986@att.com> Signed-off-by: Haidar, Shadi (sh1986) <sh1986@att.com>
Diffstat (limited to 'src')
-rw-r--r--src/gen/java/io/swagger/api/DcaeServiceTypesApi.java21
-rw-r--r--src/gen/java/io/swagger/api/DcaeServiceTypesApiService.java3
-rw-r--r--src/gen/java/io/swagger/model/DCAEServiceTypeRequest.java28
-rw-r--r--src/main/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImpl.java42
-rw-r--r--src/main/java/org/onap/dcae/inventory/daos/DCAEServiceTypesDAO.java24
-rw-r--r--src/main/java/org/onap/dcae/inventory/daos/InventoryDAO.java4
-rw-r--r--src/main/java/org/onap/dcae/inventory/daos/InventoryDAOManager.java30
-rw-r--r--src/main/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapper.java2
-rw-r--r--src/main/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceTypeObject.java18
9 files changed, 155 insertions, 17 deletions
diff --git a/src/gen/java/io/swagger/api/DcaeServiceTypesApi.java b/src/gen/java/io/swagger/api/DcaeServiceTypesApi.java
index 72f1f63..5ff9eb3 100644
--- a/src/gen/java/io/swagger/api/DcaeServiceTypesApi.java
+++ b/src/gen/java/io/swagger/api/DcaeServiceTypesApi.java
@@ -45,7 +45,7 @@ public class DcaeServiceTypesApi {
public static Link buildLinkForGet(UriInfo uriInfo, String rel, String typeName, Boolean onlyLatest, Boolean onlyActive,
String vnfType, String serviceId, String serviceLocation, String asdcServiceId,
- String asdcResourceId, Integer offset) {
+ String asdcResourceId, Integer offset, String application, String component, String owner) {
UriBuilder ub = uriInfo.getBaseUriBuilder().path(DcaeServiceTypesApi.class)
.path(DcaeServiceTypesApi.class, "dcaeServiceTypesGet");
@@ -76,6 +76,15 @@ public class DcaeServiceTypesApi {
if (offset != null) {
ub.queryParam("offset", offset);
}
+ if (application != null) {
+ ub.queryParam("application", application);
+ }
+ if (component != null) {
+ ub.queryParam("component", component);
+ }
+ if (owner != null) {
+ ub.queryParam("owner", owner);
+ }
Link.Builder lb = Link.fromUri(ub.build());
lb.rel(rel);
@@ -90,7 +99,7 @@ public class DcaeServiceTypesApi {
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "List of `DCAEServiceType` objects", response = InlineResponse200.class)})
public Response dcaeServiceTypesGet(
- @ApiParam(value = "Filter by service type name") @QueryParam("typeName") String typeName,
+ @ApiParam(value = "Filter by service type name. Wildcards matches with asterick(s) allowed.") @QueryParam("typeName") String typeName,
@ApiParam(value = "If set to true, query returns just the latest versions of DCAE service types. If set to false, then all versions are returned. Default is true")
@DefaultValue("true") @QueryParam("onlyLatest") Boolean onlyLatest,
@ApiParam(value = "If set to true, query returns only *active* DCAE service types. If set to false, then all DCAE service types are returned. Default is true")
@@ -106,10 +115,14 @@ public class DcaeServiceTypesApi {
@ApiParam(value = "Filter by associated asdc design resource id. Setting this to `NONE` will return instances that have asdc resource id set to null")
@QueryParam("asdcResourceId") String asdcResourceId,
@ApiParam(value = "Query resultset offset used for pagination (zero-based)") @QueryParam("offset") Integer offset,
- @Context SecurityContext securityContext)
+ @Context SecurityContext securityContext,
+ @ApiParam(value = "Filter by associated application.") @QueryParam("application") String application,
+ @ApiParam(value = "Filter by associated component or sub-application module.") @QueryParam("component") String component,
+ @ApiParam(value = "Filter by associated owner.") @QueryParam("owner") String owner
+ )
throws NotFoundException {
return delegate.dcaeServiceTypesGet(typeName, onlyLatest, onlyActive, vnfType, serviceId, serviceLocation,
- asdcServiceId, asdcResourceId, offset, uriInfo, securityContext);
+ asdcServiceId, asdcResourceId, offset, uriInfo, securityContext, application, component, owner);
}
public static Link buildLinkForGet(UriInfo uriInfo, String rel, String typeId) {
diff --git a/src/gen/java/io/swagger/api/DcaeServiceTypesApiService.java b/src/gen/java/io/swagger/api/DcaeServiceTypesApiService.java
index afc7476..ab2bc64 100644
--- a/src/gen/java/io/swagger/api/DcaeServiceTypesApiService.java
+++ b/src/gen/java/io/swagger/api/DcaeServiceTypesApiService.java
@@ -31,7 +31,8 @@ public abstract class DcaeServiceTypesApiService {
public abstract Response dcaeServiceTypesGet(String typeName, Boolean onlyLatest, Boolean onlyActive,
String vnfType, String serviceId, String serviceLocation,
String asdcServiceId, String asdcResourceId,
- Integer offset, UriInfo uriInfo, SecurityContext securityContext)
+ Integer offset, UriInfo uriInfo, SecurityContext securityContext,
+ String application, String component, String owner)
throws NotFoundException;
public abstract Response dcaeServiceTypesTypeIdGet(String typeId, UriInfo uriInfo, SecurityContext securityContext)
throws NotFoundException;
diff --git a/src/gen/java/io/swagger/model/DCAEServiceTypeRequest.java b/src/gen/java/io/swagger/model/DCAEServiceTypeRequest.java
index 7cd3577..83b7949 100644
--- a/src/gen/java/io/swagger/model/DCAEServiceTypeRequest.java
+++ b/src/gen/java/io/swagger/model/DCAEServiceTypeRequest.java
@@ -53,6 +53,8 @@ public class DCAEServiceTypeRequest {
private String asdcServiceId = null;
private String asdcResourceId = null;
private String asdcServiceURL = null;
+ private String application = null;
+ private String component = null;
/**
@@ -72,6 +74,26 @@ public class DCAEServiceTypeRequest {
public void setOwner(String owner) {
this.owner = owner;
}
+
+ @ApiModelProperty(required = false, value = "Application associated or that added this DCAE service type.")
+ @JsonProperty("application")
+ public String getApplication() {
+ return application;
+ }
+
+ public void setApplication(String application) {
+ this.application = application;
+ }
+
+ @ApiModelProperty(required = false, value = "Component or sub-application module associated or that added this DCAE service type.")
+ @JsonProperty("component")
+ public String getComponent() {
+ return component;
+ }
+
+ public void setComponent(String component) {
+ this.component = component;
+ }
@ApiModelProperty(required = true, value = "Descriptive name for this DCAE service type")
@@ -192,13 +214,15 @@ public class DCAEServiceTypeRequest {
}
DCAEServiceTypeRequest dCAEServiceTypeRequest = (DCAEServiceTypeRequest) o;
return Objects.equals(owner, dCAEServiceTypeRequest.owner) &&
+ Objects.equals(application, dCAEServiceTypeRequest.application) &&
+ Objects.equals(component, dCAEServiceTypeRequest.component) &&
Objects.equals(vnfTypes, dCAEServiceTypeRequest.vnfTypes) &&
Objects.equals(blueprintTemplate, dCAEServiceTypeRequest.blueprintTemplate);
}
@Override
public int hashCode() {
- return Objects.hash(owner, vnfTypes, blueprintTemplate);
+ return Objects.hash(owner, application, component, vnfTypes, blueprintTemplate);
}
@Override
@@ -207,6 +231,8 @@ public class DCAEServiceTypeRequest {
sb.append("class DCAEServiceTypeRequest {\n");
sb.append(" owner: ").append(toIndentedString(owner)).append("\n");
+ sb.append(" application: ").append(toIndentedString(application)).append("\n");
+ sb.append(" component: ").append(toIndentedString(component)).append("\n");
sb.append(" vnfTypes: ").append(toIndentedString(vnfTypes)).append("\n");
sb.append(" blueprintTemplate: ").append(toIndentedString(blueprintTemplate)).append("\n");
sb.append("}");
diff --git a/src/main/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImpl.java b/src/main/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImpl.java
index feafd20..13f1540 100644
--- a/src/main/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImpl.java
+++ b/src/main/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImpl.java
@@ -58,6 +58,8 @@ public class DcaeServiceTypesApiServiceImpl extends DcaeServiceTypesApiService {
serviceType.setTypeName(serviceTypeObject.getTypeName());
serviceType.setTypeVersion(serviceTypeObject.getTypeVersion());
serviceType.setOwner(serviceTypeObject.getOwner());
+ serviceType.setApplication(serviceTypeObject.getApplication());
+ serviceType.setComponent(serviceTypeObject.getComponent());
serviceType.setVnfTypes(serviceTypeObject.getVnfTypes());
serviceType.setServiceIds(serviceTypeObject.getServiceIds());
serviceType.setServiceLocations(serviceTypeObject.getServiceLocations());
@@ -76,7 +78,9 @@ public class DcaeServiceTypesApiServiceImpl extends DcaeServiceTypesApiService {
@Override
public Response dcaeServiceTypesGet(String typeName, Boolean onlyLatest, Boolean onlyActive, String vnfType,
String serviceId, String serviceLocation, String asdcServiceId,
- String asdcResourceId, Integer offset, UriInfo uriInfo, SecurityContext securityContext)
+ String asdcResourceId, Integer offset,
+ UriInfo uriInfo, SecurityContext securityContext,
+ String application, String component, String owner)
throws NotFoundException {
List<DCAEServiceTypeObject> serviceTypeObjects = new ArrayList<>();
@@ -100,7 +104,7 @@ public class DcaeServiceTypesApiServiceImpl extends DcaeServiceTypesApiService {
whereClauses.add(":typeName = type_name");
}
else {
- typeName = typeName.replaceAll("\\*", "%");
+ typeName = typeName.replaceAll("\\*", "%");
whereClauses.add("type_name LIKE :typeName");
}
}
@@ -116,14 +120,14 @@ public class DcaeServiceTypesApiServiceImpl extends DcaeServiceTypesApiService {
if (serviceLocation != null) {
whereClauses.add("(:serviceLocation = any(service_locations) or service_locations = \'{}\' or service_locations is null)");
}
-
+
if (asdcServiceId != null) {
if (asdcServiceId.equalsIgnoreCase("NONE")) {
whereClauses.add("asdc_service_id is null");
} else {
whereClauses.add(":asdcServiceId = asdc_service_id");
}
- }
+ }
if (asdcResourceId != null) {
if (asdcResourceId.equalsIgnoreCase("NONE")) {
@@ -132,6 +136,18 @@ public class DcaeServiceTypesApiServiceImpl extends DcaeServiceTypesApiService {
whereClauses.add(":asdcResourceId = asdc_resource_id");
}
}
+
+ if (owner != null) {
+ whereClauses.add(":owner = owner");
+ }
+
+ if (application != null) {
+ whereClauses.add(":application = application");
+ }
+
+ if (component != null) {
+ whereClauses.add(":component = component");
+ }
whereClauses.add("created < :createdCutoff");
@@ -174,6 +190,18 @@ public class DcaeServiceTypesApiServiceImpl extends DcaeServiceTypesApiService {
if (asdcResourceId != null && !"NONE".equalsIgnoreCase(asdcResourceId)) {
query.bind("asdcResourceId", asdcResourceId);
}
+
+ if (application != null) {
+ query.bind("application", application);
+ }
+
+ if (component != null) {
+ query.bind("component", component);
+ }
+
+ if (owner != null) {
+ query.bind("owner", owner);
+ }
query.bind("createdCutoff", createdCutoff);
@@ -205,14 +233,14 @@ public class DcaeServiceTypesApiServiceImpl extends DcaeServiceTypesApiService {
if (offsetPrev >= 0) {
navigationLinks.setPreviousLink(DcaeServiceTypesApi.buildLinkForGet(uriInfo, "prev", typeName, onlyLatest,
- onlyActive, vnfType, serviceId, serviceLocation, asdcServiceId, asdcResourceId, offsetPrev));
+ onlyActive, vnfType, serviceId, serviceLocation, asdcServiceId, asdcResourceId, offsetPrev, application, component, owner));
}
Integer offsetNext = offset + PAGINATION_PAGE_SIZE;
if (offsetNext < totalCount) {
navigationLinks.setNextLink(DcaeServiceTypesApi.buildLinkForGet(uriInfo, "next", typeName, onlyLatest,
- onlyActive, vnfType, serviceId, serviceLocation, asdcServiceId, asdcResourceId, offsetNext));
+ onlyActive, vnfType, serviceId, serviceLocation, asdcServiceId, asdcResourceId, offsetNext, application, component, owner));
}
response.setLinks(navigationLinks);
@@ -251,6 +279,8 @@ public class DcaeServiceTypesApiServiceImpl extends DcaeServiceTypesApiService {
serviceTypeObject.setTypeName(request.getTypeName());
serviceTypeObject.setTypeVersion(request.getTypeVersion());
serviceTypeObject.setOwner(request.getOwner());
+ serviceTypeObject.setApplication(request.getApplication());
+ serviceTypeObject.setComponent(request.getComponent());
serviceTypeObject.setBlueprintTemplate(request.getBlueprintTemplate());
serviceTypeObject.setVnfTypes(request.getVnfTypes());
serviceTypeObject.setServiceIds(request.getServiceIds());
diff --git a/src/main/java/org/onap/dcae/inventory/daos/DCAEServiceTypesDAO.java b/src/main/java/org/onap/dcae/inventory/daos/DCAEServiceTypesDAO.java
index aa242a4..770661c 100644
--- a/src/main/java/org/onap/dcae/inventory/daos/DCAEServiceTypesDAO.java
+++ b/src/main/java/org/onap/dcae/inventory/daos/DCAEServiceTypesDAO.java
@@ -42,6 +42,14 @@ public interface DCAEServiceTypesDAO extends InventoryDAO {
@SqlQuery("select exists (select * from information_schema.tables where table_name = \'dcae_service_types\')")
@Override
Boolean checkIfTableExists();
+
+ @SqlQuery("select exists (select * from information_schema.columns where table_name = \'dcae_service_types\' and column_name=\'application\')")
+ @Override
+ Boolean checkIfApplicationColumnExists();
+
+ @SqlQuery("select exists (select * from information_schema.columns where table_name = \'dcae_service_types\' and column_name=\'component\')")
+ @Override
+ Boolean checkIfComponentColumnExists();
/**
* Note that service_ids and service_locations are nullable fields. This might not be the right decision but because
@@ -50,20 +58,28 @@ public interface DCAEServiceTypesDAO extends InventoryDAO {
@SqlUpdate("create table dcae_service_types (type_id varchar not null, type_version integer not null, " +
"type_name varchar not null, owner varchar not null, blueprint_template text not null, " +
"vnf_types varchar[] not null, service_ids varchar[], service_locations varchar[], " +
- "asdc_service_id varchar, asdc_resource_id varchar, " +
+ "asdc_service_id varchar, asdc_resource_id varchar, application varchar, component varchar, " +
"created timestamp not null, deactivated timestamp, constraint pk_type_created primary key (type_id))")
@Override
void createTable();
+
+ @SqlUpdate("alter table dcae_service_types add column application varchar")
+ @Override
+ void updateTableToAddApplicationCol();
+
+ @SqlUpdate("alter table dcae_service_types add column component varchar")
+ @Override
+ void updateTableToAddComponentCol();
// REVIEW: asdcServiceId and asdcResourceId is implicitly part of the unique key and thus shouldn't be updated.
- @SqlUpdate("insert into dcae_service_types(type_id, type_version, type_name, owner, blueprint_template, vnf_types, " +
+ @SqlUpdate("insert into dcae_service_types(type_id, type_version, type_name, owner, application, component, blueprint_template, vnf_types, " +
"service_ids, service_locations, asdc_service_id, asdc_resource_id, created, deactivated) " +
- "values (:typeId, :typeVersion, :typeName, :owner, :blueprintTemplate, :vnfTypes, :serviceIds, " +
+ "values (:typeId, :typeVersion, :typeName, :owner, :application, :component, :blueprintTemplate, :vnfTypes, :serviceIds, " +
":serviceLocations, :asdcServiceId, :asdcResourceId, :created, null)")
void insert(@BindBean DCAEServiceTypeObject serviceObject);
@SqlUpdate("update dcae_service_types set " +
- "owner = :owner, blueprint_template = :blueprintTemplate, vnf_types = :vnfTypes, " +
+ "owner = :owner, application = :application, component = :component, blueprint_template = :blueprintTemplate, vnf_types = :vnfTypes, " +
"service_ids = :serviceIds, service_locations = :serviceLocations, created = :created, " +
"deactivated = null where type_id = :typeId")
void update(@BindBean DCAEServiceTypeObject serviceObject);
diff --git a/src/main/java/org/onap/dcae/inventory/daos/InventoryDAO.java b/src/main/java/org/onap/dcae/inventory/daos/InventoryDAO.java
index a369cb1..e678b60 100644
--- a/src/main/java/org/onap/dcae/inventory/daos/InventoryDAO.java
+++ b/src/main/java/org/onap/dcae/inventory/daos/InventoryDAO.java
@@ -25,5 +25,9 @@ package org.onap.dcae.inventory.daos;
*/
public interface InventoryDAO {
Boolean checkIfTableExists();
+ Boolean checkIfApplicationColumnExists();
+ Boolean checkIfComponentColumnExists();
void createTable();
+ void updateTableToAddApplicationCol();
+ void updateTableToAddComponentCol();
}
diff --git a/src/main/java/org/onap/dcae/inventory/daos/InventoryDAOManager.java b/src/main/java/org/onap/dcae/inventory/daos/InventoryDAOManager.java
index b809d2d..5bdecfe 100644
--- a/src/main/java/org/onap/dcae/inventory/daos/InventoryDAOManager.java
+++ b/src/main/java/org/onap/dcae/inventory/daos/InventoryDAOManager.java
@@ -101,6 +101,8 @@ public final class InventoryDAOManager {
final DBI jdbi_local = factory.build(this.environment, this.configuration.getDataSourceFactory(), "dcae-database");
jdbi_local.registerArgumentFactory(new StringListArgument());
+ boolean recreateDcaeServiceTypesView = false;
+
for (Class<? extends InventoryDAO> daoClass : DAO_CLASSES) {
final InventoryDAO dao = jdbi_local.onDemand(daoClass);
@@ -110,6 +112,23 @@ public final class InventoryDAOManager {
dao.createTable();
debugLogger.info(String.format("Sql table created: %s", daoClass.getSimpleName()));
}
+ // dcae_service_types DB table has been enhanced to include 2 new columns which need to be added if they don't already exist
+ if ( daoClass.getSimpleName().equals("DCAEServiceTypesDAO") ) {
+ if (dao.checkIfApplicationColumnExists()) {
+ debugLogger.info(String.format("ApplicationColumn exists: %s", daoClass.getSimpleName()));
+ } else {
+ dao.updateTableToAddApplicationCol();
+ debugLogger.info(String.format("ApplicationColumn created: %s", daoClass.getSimpleName()+".updateTableToAddApplicationCol()" ));
+ recreateDcaeServiceTypesView = true;
+ }
+ if (dao.checkIfComponentColumnExists()) {
+ debugLogger.info(String.format("ComponentColumn exists: %s", daoClass.getSimpleName()));
+ } else {
+ dao.updateTableToAddComponentCol();;
+ debugLogger.info(String.format("ComponentColumn created: %s", daoClass.getSimpleName()+".updateTableToAddComponentCol()"));
+ recreateDcaeServiceTypesView = true;
+ }
+ }
}
// CREATE VIEWS
@@ -119,7 +138,16 @@ public final class InventoryDAOManager {
String checkQuery = String.format("select exists (select * from information_schema.tables where table_name = '%s')",
viewName);
- if (jdbiHandle.createQuery(checkQuery).map(BooleanMapper.FIRST).first()) {
+ boolean viewExists = jdbiHandle.createQuery(checkQuery).map(BooleanMapper.FIRST).first();
+
+ // if the view exists and the 2 new dcae_service_types DB table columns: application and component need to be added
+ // we need to re-create the view by deleting it first
+ if (viewExists && recreateDcaeServiceTypesView) {
+ debugLogger.info(String.format("Need to delete existing Sql view: %s", viewName));
+ jdbiHandle.execute(String.format("drop view %s ", viewName));
+ }
+
+ if (viewExists) {
debugLogger.info(String.format("Sql view exists: %s", viewName));
} else {
StringBuilder sb = new StringBuilder(String.format("create view %s as ", viewName));
diff --git a/src/main/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapper.java b/src/main/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapper.java
index bda4423..a7e2249 100644
--- a/src/main/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapper.java
+++ b/src/main/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapper.java
@@ -43,6 +43,8 @@ public class DCAEServiceTypeObjectMapper implements ResultSetMapper<DCAEServiceT
object.setTypeName(resultSet.getString("type_name"));
object.setTypeVersion(resultSet.getInt("type_version"));
object.setOwner(resultSet.getString("owner"));
+ object.setApplication(resultSet.getString("application"));
+ object.setComponent(resultSet.getString("component"));
String[] vnfTypes = (String[]) resultSet.getArray("vnf_types").getArray();
object.setVnfTypes(Arrays.asList(vnfTypes));
diff --git a/src/main/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceTypeObject.java b/src/main/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceTypeObject.java
index f264c99..3c86138 100644
--- a/src/main/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceTypeObject.java
+++ b/src/main/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceTypeObject.java
@@ -36,6 +36,8 @@ public class DCAEServiceTypeObject {
private Integer typeVersion = null;
private String blueprintTemplate = null;
private String owner = null;
+ private String application = null;
+ private String component = null;
private List<String> vnfTypes = null;
private List<String> serviceIds = null;
private List<String> serviceLocations = null;
@@ -83,6 +85,22 @@ public class DCAEServiceTypeObject {
public void setOwner(String owner) {
this.owner = owner;
}
+
+ public String getApplication() {
+ return application;
+ }
+
+ public void setApplication(String application) {
+ this.application = application;
+ }
+
+ public String getComponent() {
+ return component;
+ }
+
+ public void setComponent(String component) {
+ this.component = component;
+ }
public List<String> getVnfTypes() {
return vnfTypes;