http://git-wip-us.apache.org/repos/asf/airavata/blob/ad06b474/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/Committer.java ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/Committer.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/Committer.java new file mode 100644 index 0000000..07f8244 --- /dev/null +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/Committer.java @@ -0,0 +1,27 @@ +/* + * + * 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; + +@FunctionalInterface +public interface Committer<T, R> { + + R commit(T t); +} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/ad06b474/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/JPAUtils.java ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/JPAUtils.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/JPAUtils.java new file mode 100644 index 0000000..382d66b --- /dev/null +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/JPAUtils.java @@ -0,0 +1,82 @@ +/* + * + * 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; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.persistence.*; +import java.util.HashMap; +import java.util.Map; + +public class JPAUtils { + private final static Logger logger = LoggerFactory.getLogger(JPAUtils.class); + private static final String PERSISTENCE_UNIT_NAME = "airavata_catalog"; + @PersistenceUnit(unitName = "airavata_catalog") + protected static EntityManagerFactory factory; + @PersistenceContext(unitName = "airavata_catalog") + private static EntityManager entityManager; + + public static EntityManager getEntityManager(){ + if (factory == null) { + //FIXME + String connectionProperties = "DriverClassName=com.mysql.jdbc.Driver," + + "Url=jdbc:mysql://localhost:3306/airavata_catalog," + + "Username=root," + + "Password="; + logger.info(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", "warn"); + 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); + } + + entityManager = factory.createEntityManager(); + return entityManager; + } + + public static <R> R execute(Committer<EntityManager, R> committer){ + EntityManager entityManager = JPAUtils.getEntityManager(); + 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(); + } + } + } + + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/ad06b474/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/ObjectMapperSingleton.java ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/ObjectMapperSingleton.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/ObjectMapperSingleton.java new file mode 100644 index 0000000..9189460 --- /dev/null +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/ObjectMapperSingleton.java @@ -0,0 +1,39 @@ +/* + * + * 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; + +import org.dozer.DozerBeanMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ObjectMapperSingleton extends DozerBeanMapper{ + private final static Logger logger = LoggerFactory.getLogger(ObjectMapperSingleton.class); + + private static ObjectMapperSingleton instance; + + private ObjectMapperSingleton(){} + + public static ObjectMapperSingleton getInstance(){ + if(instance == null) + instance = new ObjectMapperSingleton(); + return instance; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/ad06b474/modules/registry-refactoring/src/main/resources/META-INF/persistence.xml ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/main/resources/META-INF/persistence.xml b/modules/registry-refactoring/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000..8c6bddb --- /dev/null +++ b/modules/registry-refactoring/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<!--* + * + * 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. + * +* --> +<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0"> + <persistence-unit name="airavata_catalog"> + <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> + <class>org.apache.airavata.registry.core.entities.workspacecatalog.GatewayEntity</class> + <class>org.apache.airavata.registry.core.entities.workspacecatalog.UserProfileEntity</class> + <class>org.apache.airavata.registry.core.entities.workspacecatalog.NSFDemographicsEntity</class> + <class>org.apache.airavata.registry.core.entities.workspacecatalog.NotificationEntity</class> + <class>org.apache.airavata.registry.core.entities.workspacecatalog.ProjectEntity</class> + <class>org.apache.airavata.registry.core.entities.expcatalog.ExperimentEntity</class> + <exclude-unlisted-classes>true</exclude-unlisted-classes> + </persistence-unit> +</persistence> http://git-wip-us.apache.org/repos/asf/airavata/blob/ad06b474/modules/registry-refactoring/src/main/resources/experiment_catalog.sql ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/main/resources/experiment_catalog.sql b/modules/registry-refactoring/src/main/resources/experiment_catalog.sql new file mode 100644 index 0000000..95b7c54 --- /dev/null +++ b/modules/registry-refactoring/src/main/resources/experiment_catalog.sql @@ -0,0 +1,110 @@ + +CREATE TABLE IF NOT EXISTS EXPERIMENT( + EXPERIMENT_ID VARCHAR (255), + PROJECT_ID VARCHAR (255), + GATEWAY_ID VARCHAR (255), + EXPERIMENT_TYPE VARCHAR (255), + USER_ID VARCHAR (255), + EXPERIMENT_NAME VARCHAR (255), + CREATION_TIME BIGINT, + DESCRIPTION VARCHAR (255), + EXECUTION_ID VARCHAR (255), + GATEWAY_EXECUTION_ID VARCHAR (255), + GATEWAY_INSTANCE_ID VARCHAR (255), + ENABLE_EMAIL_NOTIFICATION TINYINT, + PRIMARY KEY (EXPERIMENT_ID), + FOREIGN KEY (PROJECT_ID) REFERENCES PROJECT(PROJECT_ID), + FOREIGN KEY (GATEWAY_ID) REFERENCES GATEWAY(GATEWAY_ID), + FOREIGN KEY (USER_ID) REFERENCES USER_PROFILE(USER_ID) +) + +CREATE TABLE IF NOT EXISTS EXPERIMENT_EMAIL ( + EXPERIMENT_ID VARCHAR (255), + EMAIL VARCHAR (255), + PRIMARY KEY (EXPERIMENT_ID, EMAIL), + FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS USER_CONFIGURATION( + EXPERIMENT_ID VARCHAR (255), + AIRAVATA_AUTO_SCHEDULE TINYINT, + OVERRIDE_MANUAL_SCHEDULED_PARAMS TINYINT, + THROTTLE_RESOURCE TINYINT, + USER_DN VARCHAR (255), + GENERATE_CERT TINYINT, + STORAGE_ID VARCHAR (255), + EXPERIMENT_DATA_DIR VARCHAR (255), + PRIMARY KEY (EXPERIMENT_ID), + FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE +) + +CREATE TABLE IF NOT EXISTS COMPUTE_RESOURCE_SCHEDULING( + EXPERIMENT_ID VARCHAR (255), + RESOURCE_HOST_ID VARCHAR (255), + CPU_COUNT INT, + NODE_COUNT INT, + NUMBER_OF_THREADS INT, + QUEUE_NAME VARCHAR (255), + WALL_TIME_LIMIT INT, + TOTAL_PHYSICAL_MEMORY INT, + CHESSIS_NUMBER VARCHAR (255), + STATIC_WORKING_DIRECTORY VARCHAR (255), + OVERRIDE_LOGIN_USERNAME VARCHAR (255), + OVERRIDE_SCRATCH_LOCATION VARCHAR (255), + OVERRIDE_ALLOCATION_PROJECT_NUMBER VARCHAR (255), + PRIMARY KEY (EXPERIMENT_ID), + FOREIGN KEY (EXPERIMENT_ID) REFERENCES USER_CONFIGURATION(EXPERIMENT_ID) +) + +CREATE TABLE IF NOT EXISTS EXPERIMENT_INPUT( + EXPERIMENT_ID VARCHAR (255), + INPUT_NAME VARCHAR (255), + INPUT_VALUE VARCHAR (255), + INPUT_TYPE VARCHAR (255), + APPLICATION_ARGUMENT VARCHAR (255), + STANDARD_INPUT TINYINT, + USER_FRIENDLY_DESCRIPTION VARCHAR (255), + METADATA VARCHAR (4096), + INPUT_ORDER INT, + REQUIRED TINYINT, + REQUIRED_TO_ADDED_TO_COMMANDLINE TINYINT, + DATA_STAGED TINYINT, + STORAGE_RESOURCE_ID VARCHAR (255), + PRIMARY KEY (EXPERIMENT_ID,INPUT_NAME), + FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) +) + +CREATE TABLE IF NOT EXISTS EXPERIMENT_OUTPUT( + EXPERIMENT_ID VARCHAR (255), + OUTPUT_NAME VARCHAR (255), + OUTPUT_VALUE VARCHAR (255), + OUTPUT_TYPE VARCHAR (255), + APPLICATION_ARGUMENT (255), + REQUIRED TINYINT, + REQUIRED_TO_ADDED_TO_COMMANDLINE TINYINT, + DATA_MOVEMENT TINYINT, + LOCATION VARCHAR (255), + SEARCH_QUERY VARCHAR (255), + OUTPUT_STREAMING TINYINT, + STORAGE_RESOURCE_ID VARCHAR (255), + PRIMARY KEY (EXPERIMENT_ID,OUTPUT_NAME), + FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) +) + +CREATE TABLE IF NOT EXISTS EXPERIMENT_ERROR( + ERROR_ID VARCHAR (255), + EXPERIMENT_ID VARCHAR (255), + CREATION_TIME BIGINT, + ACTUAL_ERROR_MESSAGE VARCHAR (255), + USER_FRIENDLY_MESSAGE VARCHAR (255), + TRANSIENT_OR_PERSISTENT TINYINT, + PRIMARY KEY (ERROR_ID), + FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) +) + +CREATE TABLE IF NOT EXISTS EXPERIMENT_ERROR_ROOT_CAUSE_ERROR_ID( + ERROR_ID VARCHAR (255), + ROOT_CAUSE_ERROR_ID VARCHAR (255), + PRIMARY KEY (ERROR_ID, ROOT_CAUSE_ERROR_ID), + FOREIGN KEY(ERROR_ID) REFERENCES EXPERIMENT_ERROR(ERROR_ID) +) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/ad06b474/modules/registry-refactoring/src/main/resources/workspace_catalog.sql ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/main/resources/workspace_catalog.sql b/modules/registry-refactoring/src/main/resources/workspace_catalog.sql new file mode 100644 index 0000000..4ea7cd2 --- /dev/null +++ b/modules/registry-refactoring/src/main/resources/workspace_catalog.sql @@ -0,0 +1,125 @@ + +CREATE TABLE IF NOT EXISTS GATEWAY( + GATEWAY_ID VARCHAR (255), + GATEWAY_NAME VARCHAR (255), + GATEWAY_DOMAIN VARCHAR (255), + EMAIL_ADDRESS VARCHAR (255), + GATEWAY_APPROVAL_STATUS VARCHAR (255), + GATEWAY_ACRONYM VARCHAR (255), + GATEWAY_URL VARCHAR (255), + GATEWAY_PUBLIC_ABSTRACT TEXT, + REVIEW_PROPOSAL_DESCRIPTION TEXT, + GATEWAY_ADMIN_FIRST_NAME VARCHAR(255), + GATEWAY_ADMIN_LAST_NAME VARCHAR(255), + GATEWAY_ADMIN_EMAIL VARCHAR(255), + IDENTITY_SERVER_USERNAME VARCHAR(255), + IDENTITY_SERVER_PASSWORD_TOKEN VARCHAR(255), + DECLINED_REASON VARCHAR(255), + OAUTH_CLIENT_ID VARCHAR(255), + OAUTH_CLIENT_SECRET VARCHAR(255), + REQUEST_CREATION_TIME BIGINT, + REQUESTER_USERNAME VARCHAR(255), + PRIMARY KEY (GATEWAY_ID) +); + +CREATE TABLE IF NOT EXISTS NOTIFICATION ( + NOTIFICATION_ID VARCHAR (255), + GATEWAY_ID VARCHAR (255), + TITLE VARCHAR (255), + NOTIFICATION_MESSAGE TEXT, + CREATION_TIME BIGINT, + PUBLISHED_TIME BIGINT, + EXPIRATION_TIME BIGINT, + PRIORITY VARCHAR (255), + PRIMARY KEY (NOTIFICATION_ID), + FOREIGN KEY (GATEWAY_ID) REFERENCES GATEWAY(GATEWAY_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS USER_PROFILE ( + AIRAVATA_INTERNAL_USER_ID VARCHAR (255), + USER_ID VARCHAR (255), + GATEWAY_ID VARCHAR (255), + USER_MODEL_VERSION VARCHAR (255), + USER_NAME VARCHAR (255), + ORCID_ID VARCHAR (255), + COUNTRY VARCHAR (255), + HOME_ORGANIZATION VARCHAR (255), + ORIGINATION_AFFILIATION VARCHAR (255), + CREATION_TIME BIGINT, + LAST_ACCESS_TIME BIGINT, + VALID_UNTIL BIGINT, + STATE VARCHAR (255), + COMMENTS TEXT, + GPG_KEY VARCHAR (8192), + TIME_ZONE VARCHAR (255), + PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID), + FOREIGN KEY (GATEWAY_ID) REFERENCES GATEWAY(GATEWAY_ID) +); + +CREATE TABLE IF NOT EXISTS USER_PROFILE_EMAIL ( + AIRAVATA_INTERNAL_USER_ID VARCHAR (255), + EMAIL VARCHAR (255), + PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID, EMAIL), + FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS USER_PROFILE_PHONE ( + AIRAVATA_INTERNAL_USER_ID VARCHAR (255), + PHONE VARCHAR (255), + PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID, PHONE ), + FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS USER_PROFILE_NATIONALITY ( + AIRAVATA_INTERNAL_USER_ID VARCHAR (255), + NATIONALITY VARCHAR (255), + PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID, NATIONALITY ), + FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS USER_PROFILE_LABELED_URI ( + AIRAVATA_INTERNAL_USER_ID VARCHAR (255), + LABELED_URI VARCHAR (255), + PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID, LABELED_URI ), + FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS NSF_DEMOGRAPHIC ( + AIRAVATA_INTERNAL_USER_ID VARCHAR (255), + GENDER VARCHAR (255), + PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID), + FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS NSF_DEMOGRAPHIC_ETHNICITY ( + AIRAVATA_INTERNAL_USER_ID VARCHAR (255), + ETHNICITY VARCHAR (255), + PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID, ETHNICITY ), + FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES NSF_DEMOGRAPHIC(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS NSF_DEMOGRAPHIC_RACE ( + AIRAVATA_INTERNAL_USER_ID VARCHAR (255), + RACE VARCHAR (255), + PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID, RACE ), + FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES NSF_DEMOGRAPHIC(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS NSF_DEMOGRAPHIC_DISABILITY ( + AIRAVATA_INTERNAL_USER_ID VARCHAR (255), + DISABILITY VARCHAR (255), + PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID, DISABILITY ), + FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES NSF_DEMOGRAPHIC(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS PROJECT( + PROJECT_ID VARCHAR (255), + OWNER VARCHAR (255), + GATEWAY_ID VARCHAR (255), + PROJECT_NAME VARCHAR (255), + DESCRIPTION VARCHAR (255), + CREATION_TIME BIGINT, + PRIMARY KEY (PROJECT_ID), + FOREIGN KEY(OWNER) REFERENCES USER_PROFILE(AIRAVATA_INTERNAL_USER_ID), + FOREIGN KEY(GATEWAY_ID) REFERENCES GATEWAY(GATEWAY_ID) +); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/ad06b474/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/RepositoryTest.java ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/RepositoryTest.java b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/RepositoryTest.java new file mode 100644 index 0000000..3561d5a --- /dev/null +++ b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/RepositoryTest.java @@ -0,0 +1,60 @@ +/* + * + * 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; + +import org.apache.airavata.model.workspace.Gateway; +import org.apache.airavata.model.workspace.GatewayApprovalStatus; +import org.apache.airavata.model.workspace.Notification; +import org.apache.airavata.registry.core.entities.workspacecatalog.GatewayEntity; +import org.apache.airavata.registry.core.entities.workspacecatalog.NotificationEntity; +import org.apache.airavata.registry.core.repositories.workspacecatalog.GatewayRepository; +import org.apache.airavata.registry.core.repositories.workspacecatalog.NotificationRepository; +import org.junit.Assert; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.UUID; + +public class RepositoryTest { + private final static Logger logger = LoggerFactory.getLogger(RepositoryTest.class); + + @Test + public void test(){ + Gateway gateway = new Gateway(); + gateway.setGatewayApprovalStatus(GatewayApprovalStatus.ACTIVE); + gateway.setGatewayId("test.com" + System.currentTimeMillis()); + gateway.setDomain("test.com"); + + GatewayRepository gatewayRepository = new GatewayRepository(Gateway.class, GatewayEntity.class); + gateway = gatewayRepository.create(gateway); + Assert.assertTrue(!gateway.getGatewayId().isEmpty()); + + Notification notification = new Notification(); + notification.setGatewayId(gateway.getGatewayId()); + notification.setNotificationId(UUID.randomUUID().toString()); + + NotificationRepository notificationRepository = new NotificationRepository(Notification.class, NotificationEntity.class); + notificationRepository.create(notification); + + notificationRepository.get(notification.getNotificationId()); + } +} \ No newline at end of file