You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ch...@apache.org on 2015/06/04 22:34:04 UTC

[16/51] [abbrv] [partial] airavata git commit: registry refactoring

http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleAppCatalogResourceAppCat.java
new file mode 100644
index 0000000..3021cee
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleAppCatalogResourceAppCat.java
@@ -0,0 +1,344 @@
+/*
+ *
+ * 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.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.app.catalog.model.ApplicationModule;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+public class AppModuleAppCatalogResourceAppCat extends AppCatAbstractResource {
+    private final static Logger logger = LoggerFactory.getLogger(AppModuleAppCatalogResourceAppCat.class);
+    private String moduleId;
+    private String moduleName;
+    private String moduleVersion;
+    private String moduleDesc;
+    private Timestamp createdTime;
+    private Timestamp updatedTime;
+    private String gatewayId;
+
+    public String getGatewayId() {
+        return gatewayId;
+    }
+
+    public void setGatewayId(String gatewayId) {
+        this.gatewayId = gatewayId;
+    }
+
+    public Timestamp getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Timestamp createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    public Timestamp getUpdatedTime() {
+        return updatedTime;
+    }
+
+    public void setUpdatedTime(Timestamp updatedTime) {
+        this.updatedTime = updatedTime;
+    }
+
+    public String getModuleId() {
+        return moduleId;
+    }
+
+    public void setModuleId(String moduleId) {
+        this.moduleId = moduleId;
+    }
+
+    public String getModuleName() {
+        return moduleName;
+    }
+
+    public void setModuleName(String moduleName) {
+        this.moduleName = moduleName;
+    }
+
+    public String getModuleVersion() {
+        return moduleVersion;
+    }
+
+    public void setModuleVersion(String moduleVersion) {
+        this.moduleVersion = moduleVersion;
+    }
+
+    public String getModuleDesc() {
+        return moduleDesc;
+    }
+
+    public void setModuleDesc(String moduleDesc) {
+        this.moduleDesc = moduleDesc;
+    }
+
+    @Override
+    public void remove(Object identifier) throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(APPLICATION_MODULE);
+            generator.setParameter(ApplicationModuleConstants.MODULE_ID, identifier);
+            Query q = generator.deleteQuery(em);
+            q.executeUpdate();
+            em.getTransaction().commit();
+            em.close();
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    @Override
+    public AppCatalogResource get(Object identifier) throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_MODULE);
+            generator.setParameter(ApplicationModuleConstants.MODULE_ID, identifier);
+            Query q = generator.selectQuery(em);
+            ApplicationModule applicationModule = (ApplicationModule) q.getSingleResult();
+            AppModuleAppCatalogResourceAppCat appModuleResource =
+                    (AppModuleAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_MODULE, applicationModule);
+            em.getTransaction().commit();
+            em.close();
+            return appModuleResource;
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    @Override
+    public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+        List<AppCatalogResource> moduleResources = new ArrayList<AppCatalogResource>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_MODULE);
+            List results;
+            if (fieldName.equals(ApplicationModuleConstants.MODULE_NAME)) {
+                generator.setParameter(ApplicationModuleConstants.MODULE_NAME, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        ApplicationModule applicationModule = (ApplicationModule) result;
+                        AppModuleAppCatalogResourceAppCat moduleResource =
+                                (AppModuleAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_MODULE, applicationModule);
+                        moduleResources.add(moduleResource);
+                    }
+                }
+            } else {
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported field name for app module resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for app module resource.");
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+        return moduleResources;
+    }
+
+    @Override
+    public List<AppCatalogResource> getAll() throws AppCatalogException {
+        List<AppCatalogResource> appModuleResources = new ArrayList<AppCatalogResource>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_MODULE);
+            generator.setParameter(ApplicationModuleConstants.GATEWAY_ID, gatewayId);
+            Query q = generator.selectQuery(em);
+            List<?> results = q.getResultList();
+            for (Object result : results) {
+                ApplicationModule module = (ApplicationModule) result;
+                AppModuleAppCatalogResourceAppCat appModuleResource = (AppModuleAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_MODULE, module);
+                appModuleResources.add(appModuleResource);
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+        return appModuleResources;
+    }
+
+    @Override
+    public List<String> getAllIds() throws AppCatalogException {
+        return null;
+    }
+
+    @Override
+    public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+        List<String> moduleResources = new ArrayList<String>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_MODULE);
+            List results;
+            if (fieldName.equals(ApplicationModuleConstants.MODULE_NAME)) {
+                generator.setParameter(ApplicationModuleConstants.MODULE_NAME, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        ApplicationModule applicationModule = (ApplicationModule) result;
+                        moduleResources.add(applicationModule.getModuleID());
+                    }
+                }
+            } else {
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported field name for app module resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for app module resource.");
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+        return moduleResources;
+    }
+
+    @Override
+    public void save() throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            ApplicationModule existingModule = em.find(ApplicationModule.class, moduleId);
+            em.close();
+
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            if (existingModule !=  null){
+                existingModule.setModuleName(moduleName);
+                existingModule.setModuleVersion(moduleVersion);
+                existingModule.setModuleDesc(moduleDesc);
+                existingModule.setGatewayId(gatewayId);
+                existingModule.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+                em.merge(existingModule);
+            }else {
+                ApplicationModule applicationModule = new ApplicationModule();
+                applicationModule.setModuleID(moduleId);
+                applicationModule.setModuleName(moduleName);
+                applicationModule.setModuleVersion(moduleVersion);
+                applicationModule.setModuleDesc(moduleDesc);
+                applicationModule.setGatewayId(gatewayId);
+                applicationModule.setCreationTime(AiravataUtils.getCurrentTimestamp());
+                em.persist(applicationModule);
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    @Override
+    public boolean isExists(Object identifier) throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            ApplicationModule applicationModule = em.find(ApplicationModule.class, identifier);
+            em.close();
+            return applicationModule != null;
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleMappingAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleMappingAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleMappingAppCatalogResourceAppCat.java
new file mode 100644
index 0000000..12d32a0
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleMappingAppCatalogResourceAppCat.java
@@ -0,0 +1,317 @@
+/*
+ *
+ * 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.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.AppModuleMapping;
+import org.apache.airavata.registry.core.app.catalog.model.AppModuleMapping_PK;
+import org.apache.airavata.registry.core.app.catalog.model.ApplicationInterface;
+import org.apache.airavata.registry.core.app.catalog.model.ApplicationModule;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class AppModuleMappingAppCatalogResourceAppCat extends AppCatAbstractResource {
+    private final static Logger logger = LoggerFactory.getLogger(AppModuleMappingAppCatalogResourceAppCat.class);
+    private String interfaceId;
+    private String moduleId;
+    private AppInterfaceAppCatalogResourceAppCat appInterfaceResource;
+    private AppModuleAppCatalogResourceAppCat moduleResource;
+
+
+    public String getModuleId() {
+        return moduleId;
+    }
+
+    public void setModuleId(String moduleId) {
+        this.moduleId = moduleId;
+    }
+
+    public String getInterfaceId() {
+        return interfaceId;
+    }
+
+    public void setInterfaceId(String interfaceId) {
+        this.interfaceId = interfaceId;
+    }
+
+    public AppInterfaceAppCatalogResourceAppCat getAppInterfaceResource() {
+        return appInterfaceResource;
+    }
+
+    public void setAppInterfaceResource(AppInterfaceAppCatalogResourceAppCat appInterfaceResource) {
+        this.appInterfaceResource = appInterfaceResource;
+    }
+
+    public AppModuleAppCatalogResourceAppCat getModuleResource() {
+        return moduleResource;
+    }
+
+    public void setModuleResource(AppModuleAppCatalogResourceAppCat moduleResource) {
+        this.moduleResource = moduleResource;
+    }
+
+    @Override
+    public void remove(Object identifier) throws AppCatalogException {
+        HashMap<String, String> ids;
+        if (identifier instanceof Map){
+            ids = (HashMap)identifier;
+        }else {
+            logger.error("Identifier should be a map with the field name and it's value");
+            throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+        }
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(APP_MODULE_MAPPING);
+            generator.setParameter(AppModuleMappingConstants.INTERFACE_ID, ids.get(AppModuleMappingConstants.INTERFACE_ID));
+            if (ids.get(AppModuleMappingConstants.MODULE_ID) != null){
+                generator.setParameter(AppModuleMappingConstants.MODULE_ID, ids.get(AppModuleMappingConstants.MODULE_ID));
+            }
+            Query q = generator.deleteQuery(em);
+            q.executeUpdate();
+            em.getTransaction().commit();
+            em.close();
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    public void removeAll() throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(APP_MODULE_MAPPING);
+            Query q = generator.deleteQuery(em);
+            q.executeUpdate();
+            em.getTransaction().commit();
+            em.close();
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    @Override
+    public AppCatalogResource get(Object identifier) throws AppCatalogException {
+        HashMap<String, String> ids;
+        if (identifier instanceof Map){
+            ids = (HashMap)identifier;
+        }else {
+            logger.error("Identifier should be a map with the field name and it's value");
+            throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+        }
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APP_MODULE_MAPPING);
+            generator.setParameter(AppModuleMappingConstants.INTERFACE_ID, ids.get(AppModuleMappingConstants.INTERFACE_ID));
+            generator.setParameter(AppModuleMappingConstants.MODULE_ID, ids.get(AppModuleMappingConstants.MODULE_ID));
+            Query q = generator.selectQuery(em);
+            AppModuleMapping result = (AppModuleMapping) q.getSingleResult();
+            AppModuleMappingAppCatalogResourceAppCat resource =
+                    (AppModuleMappingAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APP_MODULE_MAPPING, result);
+            em.getTransaction().commit();
+            em.close();
+            return resource;
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    @Override
+    public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+        List<AppCatalogResource> resourceList = new ArrayList<AppCatalogResource>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APP_MODULE_MAPPING);
+            List results;
+            if (fieldName.equals(AppModuleMappingConstants.INTERFACE_ID)) {
+                generator.setParameter(AppModuleMappingConstants.INTERFACE_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        AppModuleMapping moduleMapping = (AppModuleMapping) result;
+                        AppModuleMappingAppCatalogResourceAppCat resource =
+                                (AppModuleMappingAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APP_MODULE_MAPPING, moduleMapping);
+                        resourceList.add(resource);
+                    }
+                }
+            } else if (fieldName.equals(AppModuleMappingConstants.MODULE_ID)) {
+                generator.setParameter(AppModuleMappingConstants.MODULE_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        AppModuleMapping moduleMapping = (AppModuleMapping) result;
+                        AppModuleMappingAppCatalogResourceAppCat resource =
+                                (AppModuleMappingAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APP_MODULE_MAPPING, moduleMapping);
+                        resourceList.add(resource);
+                    }
+                }
+            }else {
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported field name for app module mapping resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for app module mapping resource.");
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+        return resourceList;
+    }
+
+    @Override
+    public List<AppCatalogResource> getAll() throws AppCatalogException {
+        return null;
+    }
+
+    @Override
+    public List<String> getAllIds() throws AppCatalogException {
+        return null;
+    }
+
+    @Override
+    public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+        logger.error("Unsupported for objects with a composite identifier");
+        throw new AppCatalogException("Unsupported for objects with a composite identifier");
+    }
+
+    @Override
+    public void save() throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            AppModuleMapping existngModuleMap = em.find(AppModuleMapping.class, new AppModuleMapping_PK(interfaceId, moduleId));
+            em.close();
+
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            ApplicationInterface applicationInterface = em.find(ApplicationInterface.class, interfaceId);
+            ApplicationModule applicationModule = em.find(ApplicationModule.class, moduleId);
+            if (existngModuleMap !=  null){
+                existngModuleMap.setApplicationInterface(applicationInterface);
+                existngModuleMap.setApplicationModule(applicationModule);
+                em.merge(existngModuleMap);
+            }else {
+                AppModuleMapping appModuleMapping = new AppModuleMapping();
+                appModuleMapping.setInterfaceID(interfaceId);
+                appModuleMapping.setApplicationInterface(applicationInterface);
+                appModuleMapping.setModuleID(moduleId);
+                appModuleMapping.setApplicationModule(applicationModule);
+                em.persist(appModuleMapping);
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    @Override
+    public boolean isExists(Object identifier) throws AppCatalogException {
+        HashMap<String, String> ids;
+        if (identifier instanceof Map){
+            ids = (HashMap)identifier;
+        }else {
+            logger.error("Identifier should be a map with the field name and it's value");
+            throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+        }
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            AppModuleMapping moduleMapping = em.find(AppModuleMapping.class,
+                    new AppModuleMapping_PK(ids.get(AppModuleMappingConstants.INTERFACE_ID),
+                            ids.get(AppModuleMappingConstants.MODULE_ID)));
+            em.close();
+            return moduleMapping != null;
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleMappingResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleMappingResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleMappingResource.java
new file mode 100644
index 0000000..a44229d
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleMappingResource.java
@@ -0,0 +1,317 @@
+/*
+ *
+ * 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.aiaravata.application.catalog.data.resources;
+
+import org.airavata.appcatalog.cpi.AppCatalogException;
+import org.apache.aiaravata.application.catalog.data.model.AppModuleMapping;
+import org.apache.aiaravata.application.catalog.data.model.AppModuleMapping_PK;
+import org.apache.aiaravata.application.catalog.data.model.ApplicationInterface;
+import org.apache.aiaravata.application.catalog.data.model.ApplicationModule;
+import org.apache.aiaravata.application.catalog.data.util.AppCatalogJPAUtils;
+import org.apache.aiaravata.application.catalog.data.util.AppCatalogQueryGenerator;
+import org.apache.aiaravata.application.catalog.data.util.AppCatalogResourceType;
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class AppModuleMappingResource extends AbstractResource {
+    private final static Logger logger = LoggerFactory.getLogger(AppModuleMappingResource.class);
+    private String interfaceId;
+    private String moduleId;
+    private AppInterfaceResource appInterfaceResource;
+    private AppModuleResource moduleResource;
+
+
+    public String getModuleId() {
+        return moduleId;
+    }
+
+    public void setModuleId(String moduleId) {
+        this.moduleId = moduleId;
+    }
+
+    public String getInterfaceId() {
+        return interfaceId;
+    }
+
+    public void setInterfaceId(String interfaceId) {
+        this.interfaceId = interfaceId;
+    }
+
+    public AppInterfaceResource getAppInterfaceResource() {
+        return appInterfaceResource;
+    }
+
+    public void setAppInterfaceResource(AppInterfaceResource appInterfaceResource) {
+        this.appInterfaceResource = appInterfaceResource;
+    }
+
+    public AppModuleResource getModuleResource() {
+        return moduleResource;
+    }
+
+    public void setModuleResource(AppModuleResource moduleResource) {
+        this.moduleResource = moduleResource;
+    }
+
+    @Override
+    public void remove(Object identifier) throws AppCatalogException {
+        HashMap<String, String> ids;
+        if (identifier instanceof Map){
+            ids = (HashMap)identifier;
+        }else {
+            logger.error("Identifier should be a map with the field name and it's value");
+            throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+        }
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(APP_MODULE_MAPPING);
+            generator.setParameter(AppModuleMappingConstants.INTERFACE_ID, ids.get(AppModuleMappingConstants.INTERFACE_ID));
+            if (ids.get(AppModuleMappingConstants.MODULE_ID) != null){
+                generator.setParameter(AppModuleMappingConstants.MODULE_ID, ids.get(AppModuleMappingConstants.MODULE_ID));
+            }
+            Query q = generator.deleteQuery(em);
+            q.executeUpdate();
+            em.getTransaction().commit();
+            em.close();
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    public void removeAll() throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(APP_MODULE_MAPPING);
+            Query q = generator.deleteQuery(em);
+            q.executeUpdate();
+            em.getTransaction().commit();
+            em.close();
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    @Override
+    public Resource get(Object identifier) throws AppCatalogException {
+        HashMap<String, String> ids;
+        if (identifier instanceof Map){
+            ids = (HashMap)identifier;
+        }else {
+            logger.error("Identifier should be a map with the field name and it's value");
+            throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+        }
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APP_MODULE_MAPPING);
+            generator.setParameter(AppModuleMappingConstants.INTERFACE_ID, ids.get(AppModuleMappingConstants.INTERFACE_ID));
+            generator.setParameter(AppModuleMappingConstants.MODULE_ID, ids.get(AppModuleMappingConstants.MODULE_ID));
+            Query q = generator.selectQuery(em);
+            AppModuleMapping result = (AppModuleMapping) q.getSingleResult();
+            AppModuleMappingResource resource =
+                    (AppModuleMappingResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APP_MODULE_MAPPING, result);
+            em.getTransaction().commit();
+            em.close();
+            return resource;
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    @Override
+    public List<Resource> get(String fieldName, Object value) throws AppCatalogException {
+        List<Resource> resourceList = new ArrayList<Resource>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APP_MODULE_MAPPING);
+            List results;
+            if (fieldName.equals(AppModuleMappingConstants.INTERFACE_ID)) {
+                generator.setParameter(AppModuleMappingConstants.INTERFACE_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        AppModuleMapping moduleMapping = (AppModuleMapping) result;
+                        AppModuleMappingResource resource =
+                                (AppModuleMappingResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APP_MODULE_MAPPING, moduleMapping);
+                        resourceList.add(resource);
+                    }
+                }
+            } else if (fieldName.equals(AppModuleMappingConstants.MODULE_ID)) {
+                generator.setParameter(AppModuleMappingConstants.MODULE_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        AppModuleMapping moduleMapping = (AppModuleMapping) result;
+                        AppModuleMappingResource resource =
+                                (AppModuleMappingResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APP_MODULE_MAPPING, moduleMapping);
+                        resourceList.add(resource);
+                    }
+                }
+            }else {
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported field name for app module mapping resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for app module mapping resource.");
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+        return resourceList;
+    }
+
+    @Override
+    public List<Resource> getAll() throws AppCatalogException {
+        return null;
+    }
+
+    @Override
+    public List<String> getAllIds() throws AppCatalogException {
+        return null;
+    }
+
+    @Override
+    public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+        logger.error("Unsupported for objects with a composite identifier");
+        throw new AppCatalogException("Unsupported for objects with a composite identifier");
+    }
+
+    @Override
+    public void save() throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            AppModuleMapping existngModuleMap = em.find(AppModuleMapping.class, new AppModuleMapping_PK(interfaceId, moduleId));
+            em.close();
+
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            ApplicationInterface applicationInterface = em.find(ApplicationInterface.class, interfaceId);
+            ApplicationModule applicationModule = em.find(ApplicationModule.class, moduleId);
+            if (existngModuleMap !=  null){
+                existngModuleMap.setApplicationInterface(applicationInterface);
+                existngModuleMap.setApplicationModule(applicationModule);
+                em.merge(existngModuleMap);
+            }else {
+                AppModuleMapping appModuleMapping = new AppModuleMapping();
+                appModuleMapping.setInterfaceID(interfaceId);
+                appModuleMapping.setApplicationInterface(applicationInterface);
+                appModuleMapping.setModuleID(moduleId);
+                appModuleMapping.setApplicationModule(applicationModule);
+                em.persist(appModuleMapping);
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    @Override
+    public boolean isExists(Object identifier) throws AppCatalogException {
+        HashMap<String, String> ids;
+        if (identifier instanceof Map){
+            ids = (HashMap)identifier;
+        }else {
+            logger.error("Identifier should be a map with the field name and it's value");
+            throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+        }
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            AppModuleMapping moduleMapping = em.find(AppModuleMapping.class,
+                    new AppModuleMapping_PK(ids.get(AppModuleMappingConstants.INTERFACE_ID),
+                            ids.get(AppModuleMappingConstants.MODULE_ID)));
+            em.close();
+            return moduleMapping != null;
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleResource.java
new file mode 100644
index 0000000..79803af
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleResource.java
@@ -0,0 +1,344 @@
+/*
+ *
+ * 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.aiaravata.application.catalog.data.resources;
+
+import org.airavata.appcatalog.cpi.AppCatalogException;
+import org.apache.aiaravata.application.catalog.data.model.ApplicationModule;
+import org.apache.aiaravata.application.catalog.data.util.AppCatalogJPAUtils;
+import org.apache.aiaravata.application.catalog.data.util.AppCatalogQueryGenerator;
+import org.apache.aiaravata.application.catalog.data.util.AppCatalogResourceType;
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+public class AppModuleResource extends AbstractResource {
+    private final static Logger logger = LoggerFactory.getLogger(AppModuleResource.class);
+    private String moduleId;
+    private String moduleName;
+    private String moduleVersion;
+    private String moduleDesc;
+    private Timestamp createdTime;
+    private Timestamp updatedTime;
+    private String gatewayId;
+
+    public String getGatewayId() {
+        return gatewayId;
+    }
+
+    public void setGatewayId(String gatewayId) {
+        this.gatewayId = gatewayId;
+    }
+
+    public Timestamp getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Timestamp createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    public Timestamp getUpdatedTime() {
+        return updatedTime;
+    }
+
+    public void setUpdatedTime(Timestamp updatedTime) {
+        this.updatedTime = updatedTime;
+    }
+
+    public String getModuleId() {
+        return moduleId;
+    }
+
+    public void setModuleId(String moduleId) {
+        this.moduleId = moduleId;
+    }
+
+    public String getModuleName() {
+        return moduleName;
+    }
+
+    public void setModuleName(String moduleName) {
+        this.moduleName = moduleName;
+    }
+
+    public String getModuleVersion() {
+        return moduleVersion;
+    }
+
+    public void setModuleVersion(String moduleVersion) {
+        this.moduleVersion = moduleVersion;
+    }
+
+    public String getModuleDesc() {
+        return moduleDesc;
+    }
+
+    public void setModuleDesc(String moduleDesc) {
+        this.moduleDesc = moduleDesc;
+    }
+
+    @Override
+    public void remove(Object identifier) throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(APPLICATION_MODULE);
+            generator.setParameter(ApplicationModuleConstants.MODULE_ID, identifier);
+            Query q = generator.deleteQuery(em);
+            q.executeUpdate();
+            em.getTransaction().commit();
+            em.close();
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    @Override
+    public Resource get(Object identifier) throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_MODULE);
+            generator.setParameter(ApplicationModuleConstants.MODULE_ID, identifier);
+            Query q = generator.selectQuery(em);
+            ApplicationModule applicationModule = (ApplicationModule) q.getSingleResult();
+            AppModuleResource appModuleResource =
+                    (AppModuleResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_MODULE, applicationModule);
+            em.getTransaction().commit();
+            em.close();
+            return appModuleResource;
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    @Override
+    public List<Resource> get(String fieldName, Object value) throws AppCatalogException {
+        List<Resource> moduleResources = new ArrayList<Resource>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_MODULE);
+            List results;
+            if (fieldName.equals(ApplicationModuleConstants.MODULE_NAME)) {
+                generator.setParameter(ApplicationModuleConstants.MODULE_NAME, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        ApplicationModule applicationModule = (ApplicationModule) result;
+                        AppModuleResource moduleResource =
+                                (AppModuleResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_MODULE, applicationModule);
+                        moduleResources.add(moduleResource);
+                    }
+                }
+            } else {
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported field name for app module resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for app module resource.");
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+        return moduleResources;
+    }
+
+    @Override
+    public List<Resource> getAll() throws AppCatalogException {
+        List<Resource> appModuleResources = new ArrayList<Resource>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_MODULE);
+            generator.setParameter(ApplicationModuleConstants.GATEWAY_ID, gatewayId);
+            Query q = generator.selectQuery(em);
+            List<?> results = q.getResultList();
+            for (Object result : results) {
+                ApplicationModule module = (ApplicationModule) result;
+                AppModuleResource appModuleResource = (AppModuleResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_MODULE, module);
+                appModuleResources.add(appModuleResource);
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+        return appModuleResources;
+    }
+
+    @Override
+    public List<String> getAllIds() throws AppCatalogException {
+        return null;
+    }
+
+    @Override
+    public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+        List<String> moduleResources = new ArrayList<String>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_MODULE);
+            List results;
+            if (fieldName.equals(ApplicationModuleConstants.MODULE_NAME)) {
+                generator.setParameter(ApplicationModuleConstants.MODULE_NAME, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        ApplicationModule applicationModule = (ApplicationModule) result;
+                        moduleResources.add(applicationModule.getModuleID());
+                    }
+                }
+            } else {
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported field name for app module resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for app module resource.");
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+        return moduleResources;
+    }
+
+    @Override
+    public void save() throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            ApplicationModule existingModule = em.find(ApplicationModule.class, moduleId);
+            em.close();
+
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            if (existingModule !=  null){
+                existingModule.setModuleName(moduleName);
+                existingModule.setModuleVersion(moduleVersion);
+                existingModule.setModuleDesc(moduleDesc);
+                existingModule.setGatewayId(gatewayId);
+                existingModule.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+                em.merge(existingModule);
+            }else {
+                ApplicationModule applicationModule = new ApplicationModule();
+                applicationModule.setModuleID(moduleId);
+                applicationModule.setModuleName(moduleName);
+                applicationModule.setModuleVersion(moduleVersion);
+                applicationModule.setModuleDesc(moduleDesc);
+                applicationModule.setGatewayId(gatewayId);
+                applicationModule.setCreationTime(AiravataUtils.getCurrentTimestamp());
+                em.persist(applicationModule);
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    @Override
+    public boolean isExists(Object identifier) throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            ApplicationModule applicationModule = em.find(ApplicationModule.class, identifier);
+            em.close();
+            return applicationModule != null;
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationInputAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationInputAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationInputAppCatalogResourceAppCat.java
new file mode 100644
index 0000000..412b2c1
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationInputAppCatalogResourceAppCat.java
@@ -0,0 +1,454 @@
+/**
+ * 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.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.AppInput_PK;
+import org.apache.airavata.registry.core.app.catalog.model.ApplicationInput;
+import org.apache.airavata.registry.core.app.catalog.model.ApplicationInterface;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ApplicationInputAppCatalogResourceAppCat extends AppCatAbstractResource {
+
+    private final static Logger logger = LoggerFactory.getLogger(ApplicationInputAppCatalogResourceAppCat.class);
+
+    private String interfaceID;
+    private String inputKey;
+    private String dataType;
+    private String inputVal;
+    private String metadata;
+    private String appArgument;
+    private String userFriendlyDesc;
+    private int inputOrder;
+    private boolean standardInput;
+    private boolean isRequired;
+    private boolean requiredToCMD;
+    private boolean dataStaged;
+
+    private AppInterfaceAppCatalogResourceAppCat appInterfaceResource;
+
+    public void remove(Object identifier) throws AppCatalogException {
+        HashMap<String, String> ids;
+        if (identifier instanceof Map) {
+            ids = (HashMap) identifier;
+        } else {
+            logger.error("Identifier should be a map with the field name and it's value");
+            throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+        }
+
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INPUT);
+            generator.setParameter(AppInputConstants.INTERFACE_ID, ids.get(AppInputConstants.INTERFACE_ID));
+            if (ids.get(AppInputConstants.INPUT_KEY) != null){
+                generator.setParameter(AppInputConstants.INPUT_KEY, ids.get(AppInputConstants.INPUT_KEY));
+            }
+            Query q = generator.deleteQuery(em);
+            q.executeUpdate();
+            em.getTransaction().commit();
+            em.close();
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    public AppCatalogResource get(Object identifier) throws AppCatalogException {
+        HashMap<String, String> ids;
+        if (identifier instanceof Map) {
+            ids = (HashMap<String, String>) identifier;
+        } else {
+            logger.error("Identifier should be a map with the field name and it's value");
+            throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+        }
+
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INPUT);
+            generator.setParameter(AppInputConstants.INTERFACE_ID, ids.get(AppInputConstants.INTERFACE_ID));
+            generator.setParameter(AppInputConstants.INPUT_KEY, ids.get(AppInputConstants.INPUT_KEY));
+            Query q = generator.selectQuery(em);
+            ApplicationInput applicationInput = (ApplicationInput) q.getSingleResult();
+            ApplicationInputAppCatalogResourceAppCat applicationInputResource =
+                    (ApplicationInputAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_INPUT
+                            , applicationInput);
+            em.getTransaction().commit();
+            em.close();
+            return applicationInputResource;
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+        List<AppCatalogResource> appInputResources = new ArrayList<AppCatalogResource>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INPUT);
+            List results;
+            if (fieldName.equals(AppInputConstants.INTERFACE_ID)) {
+                generator.setParameter(AppInputConstants.INTERFACE_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        ApplicationInput applicationInput = (ApplicationInput) result;
+                        ApplicationInputAppCatalogResourceAppCat applicationInputResource =
+                                (ApplicationInputAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
+                                        AppCatalogResourceType.APPLICATION_INPUT, applicationInput);
+                        appInputResources.add(applicationInputResource);
+                    }
+                }
+            } else if (fieldName.equals(AppInputConstants.INPUT_KEY)) {
+                generator.setParameter(AppInputConstants.INPUT_KEY, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        ApplicationInput applicationInput = (ApplicationInput) result;
+                        ApplicationInputAppCatalogResourceAppCat applicationInputResource =
+                                (ApplicationInputAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
+                                        AppCatalogResourceType.APPLICATION_INPUT, applicationInput);
+                        appInputResources.add(applicationInputResource);
+                    }
+                }
+            } else if (fieldName.equals(AppInputConstants.DATA_TYPE)) {
+                generator.setParameter(AppInputConstants.DATA_TYPE, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        ApplicationInput applicationInput = (ApplicationInput) result;
+                        ApplicationInputAppCatalogResourceAppCat applicationInputResource =
+                                (ApplicationInputAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
+                                        AppCatalogResourceType.APPLICATION_INPUT, applicationInput);
+                        appInputResources.add(applicationInputResource);
+                    }
+                }
+            } else {
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported field name for AppInput Resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for AppInput Resource.");
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+        return appInputResources;
+    }
+
+    @Override
+    public List<AppCatalogResource> getAll() throws AppCatalogException {
+        return null;
+    }
+
+    @Override
+    public List<String> getAllIds() throws AppCatalogException {
+        return null;
+    }
+
+    public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+        List<String> appInputResourceIDs = new ArrayList<String>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INPUT);
+            List results;
+            if (fieldName.equals(AppInputConstants.INTERFACE_ID)) {
+                generator.setParameter(AppInputConstants.INTERFACE_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        ApplicationInput applicationInput = (ApplicationInput) result;
+                        appInputResourceIDs.add(applicationInput.getInterfaceID());
+                    }
+                }
+            } else if (fieldName.equals(AppInputConstants.INPUT_KEY)) {
+                generator.setParameter(AppInputConstants.INPUT_KEY, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        ApplicationInput applicationInput = (ApplicationInput) result;
+                        appInputResourceIDs.add(applicationInput.getInterfaceID());
+                    }
+                }
+            } else if (fieldName.equals(AppInputConstants.DATA_TYPE)) {
+                generator.setParameter(AppInputConstants.DATA_TYPE, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        ApplicationInput applicationInput = (ApplicationInput) result;
+                        appInputResourceIDs.add(applicationInput.getInterfaceID());
+                    }
+                }
+            } else {
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported field name for AppInput resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for AppInput Resource.");
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+        return appInputResourceIDs;
+    }
+
+    public void save() throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            ApplicationInput existingApplicationInput = em.find(ApplicationInput.class, new AppInput_PK(interfaceID, inputKey));
+            em.close();
+            ApplicationInput applicationInput;
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            if (existingApplicationInput == null) {
+                applicationInput = new ApplicationInput();
+            } else {
+            	applicationInput=existingApplicationInput;
+            }
+            ApplicationInterface applicationInterface = em.find(ApplicationInterface.class, interfaceID);
+            applicationInput.setApplicationInterface(applicationInterface);
+            applicationInput.setInterfaceID(applicationInterface.getInterfaceID());
+            applicationInput.setDataType(dataType);
+            applicationInput.setInputKey(inputKey);
+            applicationInput.setInputVal(inputVal);
+            applicationInput.setMetadata(metadata);
+            applicationInput.setAppArgument(appArgument);
+            applicationInput.setUserFriendlyDesc(userFriendlyDesc);
+            applicationInput.setStandardInput(standardInput);
+            applicationInput.setInputOrder(inputOrder);
+            applicationInput.setRequiredToCMD(requiredToCMD);
+            applicationInput.setRequired(isRequired);
+            applicationInput.setDataStaged(dataStaged);
+            if (existingApplicationInput == null) {
+                em.persist(applicationInput);
+            } else {
+                em.merge(applicationInput);
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    public boolean isExists(Object identifier) throws AppCatalogException {
+        HashMap<String, String> ids;
+        if (identifier instanceof Map) {
+            ids = (HashMap<String, String>) identifier;
+        } else {
+            logger.error("Identifier should be a map with the field name and it's value");
+            throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+        }
+
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            ApplicationInput applicationInput = em.find(ApplicationInput.class, new AppInput_PK(
+                    ids.get(AppInputConstants.INTERFACE_ID),
+                    ids.get(AppInputConstants.INPUT_KEY)));
+
+            em.close();
+            return applicationInput != null;
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    public String getInterfaceID() {
+        return interfaceID;
+    }
+
+    public void setInterfaceID(String interfaceID) {
+        this.interfaceID = interfaceID;
+    }
+
+    public String getInputKey() {
+        return inputKey;
+    }
+
+    public void setInputKey(String inputKey) {
+        this.inputKey = inputKey;
+    }
+
+    public String getDataType() {
+        return dataType;
+    }
+
+    public void setDataType(String dataType) {
+        this.dataType = dataType;
+    }
+
+    public String getInputVal() {
+        return inputVal;
+    }
+
+    public void setInputVal(String inputVal) {
+        this.inputVal = inputVal;
+    }
+
+    public String getMetadata() {
+        return metadata;
+    }
+
+    public void setMetadata(String metadata) {
+        this.metadata = metadata;
+    }
+
+    public String getAppArgument() {
+        return appArgument;
+    }
+
+    public void setAppArgument(String appArgument) {
+        this.appArgument = appArgument;
+    }
+
+    public String getUserFriendlyDesc() {
+        return userFriendlyDesc;
+    }
+
+    public void setUserFriendlyDesc(String userFriendlyDesc) {
+        this.userFriendlyDesc = userFriendlyDesc;
+    }
+
+    public AppInterfaceAppCatalogResourceAppCat getAppInterfaceResource() {
+        return appInterfaceResource;
+    }
+
+    public void setAppInterfaceResource(AppInterfaceAppCatalogResourceAppCat appInterfaceResource) {
+        this.appInterfaceResource = appInterfaceResource;
+    }
+
+    public boolean isStandardInput() {
+        return standardInput;
+    }
+
+    public void setStandardInput(boolean standardInput) {
+        this.standardInput = standardInput;
+    }
+
+    public int getInputOrder() {
+        return inputOrder;
+    }
+
+    public void setInputOrder(int inputOrder) {
+        this.inputOrder = inputOrder;
+    }
+
+    public boolean getRequired() {
+        return isRequired;
+    }
+
+    public void setRequired(boolean required) {
+        this.isRequired = required;
+    }
+
+    public boolean getRequiredToCMD() {
+        return requiredToCMD;
+    }
+
+    public void setRequiredToCMD(boolean requiredToCMD) {
+        this.requiredToCMD = requiredToCMD;
+    }
+
+    public boolean isDataStaged() {
+        return dataStaged;
+    }
+
+    public void setDataStaged(boolean dataStaged) {
+        this.dataStaged = dataStaged;
+    }
+}