Adding Repository classes and tests
ADD
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/replicacatalog/DataProductRepository.java
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.registry.core.repositories.replicacatalog;
+
+import org.apache.airavata.model.data.replica.DataProductModel;
+import org.apache.airavata.model.data.replica.DataProductType;
+import org.apache.airavata.registry.core.entities.replicacatalog.DataProductEntity;
+import org.apache.airavata.registry.core.utils.DBConstants;
+import org.apache.airavata.registry.core.utils.QueryConstants;
+import org.apache.airavata.registry.cpi.ReplicaCatalog;
+import org.apache.airavata.registry.cpi.ReplicaCatalogException;
+import org.apache.airavata.registry.core.utils.ObjectMapperSingleton;
+import org.dozer.Mapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.Timestamp;
+import java.util.*;
+
+public class DataProductRepository extends RepCatAbstractRepository<DataProductModel, DataProductEntity, String> {
+ private final static Logger logger = LoggerFactory.getLogger(DataProductRepository.class);
+
+ public DataProductRepository() {
+ super(DataProductModel.class, DataProductEntity.class);
+ }
+
+ protected String saveDataProductModelData(DataProductModel dataProductModel) throws ReplicaCatalogException {
+ DataProductEntity dataProductEntity = saveDataProduct(dataProductModel);
+ return dataProductEntity.getProductUri();
+ }
+
+ protected DataProductEntity saveDataProduct(DataProductModel dataProductModel) throws ReplicaCatalogException {
+ String productUri = ReplicaCatalog.schema + "://" + UUID.randomUUID().toString();
+ dataProductModel.setProductUri(productUri);
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ DataProductEntity dataProductEntity = mapper.map(dataProductModel, DataProductEntity.class);
+
+ if (dataProductEntity.getOwnerName() == null || dataProductEntity.getGatewayId() == null) {
+ logger.error("Owner name and/or gateway ID is empty");
+ throw new ReplicaCatalogException("Owner name and gateway ID should not be empty");
+ }
+
+ if (dataProductEntity.getParentProductUri() != null && (!isExists(dataProductEntity.getParentProductUri())
+ || !getDataProduct(dataProductEntity.getParentProductUri()).getDataProductType().equals(DataProductType.COLLECTION))) {
+ logger.error("Parent product does not exist and/or parent type is not Collection");
+ throw new ReplicaCatalogException("Parent product does not exist or parent type is not Collection");
+ }
+
+ if (dataProductEntity.getReplicaLocations() != null) {
+ logger.debug("Populating the product URI for ReplicaLocations objects for the Application Deployment");
+ dataProductEntity.getReplicaLocations().forEach(dataReplicaLocationEntity -> dataReplicaLocationEntity.setProductUri(productUri));
+ }
+
+ if (!isDataProductExists(productUri)) {
+ logger.debug("Checking if the Data Product already exists");
+ dataProductEntity.setCreationTime(new Timestamp(System.currentTimeMillis()));
+ }
+
+ dataProductEntity.setLastModifiedTime(new Timestamp(System.currentTimeMillis()));
+
+ return execute(entityManager -> entityManager.merge(dataProductEntity));
+
+ }
+
+ public String registerDataProduct(DataProductModel dataProductModel) throws ReplicaCatalogException {
+ return saveDataProductModelData(dataProductModel);
+ }
+
+ public void updateDataProduct(DataProductModel updatedDataProductModel) throws ReplicaCatalogException {
+ saveDataProductModelData(updatedDataProductModel);
+ }
+
+ public DataProductModel getDataProduct(String productUri) throws ReplicaCatalogException {
+ return get(productUri);
+ }
+
+ public DataProductModel getParentDataProduct(String productUri) throws ReplicaCatalogException {
+ DataProductModel dataProductModel = getDataProduct(productUri);
+ return get(dataProductModel.getParentProductUri());
+ }
+
+ public List<DataProductModel> getChildDataProducts(String parentProductUri) throws ReplicaCatalogException {
+ Map<String, Object> queryParameters = new HashMap<>();
+ queryParameters.put(DBConstants.DataProduct.PARENT_PRODUCT_URI, parentProductUri);
+ List<DataProductModel> dataProductModelList = select(QueryConstants.FIND_ALL_CHILD_DATA_PRODUCTS, -1, 0, queryParameters);
+ return dataProductModelList;
+ }
+
+ public List<DataProductModel> searchDataProductsByName(String gatewayId, String userId, String productName,
+ int limit, int offset) throws ReplicaCatalogException {
+ Map<String, Object> queryParameters = new HashMap<>();
+ queryParameters.put(DBConstants.DataProduct.GATEWAY_ID, gatewayId);
+ queryParameters.put(DBConstants.DataProduct.OWNER_NAME, userId);
+ queryParameters.put(DBConstants.DataProduct.PRODUCT_NAME, productName);
+ List<DataProductModel> dataProductModelList = select(QueryConstants.FIND_DATA_PRODUCT_BY_NAME, limit, offset, queryParameters);
+ return dataProductModelList;
+ }
+
+ public boolean isDataProductExists(String productUri) throws ReplicaCatalogException {
+ return isExists(productUri);
+ }
+
+ public boolean removeDataProduct(String productUri) throws ReplicaCatalogException {
+ return delete(productUri);
+ }
+
+}

