airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msme...@apache.org
Subject git commit: remaining database files AIRAVATA-1473
Date Mon, 20 Oct 2014 15:33:59 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 6c6c74688 -> 1c95b2d1b


remaining database files AIRAVATA-1473


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/1c95b2d1
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/1c95b2d1
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/1c95b2d1

Branch: refs/heads/master
Commit: 1c95b2d1b1763c79ed48066b3c37a07c3a417591
Parents: 6c6c746
Author: msmemon <shahbaz.memon@gmail.com>
Authored: Mon Oct 20 17:34:54 2014 +0200
Committer: msmemon <shahbaz.memon@gmail.com>
Committed: Mon Oct 20 17:34:54 2014 +0200

----------------------------------------------------------------------
 .../data/model/UnicoreJobSubmission.java        |  44 +++
 .../resources/UnicoreJobSubmissionResource.java | 315 +++++++++++++++++++
 2 files changed, 359 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/1c95b2d1/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/UnicoreJobSubmission.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/UnicoreJobSubmission.java
b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/UnicoreJobSubmission.java
new file mode 100644
index 0000000..6772aee
--- /dev/null
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/UnicoreJobSubmission.java
@@ -0,0 +1,44 @@
+package org.apache.aiaravata.application.catalog.data.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "UNICORE_SUBMISSION")
+public class UnicoreJobSubmission {
+	@Id
+    @Column(name = "SUBMISSION_ID")
+    private String submissionID;
+    @Column(name = "SECURITY_PROTOCAL")
+    private String securityProtocol;
+
+    @Column(name = "UNICORE_ENDPOINT_URL")
+    private String unicoreEndpointUrl;
+
+    public String getUnicoreEndpointUrl() {
+		return unicoreEndpointUrl;
+	}
+
+    public void setUnicoreEndpointUrl(String unicoreEndpointUrl) {
+		this.unicoreEndpointUrl = unicoreEndpointUrl;
+	}
+
+	public String getSubmissionID() {
+        return submissionID;
+    }
+
+    public void setSubmissionID(String submissionID) {
+        this.submissionID = submissionID;
+    }
+
+    public String getSecurityProtocol() {
+        return securityProtocol;
+    }
+
+    public void setSecurityProtocol(String securityProtocol) {
+        this.securityProtocol = securityProtocol;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/1c95b2d1/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/UnicoreJobSubmissionResource.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/UnicoreJobSubmissionResource.java
b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/UnicoreJobSubmissionResource.java
new file mode 100644
index 0000000..09bc1b0
--- /dev/null
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/UnicoreJobSubmissionResource.java
@@ -0,0 +1,315 @@
+package org.apache.aiaravata.application.catalog.data.resources;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.airavata.appcatalog.cpi.AppCatalogException;
+import org.apache.aiaravata.application.catalog.data.model.GlobusJobSubmission;
+import org.apache.aiaravata.application.catalog.data.model.UnicoreJobSubmission;
+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;
+
+public class UnicoreJobSubmissionResource extends AbstractResource {
+	
+	private final static Logger logger = LoggerFactory.getLogger(UnicoreJobSubmissionResource.class);
+	
+	private String jobSubmissionInterfaceId;
+	private String securityProtocol;
+	private String unicoreEndpointUrl;
+
+	 public void remove(Object identifier) throws AppCatalogException {
+	        EntityManager em = null;
+	        try {
+	            em = AppCatalogJPAUtils.getEntityManager();
+	            em.getTransaction().begin();
+	            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(UNICORE_JOB_SUBMISSION);
+	            generator.setParameter(UnicoreJobSubmissionConstants.SUBMISSION_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();
+	            }
+	        }
+	    }
+
+	 public Resource get(Object identifier) throws AppCatalogException {
+		 // TODO: what? there is no sense to pass string and expect hashmap.. :(
+		 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(UNICORE_JOB_SUBMISSION);
+	            generator.setParameter(UnicoreJobSubmissionConstants.SUBMISSION_ID, identifier);
+//	            generator.setParameter(UnicoreJobSubmissionConstants.UNICORE_ENDPOINT_URL,
ids.get(UnicoreJobSubmissionConstants.UNICORE_ENDPOINT_URL));
+	            Query q = generator.selectQuery(em);
+	            UnicoreJobSubmission unicoreJobSubmission = (UnicoreJobSubmission) q.getSingleResult();
+	            UnicoreJobSubmissionResource unicoreSubmissionResource =
+	            			(UnicoreJobSubmissionResource) AppCatalogJPAUtils
+	            			.getResource(AppCatalogResourceType.UNICORE_JOB_SUBMISSION,
+							unicoreJobSubmission);
+	            em.getTransaction().commit();
+	            em.close();
+	            return unicoreSubmissionResource;
+	        } 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<Resource> get(String fieldName, Object value) throws AppCatalogException
{
+	        List<Resource> unicoreSubmissionResourceList = new ArrayList<Resource>();
+	        EntityManager em = null;
+	        try {
+	            em = AppCatalogJPAUtils.getEntityManager();
+	            em.getTransaction().begin();
+	            Query q;
+	            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(UNICORE_JOB_SUBMISSION);
+	            List results;
+	            if (fieldName.equals(UnicoreJobSubmissionConstants.UNICORE_ENDPOINT_URL)) {
+	                generator.setParameter(UnicoreJobSubmissionConstants.UNICORE_ENDPOINT_URL,
value);
+	                q = generator.selectQuery(em);
+	                results = q.getResultList();
+	                if (results.size() != 0) {
+	                    for (Object result : results) {
+	                        UnicoreJobSubmission unicoreJobSubmission = (UnicoreJobSubmission)
result;
+	                        UnicoreJobSubmissionResource unicoreJobSubmissionResource =
+	                                (UnicoreJobSubmissionResource) AppCatalogJPAUtils.getResource(
+	                                        AppCatalogResourceType.UNICORE_JOB_SUBMISSION, unicoreJobSubmission);
+	                        unicoreSubmissionResourceList.add(unicoreJobSubmissionResource);
+	                    }
+	                }
+	            } else if (fieldName.equals(UnicoreJobSubmissionConstants.SECURITY_PROTOCAL))
{
+	                generator.setParameter(UnicoreJobSubmissionConstants.SECURITY_PROTOCAL,
value);
+	                q = generator.selectQuery(em);
+	                results = q.getResultList();
+	                if (results.size() != 0) {
+	                    for (Object result : results) {
+	                        UnicoreJobSubmission unicoreJobSubmission = (UnicoreJobSubmission)
result;
+	                        UnicoreJobSubmissionResource unicoreJobSubmissionResource =
+	                                (UnicoreJobSubmissionResource) AppCatalogJPAUtils.getResource(
+	                                        AppCatalogResourceType.UNICORE_JOB_SUBMISSION, unicoreJobSubmission);
+	                        unicoreSubmissionResourceList.add(unicoreJobSubmissionResource);
+	                    }
+	                }
+	            } else {
+	                em.getTransaction().commit();
+	                em.close();
+	                logger.error("Unsupported field name for Unicore submission resource.",
new IllegalArgumentException());
+	                throw new IllegalArgumentException("Unsupported field name for Unicore Submission
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 unicoreSubmissionResourceList;
+	    }
+
+	@Override
+	public List<Resource> getAll() throws AppCatalogException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public List<String> getAllIds() throws AppCatalogException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+    public List<String> getIds(String fieldName, Object value) throws AppCatalogException
{
+        List<String> globusSubmissionResourceIDs = new ArrayList<String>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_SUBMISSION);
+            List results;
+            if (fieldName.equals(GlobusJobSubmissionConstants.SUBMISSION_ID)) {
+                generator.setParameter(GlobusJobSubmissionConstants.SUBMISSION_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
+                        globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
+                    }
+                }
+            } else if (fieldName.equals(GlobusJobSubmissionConstants.GLOBUS_GATEKEEPER_EP))
{
+                generator.setParameter(GlobusJobSubmissionConstants.GLOBUS_GATEKEEPER_EP,
value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
+                        globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
+                    }
+                }
+            }
+            else if (fieldName.equals(GlobusJobSubmissionConstants.SECURITY_PROTOCAL)) {
+                generator.setParameter(GlobusJobSubmissionConstants.SECURITY_PROTOCAL, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
+                        globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
+                    }
+                }
+            } else if (fieldName.equals(GlobusJobSubmissionConstants.RESOURCE_JOB_MANAGER))
{
+                generator.setParameter(GlobusJobSubmissionConstants.RESOURCE_JOB_MANAGER,
value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
+                        globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
+                    }
+                }
+            } else {
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported field name for Globus Submission resource.", new
IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for Globus Submission
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 globusSubmissionResourceIDs;
+    }
+
+    public void save() throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            UnicoreJobSubmission existingUnicoreSubmission = em.find(UnicoreJobSubmission.class,
jobSubmissionInterfaceId);
+            em.close();
+
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            if (existingUnicoreSubmission != null) {
+                existingUnicoreSubmission.setSubmissionID(jobSubmissionInterfaceId);;
+                existingUnicoreSubmission.setUnicoreEndpointUrl(unicoreEndpointUrl);
+                existingUnicoreSubmission.setSecurityProtocol(securityProtocol);
+                em.merge(existingUnicoreSubmission);
+            } else {
+            	UnicoreJobSubmission unicoreJobSubmission = new UnicoreJobSubmission();
+                unicoreJobSubmission.setSubmissionID(jobSubmissionInterfaceId);
+                unicoreJobSubmission.setUnicoreEndpointUrl(unicoreEndpointUrl);
+                unicoreJobSubmission.setSecurityProtocol(securityProtocol);
+                em.persist(unicoreJobSubmission);
+            }
+            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 {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            UnicoreJobSubmission unicoreJobSubmission = em.find(UnicoreJobSubmission.class,
identifier);
+            em.close();
+            return unicoreJobSubmission != 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 getjobSubmissionInterfaceId() {
+		return jobSubmissionInterfaceId;
+	}
+
+	public void setjobSubmissionInterfaceId(String jobSubmissionInterfaceId) {
+		this.jobSubmissionInterfaceId = jobSubmissionInterfaceId;
+	}
+
+	public String getSecurityProtocol() {
+		return securityProtocol;
+	}
+
+	public void setSecurityProtocol(String securityProtocol) {
+		this.securityProtocol = securityProtocol;
+	}
+
+	public String getUnicoreEndpointUrl() {
+		return unicoreEndpointUrl;
+	}
+
+	public void setUnicoreEndpointUrl(String unicoreEndpointUrl) {
+		this.unicoreEndpointUrl = unicoreEndpointUrl;
+	}
+	
+	
+}


Mime
View raw message