http://git-wip-us.apache.org/repos/asf/airavata/blob/208e5d38/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/ComponentStatusRepository.java ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/ComponentStatusRepository.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/ComponentStatusRepository.java new file mode 100644 index 0000000..753c36f --- /dev/null +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/ComponentStatusRepository.java @@ -0,0 +1,37 @@ +/* + * + * 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.workflowcatalog; + +import org.apache.airavata.model.ComponentStatus; +import org.apache.airavata.registry.core.entities.workflowcatalog.ComponentStatusEntity; +import org.apache.airavata.registry.core.repositories.AbstractRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ComponentStatusRepository extends AbstractRepository<ComponentStatus, ComponentStatusEntity, String> { + + + private final static Logger logger = LoggerFactory.getLogger(ComponentStatusRepository.class); + + public ComponentStatusRepository(Class<ComponentStatus> thriftGenericClass, Class<ComponentStatusEntity> dbEntityGenericClass) { + super(thriftGenericClass, dbEntityGenericClass); + } +}
http://git-wip-us.apache.org/repos/asf/airavata/blob/208e5d38/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/EdgeRepository.java ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/EdgeRepository.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/EdgeRepository.java new file mode 100644 index 0000000..df55931 --- /dev/null +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/EdgeRepository.java @@ -0,0 +1,38 @@ +/* + * + * 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.workflowcatalog; + +import org.apache.airavata.model.EdgeModel; +import org.apache.airavata.registry.core.entities.workflowcatalog.EdgeEntity; +import org.apache.airavata.registry.core.entities.workflowcatalog.EdgePK; +import org.apache.airavata.registry.core.repositories.AbstractRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class EdgeRepository extends AbstractRepository<EdgeModel, EdgeEntity, EdgePK> { + + + private final static Logger logger = LoggerFactory.getLogger(EdgeRepository.class); + + public EdgeRepository(Class<EdgeModel> thriftGenericClass, Class<EdgeEntity> dbEntityGenericClass) { + super(thriftGenericClass, dbEntityGenericClass); + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/208e5d38/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/WorkflowRepository.java ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/WorkflowRepository.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/WorkflowRepository.java new file mode 100644 index 0000000..b702342 --- /dev/null +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/WorkflowRepository.java @@ -0,0 +1,37 @@ +/* + * + * 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.workflowcatalog; + +import org.apache.airavata.model.WorkflowModel; +import org.apache.airavata.registry.core.entities.workflowcatalog.WorkflowEntity; +import org.apache.airavata.registry.core.repositories.AbstractRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class WorkflowRepository extends AbstractRepository<WorkflowModel, WorkflowEntity, String> { + + private final static Logger logger = LoggerFactory.getLogger(WorkflowRepository.class); + + + public WorkflowRepository(Class<WorkflowModel> thriftGenericClass, Class<WorkflowEntity> dbEntityGenericClass) { + super(thriftGenericClass, dbEntityGenericClass); + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/208e5d38/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workspacecatalog/GatewayRepository.java ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workspacecatalog/GatewayRepository.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workspacecatalog/GatewayRepository.java new file mode 100644 index 0000000..9a1c6d6 --- /dev/null +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workspacecatalog/GatewayRepository.java @@ -0,0 +1,36 @@ +/* + * + * 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.workspacecatalog; + +import org.apache.airavata.model.workspace.Gateway; +import org.apache.airavata.registry.core.entities.workspacecatalog.GatewayEntity; +import org.apache.airavata.registry.core.repositories.AbstractRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class GatewayRepository extends AbstractRepository<Gateway, GatewayEntity, String> { + private final static Logger logger = LoggerFactory.getLogger(GatewayRepository.class); + + public GatewayRepository(Class<Gateway> thriftGenericClass, Class<GatewayEntity> dbEntityGenericClass) { + super(thriftGenericClass, dbEntityGenericClass); + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/208e5d38/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workspacecatalog/NotificationRepository.java ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workspacecatalog/NotificationRepository.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workspacecatalog/NotificationRepository.java new file mode 100644 index 0000000..8332024 --- /dev/null +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workspacecatalog/NotificationRepository.java @@ -0,0 +1,35 @@ +/* + * + * 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.workspacecatalog; + +import org.apache.airavata.model.workspace.Notification; +import org.apache.airavata.registry.core.entities.workspacecatalog.NotificationEntity; +import org.apache.airavata.registry.core.repositories.AbstractRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class NotificationRepository extends AbstractRepository<Notification, NotificationEntity, String> { + private final static Logger logger = LoggerFactory.getLogger(NotificationRepository.class); + + public NotificationRepository(Class thriftGenericClass, Class dbEntityGenericClass) { + super(thriftGenericClass, dbEntityGenericClass); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/208e5d38/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workspacecatalog/ProjectRepository.java ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workspacecatalog/ProjectRepository.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workspacecatalog/ProjectRepository.java new file mode 100644 index 0000000..eebf5fb --- /dev/null +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workspacecatalog/ProjectRepository.java @@ -0,0 +1,35 @@ +/* + * + * 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.workspacecatalog; + +import org.apache.airavata.model.workspace.Project; +import org.apache.airavata.registry.core.entities.workspacecatalog.ProjectEntity; +import org.apache.airavata.registry.core.repositories.AbstractRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ProjectRepository extends AbstractRepository<Project, ProjectEntity, String> { + private final static Logger logger = LoggerFactory.getLogger(ProjectRepository.class); + + public ProjectRepository(Class<Project> thriftGenericClass, Class<ProjectEntity> dbEntityGenericClass) { + super(thriftGenericClass, dbEntityGenericClass); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/208e5d38/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workspacecatalog/UserProfileRepository.java ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workspacecatalog/UserProfileRepository.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workspacecatalog/UserProfileRepository.java new file mode 100644 index 0000000..de0f99e --- /dev/null +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workspacecatalog/UserProfileRepository.java @@ -0,0 +1,88 @@ +/* + * + * 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.workspacecatalog; + +import org.apache.airavata.model.user.UserProfile; +import org.apache.airavata.registry.core.entities.workspacecatalog.UserProfileEntity; +import org.apache.airavata.registry.core.repositories.AbstractRepository; +import org.apache.airavata.registry.core.utils.QueryConstants; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class UserProfileRepository extends AbstractRepository<UserProfile, UserProfileEntity, String> { + private final static Logger logger = LoggerFactory.getLogger(UserProfileRepository.class); + + public UserProfileRepository(Class<UserProfile> thriftGenericClass, Class<UserProfileEntity> dbEntityGenericClass) { + super(thriftGenericClass, dbEntityGenericClass); + } + + @Override + public List<UserProfile> select(String query, int offset, int limit) { + throw new UnsupportedOperationException("Due to performance overheads this method is not supported. Instead use" + + " UserProfileSummaryRepository"); + } + + public UserProfile getUserProfileByIdAndGateWay(String userId, String gatewayId) { + + UserProfile userProfile = null; + + Map<String, Object> queryParam = new HashMap<String, Object>(); + queryParam.put(UserProfile._Fields.USER_ID.getFieldName(), userId); + queryParam.put(UserProfile._Fields.GATEWAY_ID.getFieldName(), gatewayId); + List<UserProfile> resultList = select(QueryConstants.FIND_USER_PROFILE_BY_USER_ID, 0, 1, queryParam); + + if (resultList != null && resultList.size() > 0) + userProfile = resultList.get(0); + + + return userProfile; + } + + public List<UserProfile> getAllUserProfilesInGateway(String gatewayId, int offset, int limit) { + + Map<String, Object> queryParam = new HashMap<String, Object>(); + queryParam.put(UserProfile._Fields.GATEWAY_ID.getFieldName(), gatewayId); + + List<UserProfile> resultList = select(QueryConstants.FIND_ALL_USER_PROFILES_BY_GATEWAY_ID, limit, offset, queryParam); + + return resultList; + } + + public UserProfile getUserProfileByNameAndGateWay(String name, String gatewayId) { + + UserProfile userProfile = null; + + Map<String, Object> queryParam = new HashMap<String, Object>(); + queryParam.put(UserProfile._Fields.USER_NAME.getFieldName(), name); + queryParam.put(UserProfile._Fields.GATEWAY_ID.getFieldName(), gatewayId); + List<UserProfile> resultList = select(QueryConstants.FIND_USER_PROFILE_BY_USER_NAME, 0, 1, queryParam); + + if (resultList != null && resultList.size() > 0) + userProfile = resultList.get(0); + + + return userProfile; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/208e5d38/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/208e5d38/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..05098c4 --- /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=root"; + 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/208e5d38/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/208e5d38/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..68861e4 --- /dev/null +++ b/modules/registry-refactoring/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,131 @@ +<?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.ComputeResourceSchedulingEntity</class> + <class>org.apache.airavata.registry.core.entities.expcatalog.ExperimentEntity</class> + <class>org.apache.airavata.registry.core.entities.expcatalog.ExperimentErrorEntity</class> + <class>org.apache.airavata.registry.core.entities.expcatalog.ExperimentInputEntity</class> + <class>org.apache.airavata.registry.core.entities.expcatalog.ExperimentOutputEntity</class> + <class>org.apache.airavata.registry.core.entities.expcatalog.ExperimentStatusEntity</class> + <class>org.apache.airavata.registry.core.entities.expcatalog.UserConfigurationEntity</class> + <class>org.apache.airavata.registry.core.entities.expcatalog.ProcessEntity</class> + <class>org.apache.airavata.registry.core.entities.expcatalog.ProcessErrorEntity</class> + <class>org.apache.airavata.registry.core.entities.expcatalog.ProcessInputEntity</class> + <class>org.apache.airavata.registry.core.entities.expcatalog.ProcessOutputEntity</class> + <class>org.apache.airavata.registry.core.entities.expcatalog.ProcessResourceSchedulingEntity</class> + <class>org.apache.airavata.registry.core.entities.expcatalog.ProcessStatusEntity</class> + <class>org.apache.airavata.registry.core.entities.expcatalog.TaskEntity</class> + <class>org.apache.airavata.registry.core.entities.expcatalog.TaskErrorEntity</class> + <class>org.apache.airavata.registry.core.entities.expcatalog.TaskStatusEntity</class> + <class>org.apache.airavata.registry.core.entities.expcatalog.JobEntity</class> + <class>org.apache.airavata.registry.core.entities.expcatalog.JobStatusEntity</class> + + <class>org.apache.airavata.registry.core.entities.workflowcatalog.WorkflowEntity</class> + <class>org.apache.airavata.registry.core.entities.workflowcatalog.EdgeEntity</class> + <class>org.apache.airavata.registry.core.entities.workflowcatalog.ComponentStatusEntity</class> + <class>org.apache.airavata.registry.core.entities.workflowcatalog.NodeEntity</class> + <class>org.apache.airavata.registry.core.entities.workflowcatalog.PortEntity</class> + <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.appcatalog.GridftpDataMovementEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.ResourceJobManagerEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.ComputeResourceEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.ApplicationModuleEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.ApplicationDeploymentEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.ApplicationInterfaceEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.GatewayProfileEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.StorageResourceEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.ScpDataMovementEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.SshJobSubmissionEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.GlobusSubmissionEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.GsisshSubmissionEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.GridftpEndpointEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.ComputeResourcePreferenceEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.JobSubmissionInterfaceEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.DataMovementInterfaceEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.StorageInterfaceEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.LocalSubmissionEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.GlobusGkEndpointEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.UnicoreDatamovementEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.UnicoreSubmissionEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.GsisshPostjobcommandEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.GsisshPrejobcommandEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.GsisshExportEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.HostIpaddressEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.HostAliasEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.LibraryApendPathEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.LibraryPrependPathEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.AppEnvironmentEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.PrejobCommandEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.PostjobCommandEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.AppModuleMappingEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.ApplicationInputEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.ApplicationOutputEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.BatchQueueEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.ComputeResourceFileSystemEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.JobManagerCommandEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.ParallelismCommandEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.LocalDataMovementEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.DataStoragePreferenceEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.GlobusGkEndpointPK</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.GsisshPostjobcommandPK</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.GsisshPrejobcommandPK</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.GsisshExportPK</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.HostIpaddressPK</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.HostAliasPK</class> + <class>org.apache.airavata.registry.core.entities.workflowcatalog.WorkflowInputPK</class> + <class>org.apache.airavata.registry.core.entities.workflowcatalog.WorkflowOutputPK</class> + <class>org.apache.airavata.registry.core.entities.workflowcatalog.WorkflowStatusPK</class> + <class>org.apache.airavata.registry.core.entities.workflowcatalog.EdgePK</class> + <class>org.apache.airavata.registry.core.entities.workflowcatalog.PortPK</class> + <class>org.apache.airavata.registry.core.entities.workflowcatalog.NodePK</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.GridftpEndpointPK</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.PrejobCommandPK</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.PostjobCommandPK</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.AppModuleMappingPK</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.ApplicationInputPK</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.ApplicationOutputPK</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.ComputeResourcePreferencePK</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.BatchQueuePK</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.ComputeResourceFileSystemPK</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.JobSubmissionInterfacePK</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.DataMovementInterfacePK</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.StorageInterfacePK</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.JobManagerCommandPK</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.ParallelismCommandPK</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.DataStoragePreferencePK</class> + + <exclude-unlisted-classes>true</exclude-unlisted-classes> + </persistence-unit> +</persistence> http://git-wip-us.apache.org/repos/asf/airavata/blob/208e5d38/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..3140cd1 --- /dev/null +++ b/modules/registry-refactoring/src/main/resources/experiment_catalog.sql @@ -0,0 +1,285 @@ + +CREATE TABLE IF NOT EXISTS EXPCAT_EXPERIMENT( + EXPERIMENT_ID VARCHAR (255), + PROJECT_ID VARCHAR (255), + GATEWAY_ID VARCHAR (255), + EXPERIMENT_TYPE VARCHAR (255), + USER_NAME 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(1), + PRIMARY KEY (EXPERIMENT_ID), + FOREIGN KEY (PROJECT_ID) REFERENCES WORKSPACE_PROJECT(PROJECT_ID) ON DELETE CASCADE, + FOREIGN KEY (GATEWAY_ID) REFERENCES WORKSPACE_GATEWAY(GATEWAY_ID) ON DELETE CASCADE, + FOREIGN KEY (USER_NAME) REFERENCES WORKSPACE_USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS EXPCAT_EXPERIMENT_EMAIL ( + EXPERIMENT_ID VARCHAR (255), + EMAIL VARCHAR (255), + PRIMARY KEY (EXPERIMENT_ID, EMAIL), + FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPCAT_EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS EXPCAT_USER_CONFIGURATION( + EXPERIMENT_ID VARCHAR (255), + AIRAVATA_AUTO_SCHEDULE TINYINT(1), + OVERRIDE_MANUAL_SCHEDULED_PARAMS TINYINT(1), + THROTTLE_RESOURCE TINYINT(1), + USER_DN VARCHAR (255), + GENERATE_CERT TINYINT(1), + STORAGE_ID VARCHAR (255), + EXPERIMENT_DATA_DIR VARCHAR (255), + PRIMARY KEY (EXPERIMENT_ID), + FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPCAT_EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS EXPCAT_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 EXPCAT_USER_CONFIGURATION(EXPERIMENT_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS EXPCAT_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(1), + USER_FRIENDLY_DESCRIPTION VARCHAR (255), + METADATA VARCHAR (4096), + INPUT_ORDER INT, + REQUIRED TINYINT(1), + REQUIRED_TO_ADDED_TO_COMMANDLINE TINYINT(1), + DATA_STAGED TINYINT(1), + STORAGE_RESOURCE_ID VARCHAR (255), + PRIMARY KEY (EXPERIMENT_ID,INPUT_NAME), + FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPCAT_EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS EXPCAT_EXPERIMENT_OUTPUT( + EXPERIMENT_ID VARCHAR (255), + OUTPUT_NAME VARCHAR (255), + OUTPUT_VALUE VARCHAR (255), + OUTPUT_TYPE VARCHAR (255), + APPLICATION_ARGUMENT VARCHAR (255), + REQUIRED TINYINT(1), + REQUIRED_TO_ADDED_TO_COMMANDLINE TINYINT(1), + DATA_MOVEMENT TINYINT(1), + LOCATION VARCHAR (255), + SEARCH_QUERY VARCHAR (255), + OUTPUT_STREAMING TINYINT(1), + STORAGE_RESOURCE_ID VARCHAR (255), + PRIMARY KEY (EXPERIMENT_ID,OUTPUT_NAME), + FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPCAT_EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS EXPCAT_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, EXPERIMENT_ID), + FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPCAT_EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS EXPCAT_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 EXPCAT_EXPERIMENT_ERROR(ERROR_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS EXPCAT_EXPERIMENT_STATUS( + EXPERIMENT_ID VARCHAR (255), + STATE VARCHAR (255), + TIME_OF_STATE_CHANGE BIGINT, + REASON VARCHAR (255), + PRIMARY KEY (EXPERIMENT_ID, STATE), + FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPCAT_EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS EXPCAT_PROCESS( + PROCESS_ID VARCHAR (255), + EXPERIMENT_ID VARCHAR (255), + CREATION_TIME BIGINT, + LAST_UPDATE_TIME BIGINT, + PROCESS_DETAIL VARCHAR (255), + APPLICATION_INTERFACE_ID VARCHAR (255), + APPLICATION_DEPLOYMENT_ID VARCHAR (255), + COMPUTE_RESOURCE_ID VARCHAR (255), + TASK_DAG VARCHAR (255), + GATEWAY_EXECUTION_ID VARCHAR (255), + ENABLE_EMAIL_NOTIFICATION TINYINT(1), + STORAGE_RESOURCE_ID VARCHAR (255), + USER_DN VARCHAR (255), + GENERATE_CERT VARCHAR (255), + EXPERIMENT_DATA_DIR VARCHAR (255), + USER_NAME VARCHAR (255), + PRIMARY KEY (PROCESS_ID), + FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPCAT_EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS EXPCAT_PROCESS_EMAIL ( + PROCESS_ID VARCHAR (255), + EMAIL VARCHAR (255), + PRIMARY KEY (PROCESS_ID, EMAIL), + FOREIGN KEY (PROCESS_ID) REFERENCES EXPCAT_PROCESS(PROCESS_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS EXPCAT_PROCESS_RESOURCE_SCHEDULING( + PROCESS_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 (PROCESS_ID), + FOREIGN KEY (PROCESS_ID) REFERENCES EXPCAT_PROCESS(PROCESS_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS EXPCAT_PROCESS_INPUT( + PROCESS_ID VARCHAR (255), + INPUT_NAME VARCHAR (255), + INPUT_VALUE VARCHAR (255), + INPUT_TYPE VARCHAR (255), + APPLICATION_ARGUMENT VARCHAR (255), + STANDARD_INPUT TINYINT(1), + USER_FRIENDLY_DESCRIPTION VARCHAR (255), + METADATA VARCHAR (4096), + INPUT_ORDER INT, + REQUIRED TINYINT(1), + REQUIRED_TO_ADDED_TO_COMMANDLINE TINYINT(1), + DATA_STAGED TINYINT(1), + STORAGE_RESOURCE_ID VARCHAR (255), + PRIMARY KEY (PROCESS_ID,INPUT_NAME), + FOREIGN KEY (PROCESS_ID) REFERENCES EXPCAT_PROCESS(PROCESS_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS EXPCAT_PROCESS_OUTPUT( + PROCESS_ID VARCHAR (255), + OUTPUT_NAME VARCHAR (255), + OUTPUT_VALUE VARCHAR (255), + OUTPUT_TYPE VARCHAR (255), + APPLICATION_ARGUMENT VARCHAR (255), + REQUIRED TINYINT(1), + REQUIRED_TO_ADDED_TO_COMMANDLINE TINYINT(1), + DATA_MOVEMENT TINYINT(1), + LOCATION VARCHAR (255), + SEARCH_QUERY VARCHAR (255), + OUTPUT_STREAMING TINYINT(1), + STORAGE_RESOURCE_ID VARCHAR (255), + PRIMARY KEY (PROCESS_ID,OUTPUT_NAME), + FOREIGN KEY (PROCESS_ID) REFERENCES EXPCAT_PROCESS(PROCESS_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS EXPCAT_PROCESS_ERROR( + ERROR_ID VARCHAR (255), + PROCESS_ID VARCHAR (255), + CREATION_TIME BIGINT, + ACTUAL_ERROR_MESSAGE VARCHAR (255), + USER_FRIENDLY_MESSAGE VARCHAR (255), + TRANSIENT_OR_PERSISTENT TINYINT, + PRIMARY KEY (ERROR_ID, PROCESS_ID), + FOREIGN KEY (PROCESS_ID) REFERENCES EXPCAT_PROCESS(PROCESS_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS EXPCAT_PROCESS_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 EXPCAT_PROCESS_ERROR(ERROR_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS EXPCAT_PROCESS_STATUS( + PROCESS_ID VARCHAR (255), + STATE VARCHAR (255), + TIME_OF_STATE_CHANGE BIGINT, + REASON VARCHAR (255), + PRIMARY KEY (PROCESS_ID, STATE), + FOREIGN KEY (PROCESS_ID) REFERENCES EXPCAT_PROCESS(PROCESS_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS EXPCAT_TASK( + TASK_ID VARCHAR (255), + TASK_TYPE VARCHAR (255), + PARENT_PROCESS_ID VARCHAR (255), + CREATION_TIME BIGINT, + LAST_UPDATE_TIME BIGINT, + TASK_DETAIL VARCHAR (255), + SUB_TASK_MODEL BLOB, + PRIMARY KEY (TASK_ID), + FOREIGN KEY (PARENT_PROCESS_ID) REFERENCES EXPCAT_PROCESS(PROCESS_ID) +); + +CREATE TABLE IF NOT EXISTS EXPCAT_TASK_ERROR( + ERROR_ID VARCHAR (255), + TASK_ID VARCHAR (255), + CREATION_TIME BIGINT, + ACTUAL_ERROR_MESSAGE VARCHAR (255), + USER_FRIENDLY_MESSAGE VARCHAR (255), + TRANSIENT_OR_PERSISTENT TINYINT, + PRIMARY KEY (ERROR_ID, TASK_ID), + FOREIGN KEY (TASK_ID) REFERENCES EXPCAT_TASK(TASK_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS EXPCAT_TASK_STATUS( + TASK_ID VARCHAR (255), + STATE VARCHAR (255), + TIME_OF_STATE_CHANGE BIGINT, + REASON VARCHAR (255), + PRIMARY KEY (TASK_ID, STATE), + FOREIGN KEY (TASK_ID) REFERENCES EXPCAT_TASK(TASK_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS EXPCAT_JOB( + JOB_ID VARCHAR (255), + TASK_ID VARCHAR (255), + PROCESS_ID VARCHAR (255), + JOB_DESCRIPTION VARCHAR (255), + CREATION_TIME BIGINT, + COMPUTE_RESOURCE_CONSUMED VARCHAR (255), + JOB_NAME VARCHAR (255), + WORKING_DIR VARCHAR (255), + STDOUT TEXT, + STDERR TEXT, + EXIT_CODE INT(11), + PRIMARY KEY(JOB_ID), + FOREIGN KEY(TASK_ID) REFERENCES EXPCAT_TASK(TASK_ID), + FOREIGN KEY(PROCESS_ID) REFERENCES EXPCAT_PROCESS(PROCESS_ID) +); + +CREATE TABLE IF NOT EXISTS EXPCAT_JOB_STATUS( + JOB_ID VARCHAR (255), + STATE VARCHAR (255), + TIME_OF_STATE_CHANGE BIGINT, + REASON VARCHAR (255), + PRIMARY KEY (JOB_ID, STATE), + FOREIGN KEY (JOB_ID) REFERENCES EXPCAT_JOB(JOB_ID) ON DELETE CASCADE +); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/208e5d38/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..debdba4 --- /dev/null +++ b/modules/registry-refactoring/src/main/resources/workspace_catalog.sql @@ -0,0 +1,125 @@ + +CREATE TABLE IF NOT EXISTS WORKSPACE_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 WORKSPACE_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 WORKSPACE_GATEWAY(GATEWAY_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS WORKSPACE_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 WORKSPACE_GATEWAY(GATEWAY_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS WORKSPACE_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 WORKSPACE_USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS WORKSPACE_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 WORKSPACE_USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS WORKSPACE_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 WORKSPACE_USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS WORKSPACE_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 WORKSPACE_USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS WORKSPACE_NSF_DEMOGRAPHIC ( + AIRAVATA_INTERNAL_USER_ID VARCHAR (255), + GENDER VARCHAR (255), + PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID), + FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES WORKSPACE_USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS WORKSPACE_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 WORKSPACE_NSF_DEMOGRAPHIC(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS WORKSPACE_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 WORKSPACE_NSF_DEMOGRAPHIC(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS WORKSPACE_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 WORKSPACE_NSF_DEMOGRAPHIC(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS WORKSPACE_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 WORKSPACE_USER_PROFILE(AIRAVATA_INTERNAL_USER_ID), + FOREIGN KEY(GATEWAY_ID) REFERENCES WORKSPACE_GATEWAY(GATEWAY_ID) ON DELETE CASCADE +); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/208e5d38/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/ExperimentRepositoryTest.java ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/ExperimentRepositoryTest.java b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/ExperimentRepositoryTest.java index 8c00e8b..abfaed8 100644 --- a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/ExperimentRepositoryTest.java +++ b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/ExperimentRepositoryTest.java @@ -20,131 +20,138 @@ */ package org.apache.airavata.registry.core.repositories; +import org.apache.airavata.model.experiment.ExperimentModel; +import org.apache.airavata.model.user.UserProfile; +import org.apache.airavata.model.workspace.Gateway; +import org.apache.airavata.model.workspace.GatewayApprovalStatus; +import org.apache.airavata.model.workspace.Project; +import org.apache.airavata.registry.core.entities.expcatalog.ExperimentEntity; +import org.apache.airavata.registry.core.entities.workspacecatalog.GatewayEntity; +import org.apache.airavata.registry.core.entities.workspacecatalog.ProjectEntity; +import org.apache.airavata.registry.core.entities.workspacecatalog.UserProfileEntity; +import org.apache.airavata.registry.core.repositories.expcatalog.ExperimentRepository; +import org.apache.airavata.registry.core.repositories.workspacecatalog.GatewayRepository; +import org.apache.airavata.registry.core.repositories.workspacecatalog.ProjectRepository; +import org.apache.airavata.registry.core.repositories.workspacecatalog.UserProfileRepository; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -//import org.apache.airavata.registry.core.entities.expcatalog.ExperimentEntity; -//import org.apache.airavata.registry.core.entities.workspacecatalog.GatewayEntity; -//import org.apache.airavata.registry.core.entities.workspacecatalog.ProjectEntity; -//import org.apache.airavata.registry.core.entities.workspacecatalog.UserProfileEntity; -//import org.apache.airavata.registry.core.repositories.expcatalog.ExperimentRepository; -//import org.apache.airavata.registry.core.repositories.workspacecatalog.GatewayRepository; -//import org.apache.airavata.registry.core.repositories.workspacecatalog.ProjectRepository; -//import org.apache.airavata.registry.core.repositories.workspacecatalog.UserProfileRepository; - public class ExperimentRepositoryTest { private final static Logger logger = LoggerFactory.getLogger(ExperimentRepositoryTest.class); -// private GatewayRepository gatewayRepository; -// private UserProfileRepository userProfileRepository; -// private ProjectRepository projectRepository; -// private ExperimentRepository experimentRepository; -// private String gatewayId; -// private String userId; -// private String projectId; -// private String experimentId; -// -// private final String GATEWAY_DOMAIN = "test1.com"; -// private final String EXPERIMENT_NAME = "sample experiment"; -// private final String EXPERIMENT_DESCRIPTION = "sample description"; -// -// -// @Before -// public void setupRepository() { -// -// gatewayRepository = new GatewayRepository(Gateway.class, GatewayEntity.class); -// userProfileRepository = new UserProfileRepository(UserProfile.class, UserProfileEntity.class); -// projectRepository = new ProjectRepository(Project.class, ProjectEntity.class); -// experimentRepository = new ExperimentRepository(ExperimentModel.class, ExperimentEntity.class); -// -// gatewayId = "test.com" + System.currentTimeMillis(); -// userId = "testuser" + System.currentTimeMillis(); -// projectId = "project" + System.currentTimeMillis(); -// experimentId = "exp" + System.currentTimeMillis(); -// } -// -// @Test -// public void experimentRepositoryTest() { -// -// /* -// * Creating Gateway required for UserProfile & Project creation -// */ -// Gateway gateway = new Gateway(); -// gateway.setGatewayApprovalStatus(GatewayApprovalStatus.ACTIVE); -// gateway.setGatewayId(gatewayId); -// gateway.setDomain(GATEWAY_DOMAIN); -// gateway = gatewayRepository.create(gateway); -// Assert.assertTrue(!gateway.getGatewayId().isEmpty()); -// -// /* -// * UserProfile Instance creation required for Project Creation -// */ -// UserProfile userProfile = new UserProfile(); -// userProfile.setAiravataInternalUserId(userId); -// userProfile.setGatewayId(gateway.getGatewayId()); -// userProfile = userProfileRepository.create(userProfile); -// Assert.assertTrue(!userProfile.getAiravataInternalUserId().isEmpty()); -// -// /* -// * Project Instance creation -// */ -// Project project = new Project(); -// project.setGatewayId(gatewayId); -// project.setOwner(userId); -// project.setProjectID(projectId); -// project.setGatewayIdIsSet(true); -// project = projectRepository.create(project); -// Assert.assertTrue(!project.getProjectID().isEmpty()); -// -// /* -// * Experiment Instance Creation -// */ -// -// ExperimentModel experiment = new ExperimentModel(); -// experiment.setExperimentId(experimentId); -// experiment.setExperimentName(EXPERIMENT_NAME); -// experiment.setGatewayId(gatewayId); -// experiment.setUserName(userId); -// experiment.setProjectId(projectId); -// -// /* -// * Experiment Repository Insert Operation Test -// */ -// experiment = experimentRepository.create(experiment); -// Assert.assertTrue(!experiment.getExperimentId().isEmpty()); -// -// -// /* -// * Experiment Repository Update Operation Test -// */ -// experiment.setDescription(EXPERIMENT_DESCRIPTION); -// experimentRepository.update(experiment); -// experiment = experimentRepository.get(experimentId); -// Assert.assertEquals(experiment.getDescription(), EXPERIMENT_DESCRIPTION); -// -// /* -// * Workspace Project Repository Select Operation Test -// */ -// experiment = experimentRepository.get(experimentId); -// Assert.assertNotNull(experiment); -// -// /* -// * Experiment Repository Delete Operation -// */ -// -// boolean deleteResult = experimentRepository.delete(experimentId); -// Assert.assertTrue(deleteResult); -// -// deleteResult = projectRepository.delete(projectId); -// Assert.assertTrue(deleteResult); -// -// deleteResult = userProfileRepository.delete(userId); -// Assert.assertTrue(deleteResult); -// -// deleteResult = gatewayRepository.delete(gatewayId); -// Assert.assertTrue(deleteResult); - - -// } + private GatewayRepository gatewayRepository; + private UserProfileRepository userProfileRepository; + private ProjectRepository projectRepository; + private ExperimentRepository experimentRepository; + private String gatewayId; + private String userId; + private String projectId; + private String experimentId; + + private final String GATEWAY_DOMAIN = "test1.com"; + private final String EXPERIMENT_NAME = "sample experiment"; + private final String EXPERIMENT_DESCRIPTION = "sample description"; + + + @Before + public void setupRepository() { + + gatewayRepository = new GatewayRepository(Gateway.class, GatewayEntity.class); + userProfileRepository = new UserProfileRepository(UserProfile.class, UserProfileEntity.class); + projectRepository = new ProjectRepository(Project.class, ProjectEntity.class); + experimentRepository = new ExperimentRepository(ExperimentModel.class, ExperimentEntity.class); + + gatewayId = "test.com" + System.currentTimeMillis(); + userId = "testuser" + System.currentTimeMillis(); + projectId = "project" + System.currentTimeMillis(); + experimentId = "exp" + System.currentTimeMillis(); + } + + @Test + public void experimentRepositoryTest() { + + /* + * Creating Gateway required for UserProfile & Project creation + */ + Gateway gateway = new Gateway(); + gateway.setGatewayApprovalStatus(GatewayApprovalStatus.ACTIVE); + gateway.setGatewayId(gatewayId); + gateway.setDomain(GATEWAY_DOMAIN); + gateway = gatewayRepository.create(gateway); + Assert.assertTrue(!gateway.getGatewayId().isEmpty()); + + /* + * UserProfile Instance creation required for Project Creation + */ + UserProfile userProfile = new UserProfile(); + userProfile.setAiravataInternalUserId(userId); + userProfile.setGatewayId(gateway.getGatewayId()); + userProfile = userProfileRepository.create(userProfile); + Assert.assertTrue(!userProfile.getAiravataInternalUserId().isEmpty()); + + /* + * Project Instance creation + */ + Project project = new Project(); + project.setGatewayId(gatewayId); + project.setOwner(userId); + project.setProjectID(projectId); + project.setGatewayIdIsSet(true); + project = projectRepository.create(project); + Assert.assertTrue(!project.getProjectID().isEmpty()); + + /* + * Experiment Instance Creation + */ + + ExperimentModel experiment = new ExperimentModel(); + experiment.setExperimentId(experimentId); + experiment.setExperimentName(EXPERIMENT_NAME); + experiment.setGatewayId(gatewayId); + experiment.setUserName(userId); + experiment.setProjectId(projectId); + + /* + * Experiment Repository Insert Operation Test + */ + experiment = experimentRepository.create(experiment); + Assert.assertTrue(!experiment.getExperimentId().isEmpty()); + + + /* + * Experiment Repository Update Operation Test + */ + experiment.setDescription(EXPERIMENT_DESCRIPTION); + experimentRepository.update(experiment); + experiment = experimentRepository.get(experimentId); + Assert.assertEquals(experiment.getDescription(), EXPERIMENT_DESCRIPTION); + + /* + * Workspace Project Repository Select Operation Test + */ + experiment = experimentRepository.get(experimentId); + Assert.assertNotNull(experiment); + + /* + * Experiment Repository Delete Operation + */ + + boolean deleteResult = experimentRepository.delete(experimentId); + Assert.assertTrue(deleteResult); + + deleteResult = projectRepository.delete(projectId); + Assert.assertTrue(deleteResult); + + deleteResult = userProfileRepository.delete(userId); + Assert.assertTrue(deleteResult); + + deleteResult = gatewayRepository.delete(gatewayId); + Assert.assertTrue(deleteResult); + + + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/208e5d38/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/ReplicaCatalogRepositoryTest.java ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/ReplicaCatalogRepositoryTest.java b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/ReplicaCatalogRepositoryTest.java index c76bd84..38cb722 100644 --- a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/ReplicaCatalogRepositoryTest.java +++ b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/ReplicaCatalogRepositoryTest.java @@ -20,103 +20,111 @@ */ package org.apache.airavata.registry.core.repositories; -//import org.apache.airavata.registry.core.entities.workspacecatalog.GatewayEntity; -//import org.apache.airavata.registry.core.entities.workspacecatalog.UserProfileEntity; -//import org.apache.airavata.registry.core.repositories.replicacatalog.DataProductRepository; -//import org.apache.airavata.registry.core.repositories.workspacecatalog.GatewayRepository; -//import org.apache.airavata.registry.core.repositories.workspacecatalog.UserProfileRepository; +import org.apache.airavata.model.data.replica.DataProductModel; +import org.apache.airavata.model.user.UserProfile; +import org.apache.airavata.model.workspace.Gateway; +import org.apache.airavata.model.workspace.GatewayApprovalStatus; +import org.apache.airavata.registry.core.entities.replicacatalog.DataProductEntity; +import org.apache.airavata.registry.core.entities.workspacecatalog.GatewayEntity; +import org.apache.airavata.registry.core.entities.workspacecatalog.UserProfileEntity; +import org.apache.airavata.registry.core.repositories.replicacatalog.DataProductRepository; +import org.apache.airavata.registry.core.repositories.workspacecatalog.GatewayRepository; +import org.apache.airavata.registry.core.repositories.workspacecatalog.UserProfileRepository; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class ReplicaCatalogRepositoryTest { -// private GatewayRepository gatewayRepository; -// private UserProfileRepository userProfileRepository; -// private String gatewayId; -// private String userId; -// private String dataProductUri; -// -// private final String GATEWAY_DOMAIN = "test1.com"; -// private final String DATA_PRODUCT_DESCRIPTION = "testDesc"; -// -// -// @Before -// public void setupRepository() { -// -// gatewayRepository = new GatewayRepository(Gateway.class, GatewayEntity.class); -// userProfileRepository = new UserProfileRepository(UserProfile.class, UserProfileEntity.class); -// -// -// gatewayId = "test.com" + System.currentTimeMillis(); -// userId = "testuser" + System.currentTimeMillis(); -// dataProductUri = "uri" + System.currentTimeMillis(); -// -// } -// @Test -// public void dataProductRepositoryTest() { -// -// DataProductRepository dataProductRepository = new DataProductRepository(DataProductModel.class, DataProductEntity.class); -// -// /* -// * Creating Gateway required for UserProfile & Project creation -// */ -// Gateway gateway = new Gateway(); -// gateway.setGatewayApprovalStatus(GatewayApprovalStatus.ACTIVE); -// gateway.setGatewayId(gatewayId); -// gateway.setDomain(GATEWAY_DOMAIN); -// gateway = gatewayRepository.create(gateway); -// Assert.assertTrue(!gateway.getGatewayId().isEmpty()); -// -// /* -// * UserProfile Instance creation required for Project Creation -// */ -// UserProfile userProfile = new UserProfile(); -// userProfile.setAiravataInternalUserId(userId); -// userProfile.setGatewayId(gateway.getGatewayId()); -// userProfile = userProfileRepository.create(userProfile); -// Assert.assertTrue(!userProfile.getAiravataInternalUserId().isEmpty()); -// -// /* -// * DataProduct Instance creation -// */ -// DataProductModel dataProduct = new DataProductModel(); -// dataProduct.setProductUri(dataProductUri); -// dataProduct.setGatewayId(gatewayId); -// dataProduct.setOwnerName(gatewayId); -// dataProduct.setProductName("Product1234"); -// -// -// /* -// * Data Product Repository Insert Operation Test -// */ -// dataProduct = dataProductRepository.create(dataProduct); -// Assert.assertTrue(!dataProduct.getProductUri().isEmpty()); -// -// -// -// /* -// * DataProduct Repository Update Operation Test -// */ -// dataProduct.setProductDescription(DATA_PRODUCT_DESCRIPTION); -// dataProductRepository.update(dataProduct); -// dataProduct = dataProductRepository.get(dataProduct.getProductUri()); -// Assert.assertEquals(dataProduct.getProductDescription(), DATA_PRODUCT_DESCRIPTION); -// -// /* -// * Data Product Repository Select Operation Test -// */ -// dataProduct = dataProductRepository.get(dataProductUri); -// Assert.assertNotNull(dataProduct); -// -// /* -// * Workspace Project Repository Delete Operation -// */ -// boolean deleteResult = dataProductRepository.delete(dataProductUri); -// Assert.assertTrue(deleteResult); -// -// deleteResult = userProfileRepository.delete(userId); -// Assert.assertTrue(deleteResult); -// -// deleteResult = gatewayRepository.delete(gatewayId); -// Assert.assertTrue(deleteResult); - -// } + private GatewayRepository gatewayRepository; + private UserProfileRepository userProfileRepository; + private String gatewayId; + private String userId; + private String dataProductUri; + + private final String GATEWAY_DOMAIN = "test1.com"; + private final String DATA_PRODUCT_DESCRIPTION = "testDesc"; + + + @Before + public void setupRepository() { + + gatewayRepository = new GatewayRepository(Gateway.class, GatewayEntity.class); + userProfileRepository = new UserProfileRepository(UserProfile.class, UserProfileEntity.class); + + + gatewayId = "test.com" + System.currentTimeMillis(); + userId = "testuser" + System.currentTimeMillis(); + dataProductUri = "uri" + System.currentTimeMillis(); + + } + @Test + public void dataProductRepositoryTest() { + + DataProductRepository dataProductRepository = new DataProductRepository(DataProductModel.class, DataProductEntity.class); + + /* + * Creating Gateway required for UserProfile & Project creation + */ + Gateway gateway = new Gateway(); + gateway.setGatewayApprovalStatus(GatewayApprovalStatus.ACTIVE); + gateway.setGatewayId(gatewayId); + gateway.setDomain(GATEWAY_DOMAIN); + gateway = gatewayRepository.create(gateway); + Assert.assertTrue(!gateway.getGatewayId().isEmpty()); + + /* + * UserProfile Instance creation required for Project Creation + */ + UserProfile userProfile = new UserProfile(); + userProfile.setAiravataInternalUserId(userId); + userProfile.setGatewayId(gateway.getGatewayId()); + userProfile = userProfileRepository.create(userProfile); + Assert.assertTrue(!userProfile.getAiravataInternalUserId().isEmpty()); + + /* + * DataProduct Instance creation + */ + DataProductModel dataProduct = new DataProductModel(); + dataProduct.setProductUri(dataProductUri); + dataProduct.setGatewayId(gatewayId); + dataProduct.setOwnerName(gatewayId); + dataProduct.setProductName("Product1234"); + + + /* + * Data Product Repository Insert Operation Test + */ + dataProduct = dataProductRepository.create(dataProduct); + Assert.assertTrue(!dataProduct.getProductUri().isEmpty()); + + + + /* + * DataProduct Repository Update Operation Test + */ + dataProduct.setProductDescription(DATA_PRODUCT_DESCRIPTION); + dataProductRepository.update(dataProduct); + dataProduct = dataProductRepository.get(dataProduct.getProductUri()); + Assert.assertEquals(dataProduct.getProductDescription(), DATA_PRODUCT_DESCRIPTION); + + /* + * Data Product Repository Select Operation Test + */ + dataProduct = dataProductRepository.get(dataProductUri); + Assert.assertNotNull(dataProduct); + + /* + * Workspace Project Repository Delete Operation + */ + boolean deleteResult = dataProductRepository.delete(dataProductUri); + Assert.assertTrue(deleteResult); + + deleteResult = userProfileRepository.delete(userId); + Assert.assertTrue(deleteResult); + + deleteResult = gatewayRepository.delete(gatewayId); + Assert.assertTrue(deleteResult); + + } } http://git-wip-us.apache.org/repos/asf/airavata/blob/208e5d38/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/WorkflowRepositoryTest.java ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/WorkflowRepositoryTest.java b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/WorkflowRepositoryTest.java index eab2d92..b17432c 100644 --- a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/WorkflowRepositoryTest.java +++ b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/WorkflowRepositoryTest.java @@ -20,100 +20,113 @@ */ package org.apache.airavata.registry.core.repositories; +import org.apache.airavata.model.WorkflowModel; +import org.apache.airavata.model.user.UserProfile; +import org.apache.airavata.model.workspace.Gateway; +import org.apache.airavata.model.workspace.GatewayApprovalStatus; +import org.apache.airavata.registry.core.entities.workflowcatalog.WorkflowEntity; +import org.apache.airavata.registry.core.entities.workspacecatalog.GatewayEntity; +import org.apache.airavata.registry.core.entities.workspacecatalog.UserProfileEntity; +import org.apache.airavata.registry.core.repositories.workflowcatalog.WorkflowRepository; +import org.apache.airavata.registry.core.repositories.workspacecatalog.GatewayRepository; +import org.apache.airavata.registry.core.repositories.workspacecatalog.UserProfileRepository; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class WorkflowRepositoryTest { private final static Logger logger = LoggerFactory.getLogger(WorkflowRepositoryTest.class); -// private GatewayRepository gatewayRepository; -// private UserProfileRepository userProfileRepository; -// private WorkflowRepository workflowRepository; -// private String gatewayId; -// private String userId; -// private String templateId; -// -// private final String GATEWAY_DOMAIN = "test1.com"; -// private final String WORKFLOW_NAME = "test Workflow"; -// -// @Before -// public void setupRepository() { -// gatewayRepository = new GatewayRepository(Gateway.class, GatewayEntity.class); -// userProfileRepository = new UserProfileRepository(UserProfile.class, UserProfileEntity.class); -// gatewayId = "test.com" + System.currentTimeMillis(); -// userId = "testuser" + System.currentTimeMillis(); -// workflowRepository = new WorkflowRepository(WorkflowModel.class, WorkflowEntity.class); -// templateId = "templateId" + System.currentTimeMillis(); -// } -// -// -// @Test -// public void workflowRepositoryTest() { -// -// /* -// * Creating Gateway required for UserProfile & Workflow creation -// */ -// Gateway gateway = new Gateway(); -// gateway.setGatewayApprovalStatus(GatewayApprovalStatus.ACTIVE); -// gateway.setGatewayId(gatewayId); -// gateway.setDomain(GATEWAY_DOMAIN); -// gateway = gatewayRepository.create(gateway); -// Assert.assertTrue(!gateway.getGatewayId().isEmpty()); -// -// /* -// * UserProfile Instance creation required for Workflow Creation -// */ -// UserProfile userProfile = new UserProfile(); -// userProfile.setAiravataInternalUserId(userId); -// userProfile.setGatewayId(gateway.getGatewayId()); -// userProfile = userProfileRepository.create(userProfile); -// Assert.assertTrue(!userProfile.getAiravataInternalUserId().isEmpty()); -// -// /* -// * Workflow Instance Creation -// */ -// -// WorkflowModel workflowModel = new WorkflowModel(); -// workflowModel.setTemplateId(templateId); -// workflowModel.setCreatedUser(userId); -// workflowModel.setGatewayId(gatewayId); -// workflowModel.setName(WORKFLOW_NAME); -// -// -// /* -// * Workflow Repository Insert Operation Test -// */ -// workflowModel = workflowRepository.create(workflowModel); -// Assert.assertTrue(!workflowModel.getTemplateId().isEmpty()); -// -// -// /* -// * Workflow Repository Update Operation Test -// */ -// workflowModel.setGraph("test"); -// workflowRepository.update(workflowModel); -// workflowModel = workflowRepository.get(templateId); -// Assert.assertEquals(workflowModel.getGraph(), "test"); -// -// /* -// * Workflow Repository Select Operation Test -// */ -// workflowModel = workflowRepository.get(templateId); -// Assert.assertNotNull(workflowModel); -// -// /* -// * Workflow Repository Delete Operation -// */ -// -// boolean deleteResult = workflowRepository.delete(templateId); -// Assert.assertTrue(deleteResult); -// -// deleteResult = userProfileRepository.delete(userId); -// Assert.assertTrue(deleteResult); -// -// deleteResult = gatewayRepository.delete(gatewayId); -// Assert.assertTrue(deleteResult); -// -// -// } + private GatewayRepository gatewayRepository; + private UserProfileRepository userProfileRepository; + private WorkflowRepository workflowRepository; + private String gatewayId; + private String userId; + private String templateId; + + private final String GATEWAY_DOMAIN = "test1.com"; + private final String WORKFLOW_NAME = "test Workflow"; + + @Before + public void setupRepository() { + gatewayRepository = new GatewayRepository(Gateway.class, GatewayEntity.class); + userProfileRepository = new UserProfileRepository(UserProfile.class, UserProfileEntity.class); + gatewayId = "test.com" + System.currentTimeMillis(); + userId = "testuser" + System.currentTimeMillis(); + workflowRepository = new WorkflowRepository(WorkflowModel.class, WorkflowEntity.class); + templateId = "templateId" + System.currentTimeMillis(); + } + + + @Test + public void workflowRepositoryTest() { + + /* + * Creating Gateway required for UserProfile & Workflow creation + */ + Gateway gateway = new Gateway(); + gateway.setGatewayApprovalStatus(GatewayApprovalStatus.ACTIVE); + gateway.setGatewayId(gatewayId); + gateway.setDomain(GATEWAY_DOMAIN); + gateway = gatewayRepository.create(gateway); + Assert.assertTrue(!gateway.getGatewayId().isEmpty()); + + /* + * UserProfile Instance creation required for Workflow Creation + */ + UserProfile userProfile = new UserProfile(); + userProfile.setAiravataInternalUserId(userId); + userProfile.setGatewayId(gateway.getGatewayId()); + userProfile = userProfileRepository.create(userProfile); + Assert.assertTrue(!userProfile.getAiravataInternalUserId().isEmpty()); + + /* + * Workflow Instance Creation + */ + + WorkflowModel workflowModel = new WorkflowModel(); + workflowModel.setTemplateId(templateId); + workflowModel.setCreatedUser(userId); + workflowModel.setGatewayId(gatewayId); + workflowModel.setName(WORKFLOW_NAME); + + + /* + * Workflow Repository Insert Operation Test + */ + workflowModel = workflowRepository.create(workflowModel); + Assert.assertTrue(!workflowModel.getTemplateId().isEmpty()); + + + /* + * Workflow Repository Update Operation Test + */ + workflowModel.setGraph("test"); + workflowRepository.update(workflowModel); + workflowModel = workflowRepository.get(templateId); + Assert.assertEquals(workflowModel.getGraph(), "test"); + + /* + * Workflow Repository Select Operation Test + */ + workflowModel = workflowRepository.get(templateId); + Assert.assertNotNull(workflowModel); + + /* + * Workflow Repository Delete Operation + */ + + boolean deleteResult = workflowRepository.delete(templateId); + Assert.assertTrue(deleteResult); + + deleteResult = userProfileRepository.delete(userId); + Assert.assertTrue(deleteResult); + + deleteResult = gatewayRepository.delete(gatewayId); + Assert.assertTrue(deleteResult); + + + } } \ No newline at end of file