ADD
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/replicacatalog/DataReplicaLocationRepository.java
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.registry.core.repositories.replicacatalog;
+
+import org.apache.airavata.model.data.replica.DataProductModel;
+import org.apache.airavata.model.data.replica.DataReplicaLocationModel;
+import org.apache.airavata.registry.core.entities.replicacatalog.DataProductEntity;
+import org.apache.airavata.registry.core.entities.replicacatalog.DataReplicaLocationEntity;
+import org.apache.airavata.registry.core.utils.ObjectMapperSingleton;
+import org.apache.airavata.registry.cpi.ReplicaCatalogException;
+import org.dozer.Mapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.Timestamp;
+import java.util.List;
+import java.util.UUID;
+
+public class DataReplicaLocationRepository extends RepCatAbstractRepository<DataReplicaLocationModel, DataReplicaLocationEntity, String> {
+ private final static Logger logger = LoggerFactory.getLogger(DataProductRepository.class);
+
+ public DataReplicaLocationRepository() { super(DataReplicaLocationModel.class, DataReplicaLocationEntity.class); }
+
+ private String saveDataReplicaLocationModelData(DataReplicaLocationModel dataReplicaLocationModel) throws ReplicaCatalogException {
+ DataReplicaLocationEntity dataReplicaLocationEntity = saveDataReplicaLocation(dataReplicaLocationModel);
+ return dataReplicaLocationEntity.getProductUri();
+ }
+
+ private DataReplicaLocationEntity saveDataReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel) throws ReplicaCatalogException {
+ String replicaId = UUID.randomUUID().toString();
+ dataReplicaLocationModel.setReplicaId(replicaId);
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ DataReplicaLocationEntity dataReplicaLocationEntity = mapper.map(dataReplicaLocationModel, DataReplicaLocationEntity.class);
+
+ if (!isDataReplicaLocationExists(replicaId)) {
+ logger.debug("Checking if the Data Replica Location already exists");
+ dataReplicaLocationEntity.setCreationTime(new Timestamp(System.currentTimeMillis()));
+ }
+
+ dataReplicaLocationEntity.setLastModifiedTime(new Timestamp(System.currentTimeMillis()));
+
+ return execute(entityManager -> entityManager.merge(dataReplicaLocationEntity));
+ }
+
+ public String registerDataReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel) throws ReplicaCatalogException {
+ return saveDataReplicaLocationModelData(dataReplicaLocationModel);
+ }
+
+ public void updateDataReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel) throws ReplicaCatalogException {
+ saveDataReplicaLocationModelData(dataReplicaLocationModel);
+ }
+
+ public DataReplicaLocationModel getDataReplicaLocation(String replicaId) throws ReplicaCatalogException {
+ return get(replicaId);
+ }
+
+ public List<DataReplicaLocationModel> getAllDataReplicaLocations(String productUri) throws ReplicaCatalogException {
+ DataProductRepository dataProductRepository = new DataProductRepository();
+ DataProductModel dataProductModel = dataProductRepository.getDataProduct(productUri);
+ List<DataReplicaLocationModel> dataReplicaLocationModelList = dataProductModel.getReplicaLocations();
+ return dataReplicaLocationModelList;
+ }
+
+ public boolean isDataReplicaLocationExists(String replicaId) throws ReplicaCatalogException {
+ return isExists(replicaId);
+ }
+
+ public boolean removeDataReplicaLocation(String replicaId) throws ReplicaCatalogException {
+ return delete(replicaId);
+ }
+
+}

