aboutsummaryrefslogtreecommitdiffstats
path: root/vnfmarket-be/vnf-sdk-marketplace/src
diff options
context:
space:
mode:
Diffstat (limited to 'vnfmarket-be/vnf-sdk-marketplace/src')
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/impl/MarketplaceDaoImpl.java17
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/inf/IMarketplaceDao.java3
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/mapper/IMarketplaceMapper.java3
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/wrapper/BaseHandler.java2
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/resources/mybatis/sql/MarketplaceMapper.xml23
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java3
6 files changed, 48 insertions, 3 deletions
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/impl/MarketplaceDaoImpl.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/impl/MarketplaceDaoImpl.java
index 1e152991..79b08afd 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/impl/MarketplaceDaoImpl.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/impl/MarketplaceDaoImpl.java
@@ -17,6 +17,7 @@
package org.onap.vnfsdk.marketplace.db.impl;
import java.util.List;
+import java.util.Map;
import javax.persistence.PersistenceException;
@@ -77,6 +78,22 @@ public class MarketplaceDaoImpl implements IMarketplaceDao {
return csars;
}
+ @Override
+ public List<PackageData> getPackageDataSubset(Map<String, String> paramsMap) {
+ SqlSession session = sqlSessionFactory.openSession();
+ List<PackageData> csars = null;
+ try {
+ IMarketplaceMapper mapper = session.getMapper(IMarketplaceMapper.class);
+ csars = mapper.getPackageDataSubset(paramsMap);
+ session.commit();
+ } catch(PersistenceException e) {
+ LOGGER.error("Exception caught {}", e);
+ } finally {
+ session.close();
+ }
+ return csars;
+ }
+
/**
* saving the package data object to the DB using the mybatis.
* <br/>
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/inf/IMarketplaceDao.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/inf/IMarketplaceDao.java
index 1f1d69fc..cf6d7db8 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/inf/IMarketplaceDao.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/inf/IMarketplaceDao.java
@@ -17,6 +17,7 @@
package org.onap.vnfsdk.marketplace.db.inf;
import java.util.List;
+import java.util.Map;
import org.onap.vnfsdk.marketplace.db.entity.PackageData;
@@ -49,6 +50,8 @@ public interface IMarketplaceDao {
List<PackageData> getPackageData(String csarID);
+ List<PackageData> getPackageDataSubset(Map<String, String> paramsMap);
+
void deletePackageData(String csarId);
void updatePackageData(PackageData oPackageData);
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/mapper/IMarketplaceMapper.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/mapper/IMarketplaceMapper.java
index b94d442e..df7d5c05 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/mapper/IMarketplaceMapper.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/mapper/IMarketplaceMapper.java
@@ -17,6 +17,7 @@
package org.onap.vnfsdk.marketplace.db.mapper;
import java.util.List;
+import java.util.Map;
import org.onap.vnfsdk.marketplace.db.entity.PackageData;
@@ -49,6 +50,8 @@ public interface IMarketplaceMapper {
List<PackageData> getPackageData(String csarId);
+ List<PackageData> getPackageDataSubset(Map<String, String> paramsMap);
+
void deletePackageData(String csarId);
void updatePackageData(PackageData oPackageData);
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/wrapper/BaseHandler.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/wrapper/BaseHandler.java
index 0c5c542f..4e3e117c 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/wrapper/BaseHandler.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/wrapper/BaseHandler.java
@@ -86,7 +86,7 @@ public abstract class BaseHandler<T extends BaseData> {
throws MarketplaceResourceException {
logger.info("BaseHandler:start query data .info:" + MarketplaceDbUtil.objectToString(queryParam));
IMarketplaceDao dao = new MarketplaceDaoImpl();
- List<PackageData> datas = dao.getAllPackageData();
+ List<PackageData> datas = dao.getPackageDataSubset(queryParam);
logger.info("BaseHandler: query data end .info:" + MarketplaceDbUtil.objectToString(datas));
return datas;
}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/resources/mybatis/sql/MarketplaceMapper.xml b/vnfmarket-be/vnf-sdk-marketplace/src/main/resources/mybatis/sql/MarketplaceMapper.xml
index aeaa4a47..7d76b998 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/resources/mybatis/sql/MarketplaceMapper.xml
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/resources/mybatis/sql/MarketplaceMapper.xml
@@ -32,7 +32,28 @@
WHERE
CSARID=#{csarId}
</select>
-
+
+ <select id="getPackageDataSubset" resultType="org.onap.vnfsdk.marketplace.db.entity.PackageData" parameterType="java.util.Map">
+ SELECT * FROM CSAR_PACKAGE_TABLE
+ <where>
+ <if test="name != null">
+ NAME like #{name}
+ </if>
+ <if test="version != null">
+ AND VERSION like #{version}
+ </if>
+ <if test="deletionPending != null">
+ AND DELETIONPENDING like #{deletionPending}
+ </if>
+ <if test="type != null">
+ AND TYPE like #{type}
+ </if>
+ <if test="provider != null">
+ AND PROVIDER like #{provider}
+ </if>
+ </where>
+ </select>
+
<insert id="savePackageData" parameterType="org.onap.vnfsdk.marketplace.db.entity.PackageData">
INSERT INTO
CSAR_PACKAGE_TABLE
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java
index d1562f8f..de3ba455 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java
@@ -30,6 +30,7 @@ import java.io.InputStream;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@@ -153,7 +154,7 @@ public class PackageResourceTest {
new MockUp<MarketplaceDaoImpl>() {
@Mock
- public List<PackageData> getAllPackageData() {
+ public List<PackageData> getPackageDataSubset(Map<String, String> queryParam) {
return new ArrayList<PackageData>();
}
};