ADD
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/replicacatalog/RepCatAbstractRepository.java
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.registry.core.repositories.replicacatalog;
+
+import org.apache.airavata.registry.core.utils.Committer;
+import org.apache.airavata.registry.core.utils.DBConstants;
+import org.apache.airavata.registry.core.utils.JPAUtil.RepCatalogJPAUtils;
+import org.apache.airavata.registry.core.utils.ObjectMapperSingleton;
+import org.dozer.Mapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public abstract class RepCatAbstractRepository<T, E, Id> {
+ private final static Logger logger = LoggerFactory.getLogger(RepCatAbstractRepository.class);
+
+ private Class<T> thriftGenericClass;
+ private Class<E> dbEntityGenericClass;
+
+ public RepCatAbstractRepository(Class<T> thriftGenericClass, Class<E> dbEntityGenericClass) {
+ this.thriftGenericClass = thriftGenericClass;
+ this.dbEntityGenericClass = dbEntityGenericClass;
+ }
+
+ public T create(T t) {
+ return update(t);
+ }
+
+ public T update(T t) {
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ E entity = mapper.map(t, dbEntityGenericClass);
+ E persistedCopy = execute(entityManager -> entityManager.merge(entity));
+ return mapper.map(persistedCopy, thriftGenericClass);
+ }
+
+ public boolean delete(Id id) {
+ execute(entityManager -> {
+ E entity = entityManager.find(dbEntityGenericClass, id);
+ entityManager.remove(entity);
+ return entity;
+ });
+ return true;
+ }
+
+ public T get(Id id) {
+ E entity = execute(entityManager -> entityManager
+ .find(dbEntityGenericClass, id));
+ if(entity == null)
+ return null;
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ return mapper.map(entity, thriftGenericClass);
+ }
+
+ public List<T> select(String query, int offset) {
+ List resultSet = (List) execute(entityManager -> entityManager.createQuery(query).setFirstResult(offset)
+ .getResultList());
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ List<T> gatewayList = new ArrayList<>();
+ resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, thriftGenericClass)));
+ return gatewayList;
+ }
+
+ public List<T> select(String query, int limit, int offset, Map<String, Object> queryParams) {
+ int newLimit = limit < 0 ? DBConstants.SELECT_MAX_ROWS: limit;
+
+ List resultSet = (List) execute(entityManager -> {
+ Query jpaQuery = entityManager.createQuery(query);
+
+ for (Map.Entry<String, Object> entry : queryParams.entrySet()) {
+
+ jpaQuery.setParameter(entry.getKey(), entry.getValue());
+ }
+
+ return jpaQuery.setFirstResult(offset).setMaxResults(newLimit).getResultList();
+
+ });
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ List<T> gatewayList = new ArrayList<>();
+ resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, thriftGenericClass)));
+ return gatewayList;
+ }
+
+ public boolean isExists(Id id) {
+ return get(id) != null;
+ }
+
+ public <R> R execute(Committer<EntityManager, R> committer){
+ EntityManager entityManager = null;
+ try {
+ entityManager = RepCatalogJPAUtils.getEntityManager();
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to get Replica Catalog EntityManager", e);
+ }
+ try {
+ entityManager.getTransaction().begin();
+ R r = committer.commit(entityManager);
+ entityManager.getTransaction().commit();
+ return r;
+ }finally {
+ if (entityManager != null && entityManager.isOpen()) {
+ if (entityManager.getTransaction().isActive()) {
+ entityManager.getTransaction().rollback();
+ }
+ entityManager.close();
+ }
+ }
+ }
+
+}

MODIFY
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/DBConstants.java
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/DBConstants.java
@@ -26,4 +26,11 @@ public class DBConstants {
public static final String GROUP_RESOURCE_PROFILE_ID = "groupResourceProfileId";
}
+ public static class DataProduct {
+ public static final String GATEWAY_ID = "gatewayId";
+ public static final String OWNER_NAME = "ownerName";
+ public static final String PRODUCT_NAME = "productName";
+ public static final String PARENT_PRODUCT_URI = "parentProductUri";
+ }
+
}

ADD
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/JPAUtil/RepCatalogJPAUtils.java
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.airavata.registry.core.utils.JPAUtil;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ServerSettings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+import java.util.HashMap;
+import java.util.Map;
+
+public class RepCatalogJPAUtils {
+ private final static Logger logger = LoggerFactory.getLogger(RepCatalogJPAUtils.class);
+
+ private static final String PERSISTENCE_UNIT_NAME = "replicacatalog_data";
+ private static final String REPLICACATALOG_JDBC_DRIVER = "replicacatalog.jdbc.driver";
+ private static final String REPLICACATALOG_JDBC_URL = "replicacatalog.jdbc.url";
+ private static final String REPLICACATALOG_JDBC_USER = "replicacatalog.jdbc.user";
+ private static final String REPLICACATALOG_JDBC_PWD = "replicacatalog.jdbc.password";
+ private static final String REPLICACATALOG_VALIDATION_QUERY = "replicacatalog.validationQuery";
+
+ @PersistenceUnit(unitName="replicacatalog_data")
+ protected static EntityManagerFactory factory;
+
+ @PersistenceContext(unitName="replicacatalog_data")
+ private static EntityManager dataCatEntityManager;
+
+ public static EntityManager getEntityManager() throws ApplicationSettingsException {
+ if (factory == null) {
+ String connectionProperties = "DriverClassName=" + readServerProperties(REPLICACATALOG_JDBC_DRIVER) + "," +
+ "Url=" + readServerProperties(REPLICACATALOG_JDBC_URL) + "?autoReconnect=true," +
+ "Username=" + readServerProperties(REPLICACATALOG_JDBC_USER) + "," +
+ "Password=" + readServerProperties(REPLICACATALOG_JDBC_PWD) +
+ ",validationQuery=" + readServerProperties(REPLICACATALOG_VALIDATION_QUERY);
+ System.out.println(connectionProperties);
+ Map<String, String> properties = new HashMap<String, String>();
+ properties.put("openjpa.ConnectionDriverName", "org.apache.commons.dbcp.BasicDataSource");
+ properties.put("openjpa.ConnectionProperties", connectionProperties);
+ properties.put("openjpa.DynamicEnhancementAgent", "true");
+ properties.put("openjpa.RuntimeUnenhancedClasses", "unsupported");
+ properties.put("openjpa.RemoteCommitProvider","sjvm");
+ properties.put("openjpa.Log","DefaultLevel=INFO, Runtime=INFO, Tool=INFO, SQL=INFO");
+ properties.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
+ properties.put("openjpa.jdbc.QuerySQLCache", "false");
+ properties.put("openjpa.ConnectionFactoryProperties", "PrettyPrint=true, PrettyPrintLineLength=72," +
+ " PrintParameters=true, MaxActive=10, MaxIdle=5, MinIdle=2, MaxWait=31536000, autoReconnect=true");
+ factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME, properties);
+ }
+ dataCatEntityManager = factory.createEntityManager();
+ return dataCatEntityManager;
+ }
+
+ private static String readServerProperties (String propertyName) throws ApplicationSettingsException {
+ try {
+ return ServerSettings.getSetting(propertyName);
+ } catch (ApplicationSettingsException e) {
+ logger.error("Unable to read airavata-server.properties...", e);
+ throw new ApplicationSettingsException("Unable to read airavata-server.properties...");
+ }
+ }
+
+}

MODIFY
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java
@@ -3,6 +3,7 @@ package org.apache.airavata.registry.core.utils;
import org.apache.airavata.model.user.UserProfile;
import org.apache.airavata.registry.core.entities.appcatalog.*;
+import org.apache.airavata.registry.core.entities.replicacatalog.DataProductEntity;
public interface QueryConstants {
@@ -37,4 +38,10 @@ public interface QueryConstants {
"WHERE BQ.groupResourceProfileId LIKE : " + DBConstants.GroupResourceProfile.GROUP_RESOURCE_PROFILE_ID;
String FIND_ALL_GROUP_COMPUTE_RESOURCE_POLICY = "SELECT CR FROM "+ ComputeResourcePolicyEntity.class.getSimpleName() + " CR " +
"WHERE CR.groupResourceProfileId LIKE : " + DBConstants.GroupResourceProfile.GROUP_RESOURCE_PROFILE_ID;
+
+ String FIND_ALL_CHILD_DATA_PRODUCTS = "SELECT DP FROM " + DataProductEntity.class.getSimpleName() + " DP " +
+ "WHERE DP.parentProductUri LIKE: " + DBConstants.DataProduct.PARENT_PRODUCT_URI;
+ String FIND_DATA_PRODUCT_BY_NAME = "SELECT DP FROM " + DataProductEntity.class.getSimpleName() + " DP " +
+ "WHERE DP.gatewayId LIKE: " + DBConstants.DataProduct.GATEWAY_ID + " AND DP.ownerName LIKE: " +
+ DBConstants.DataProduct.OWNER_NAME + "AND dp.productName LIKE: " + DBConstants.DataProduct.PRODUCT_NAME;
}

MODIFY
modules/registry-refactoring/src/main/resources/META-INF/persistence.xml
modules/registry-refactoring/src/main/resources/META-INF/persistence.xml
<!--<class>org.apache.airavata.registry.core.entities.workflowcatalog.WorkflowInputEntity</class>-->
<!--<class>org.apache.airavata.registry.core.entities.workflowcatalog.WorkflowOutputEntity</class>-->
<!--<class>org.apache.airavata.registry.core.entities.workflowcatalog.WorkflowStatusEntity</class>-->
- <!--<class>org.apache.airavata.registry.core.entities.replicacatalog.DataProductEntity</class>-->
- <!--<class>org.apache.airavata.registry.core.entities.replicacatalog.DataProductMetadataEntity</class>-->
- <!--<class>org.apache.airavata.registry.core.entities.replicacatalog.DataReplicaLocationEntity</class>-->
- <!--<class>org.apache.airavata.registry.core.entities.replicacatalog.DataReplicaMetadataEntity</class>-->
+ <class>org.apache.airavata.registry.core.entities.replicacatalog.ConfigurationEntity</class>
+ <class>org.apache.airavata.registry.core.entities.replicacatalog.DataProductEntity</class>
+ <class>org.apache.airavata.registry.core.entities.replicacatalog.DataProductMetadataEntity</class>
+ <class>org.apache.airavata.registry.core.entities.replicacatalog.DataReplicaLocationEntity</class>
+ <class>org.apache.airavata.registry.core.entities.replicacatalog.DataReplicaMetadataEntity</class>
<class>org.apache.airavata.registry.core.entities.appcatalog.GridftpDataMovementEntity</class>
<class>org.apache.airavata.registry.core.entities.appcatalog.ResourceJobManagerEntity</class>
<class>org.apache.airavata.registry.core.entities.appcatalog.ComputeResourceEntity</class>

ADD
modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/replicacatalog/DataProductRepositoryTest.java
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.airavata.registry.core.repositories.replicacatalog;
+
+import org.apache.airavata.registry.core.repositories.util.Initialize;
+import org.apache.airavata.registry.cpi.ReplicaCatalogException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+
+public class DataProductRepositoryTest {
+
+ private static Initialize initialize;
+ private DataProductRepository dataProductRepository;
+ private String gatewayId = "testGateway";
+ private static final Logger logger = LoggerFactory.getLogger(DataProductRepositoryTest.class);
+
+ @Before
+ public void setUp() {
+ try {
+ initialize = new Initialize("replicacatalog-derby.sql");
+ initialize.initializeDB();
+ dataProductRepository = new DataProductRepository();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ System.out.println("********** TEAR DOWN ************");
+ initialize.stopDerbyServer();
+ }
+
+ @Test
+ public void DataProductRepositoryTest() throws ReplicaCatalogException {
+
+ }
+
+}

ADD
modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/replicacatalog/DataReplicaLocationRepositoryTest.java
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.airavata.registry.core.repositories.replicacatalog;
+
+import org.apache.airavata.registry.core.repositories.util.Initialize;
+import org.apache.airavata.registry.cpi.ReplicaCatalogException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+
+public class DataReplicaLocationRepositoryTest {
+
+ private static Initialize initialize;
+ private DataReplicaLocationRepository dataReplicaLocationRepository;
+ private String gatewayId = "testGateway";
+ private static final Logger logger = LoggerFactory.getLogger(DataReplicaLocationRepositoryTest.class);
+
+ @Before
+ public void setUp() {
+ try {
+ initialize = new Initialize("replicacatalog-derby.sql");
+ initialize.initializeDB();
+ dataReplicaLocationRepository = new DataReplicaLocationRepository();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ System.out.println("********** TEAR DOWN ************");
+ initialize.stopDerbyServer();
+ }
+
+ @Test
+ public void DataProductRepositoryTest() throws ReplicaCatalogException {
+
+ }
+
+}

Adding Repository classes and tests