Added Added initial files for entities,repositories for allocation manager module
authorHarsha Phulwani <harshaphulwani16@gmail.com>
Mon, 13 Nov 2017 06:56:30 +0000 (01:56 -0500)
committerSuresh Marru <smarru@apache.org>
Fri, 17 Nov 2017 23:57:30 +0000 (18:57 -0500)
allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/entities/RequestStatusEntity.java [new file with mode: 0644]
allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/entities/UserAllocationDetailEntity.java [new file with mode: 0644]
allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/entities/UserAllocationDetailPKEntity.java [new file with mode: 0644]
allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/entities/UserDetailEntity.java [new file with mode: 0644]
allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/repositories/AbstractRepository.java [new file with mode: 0644]
allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/repositories/RequestStatusRepository.java [new file with mode: 0644]
allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/repositories/UserAllocationDetailPKRepository.java [new file with mode: 0644]
allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/repositories/UserAllocationDetailRepository.java [new file with mode: 0644]
allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/repositories/UserDetailRepository.java [new file with mode: 0644]
allocation-manager/allocation-manager-server/src/main/resources/META-INF/persistence.xml [new file with mode: 0644]
allocation-manager/allocation-manager-server/src/main/resources/allocation-manager-mysql.sql [new file with mode: 0644]

diff --git a/allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/entities/RequestStatusEntity.java b/allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/entities/RequestStatusEntity.java
new file mode 100644 (file)
index 0000000..4263468
--- /dev/null
@@ -0,0 +1,87 @@
+package org.apache.airavata.allocation.manager.db.entities;\r
+\r
+import java.io.Serializable;\r
+import javax.persistence.*;\r
+import java.math.BigInteger;\r
+\r
+\r
+/**\r
+ * The persistent class for the request_status database table.\r
+ * \r
+ */\r
+@Entity\r
+@Table(name="request_status")\r
+@NamedQuery(name="RequestStatus.findAll", query="SELECT r FROM RequestStatus r")\r
+public class RequestStatus implements Serializable {\r
+       private static final long serialVersionUID = 1L;\r
+\r
+       @Id\r
+       @Column(name="PROJECT_ID")\r
+       private String projectId;\r
+\r
+       @Column(name="AWARD_ALLOCATION")\r
+       private BigInteger awardAllocation;\r
+\r
+       @Column(name="END_DATE")\r
+       private BigInteger endDate;\r
+\r
+       @Lob\r
+       private String reviewers;\r
+\r
+       @Column(name="START_DATE")\r
+       private BigInteger startDate;\r
+\r
+       private String status;\r
+\r
+       public RequestStatus() {\r
+       }\r
+\r
+       public String getProjectId() {\r
+               return this.projectId;\r
+       }\r
+\r
+       public void setProjectId(String projectId) {\r
+               this.projectId = projectId;\r
+       }\r
+\r
+       public BigInteger getAwardAllocation() {\r
+               return this.awardAllocation;\r
+       }\r
+\r
+       public void setAwardAllocation(BigInteger awardAllocation) {\r
+               this.awardAllocation = awardAllocation;\r
+       }\r
+\r
+       public BigInteger getEndDate() {\r
+               return this.endDate;\r
+       }\r
+\r
+       public void setEndDate(BigInteger endDate) {\r
+               this.endDate = endDate;\r
+       }\r
+\r
+       public String getReviewers() {\r
+               return this.reviewers;\r
+       }\r
+\r
+       public void setReviewers(String reviewers) {\r
+               this.reviewers = reviewers;\r
+       }\r
+\r
+       public BigInteger getStartDate() {\r
+               return this.startDate;\r
+       }\r
+\r
+       public void setStartDate(BigInteger startDate) {\r
+               this.startDate = startDate;\r
+       }\r
+\r
+       public String getStatus() {\r
+               return this.status;\r
+       }\r
+\r
+       public void setStatus(String status) {\r
+               this.status = status;\r
+       }\r
+\r
+}
\ No newline at end of file
diff --git a/allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/entities/UserAllocationDetailEntity.java b/allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/entities/UserAllocationDetailEntity.java
new file mode 100644 (file)
index 0000000..7d40899
--- /dev/null
@@ -0,0 +1,202 @@
+package org.apache.airavata.allocation.manager.db.entities;\r
+\r
+import java.io.Serializable;\r
+import javax.persistence.*;\r
+import java.math.BigInteger;\r
+\r
+\r
+/**\r
+ * The persistent class for the user_allocation_details database table.\r
+ * \r
+ */\r
+@Entity\r
+@Table(name="user_allocation_details")\r
+@NamedQuery(name="UserAllocationDetail.findAll", query="SELECT u FROM UserAllocationDetail u")\r
+public class UserAllocationDetail implements Serializable {\r
+       private static final long serialVersionUID = 1L;\r
+\r
+       @EmbeddedId\r
+       private UserAllocationDetailPK id;\r
+\r
+       @Lob\r
+       @Column(name="APPLICATIONS_TO_BE_USED")\r
+       private String applicationsToBeUsed;\r
+\r
+       @Column(name="DISK_USAGE_RANGE_PER_JOB")\r
+       private BigInteger diskUsageRangePerJob;\r
+\r
+       @Lob\r
+       private byte[] documents;\r
+\r
+       @Lob\r
+       @Column(name="FIELD_OF_SCIENCE")\r
+       private String fieldOfScience;\r
+\r
+       @Lob\r
+       private String keywords;\r
+\r
+       @Column(name="MAX_MEMORY_PER_CPU")\r
+       private BigInteger maxMemoryPerCpu;\r
+\r
+       @Column(name="NUMBER_OF_CPU_PER_JOB")\r
+       private BigInteger numberOfCpuPerJob;\r
+\r
+       @Lob\r
+       @Column(name="PROJECT_DESCRIPTION")\r
+       private String projectDescription;\r
+\r
+       @Lob\r
+       @Column(name="PROJECT_REVIEWED_AND_FUNDED_BY")\r
+       private String projectReviewedAndFundedBy;\r
+\r
+       @Column(name="REQUESTED_DATE")\r
+       private BigInteger requestedDate;\r
+\r
+       @Column(name="SERVICE_UNITS")\r
+       private BigInteger serviceUnits;\r
+\r
+       @Lob\r
+       @Column(name="SPECIFIC_RESOURCE_SELECTION")\r
+       private String specificResourceSelection;\r
+\r
+       @Lob\r
+       private String title;\r
+\r
+       @Column(name="TYPE_OF_ALLOCATION")\r
+       private String typeOfAllocation;\r
+\r
+       @Column(name="TYPICAL_SU_PER_JOB")\r
+       private BigInteger typicalSuPerJob;\r
+\r
+       public UserAllocationDetail() {\r
+       }\r
+\r
+       public UserAllocationDetailPK getId() {\r
+               return this.id;\r
+       }\r
+\r
+       public void setId(UserAllocationDetailPK id) {\r
+               this.id = id;\r
+       }\r
+\r
+       public String getApplicationsToBeUsed() {\r
+               return this.applicationsToBeUsed;\r
+       }\r
+\r
+       public void setApplicationsToBeUsed(String applicationsToBeUsed) {\r
+               this.applicationsToBeUsed = applicationsToBeUsed;\r
+       }\r
+\r
+       public BigInteger getDiskUsageRangePerJob() {\r
+               return this.diskUsageRangePerJob;\r
+       }\r
+\r
+       public void setDiskUsageRangePerJob(BigInteger diskUsageRangePerJob) {\r
+               this.diskUsageRangePerJob = diskUsageRangePerJob;\r
+       }\r
+\r
+       public byte[] getDocuments() {\r
+               return this.documents;\r
+       }\r
+\r
+       public void setDocuments(byte[] documents) {\r
+               this.documents = documents;\r
+       }\r
+\r
+       public String getFieldOfScience() {\r
+               return this.fieldOfScience;\r
+       }\r
+\r
+       public void setFieldOfScience(String fieldOfScience) {\r
+               this.fieldOfScience = fieldOfScience;\r
+       }\r
+\r
+       public String getKeywords() {\r
+               return this.keywords;\r
+       }\r
+\r
+       public void setKeywords(String keywords) {\r
+               this.keywords = keywords;\r
+       }\r
+\r
+       public BigInteger getMaxMemoryPerCpu() {\r
+               return this.maxMemoryPerCpu;\r
+       }\r
+\r
+       public void setMaxMemoryPerCpu(BigInteger maxMemoryPerCpu) {\r
+               this.maxMemoryPerCpu = maxMemoryPerCpu;\r
+       }\r
+\r
+       public BigInteger getNumberOfCpuPerJob() {\r
+               return this.numberOfCpuPerJob;\r
+       }\r
+\r
+       public void setNumberOfCpuPerJob(BigInteger numberOfCpuPerJob) {\r
+               this.numberOfCpuPerJob = numberOfCpuPerJob;\r
+       }\r
+\r
+       public String getProjectDescription() {\r
+               return this.projectDescription;\r
+       }\r
+\r
+       public void setProjectDescription(String projectDescription) {\r
+               this.projectDescription = projectDescription;\r
+       }\r
+\r
+       public String getProjectReviewedAndFundedBy() {\r
+               return this.projectReviewedAndFundedBy;\r
+       }\r
+\r
+       public void setProjectReviewedAndFundedBy(String projectReviewedAndFundedBy) {\r
+               this.projectReviewedAndFundedBy = projectReviewedAndFundedBy;\r
+       }\r
+\r
+       public BigInteger getRequestedDate() {\r
+               return this.requestedDate;\r
+       }\r
+\r
+       public void setRequestedDate(BigInteger requestedDate) {\r
+               this.requestedDate = requestedDate;\r
+       }\r
+\r
+       public BigInteger getServiceUnits() {\r
+               return this.serviceUnits;\r
+       }\r
+\r
+       public void setServiceUnits(BigInteger serviceUnits) {\r
+               this.serviceUnits = serviceUnits;\r
+       }\r
+\r
+       public String getSpecificResourceSelection() {\r
+               return this.specificResourceSelection;\r
+       }\r
+\r
+       public void setSpecificResourceSelection(String specificResourceSelection) {\r
+               this.specificResourceSelection = specificResourceSelection;\r
+       }\r
+\r
+       public String getTitle() {\r
+               return this.title;\r
+       }\r
+\r
+       public void setTitle(String title) {\r
+               this.title = title;\r
+       }\r
+\r
+       public String getTypeOfAllocation() {\r
+               return this.typeOfAllocation;\r
+       }\r
+\r
+       public void setTypeOfAllocation(String typeOfAllocation) {\r
+               this.typeOfAllocation = typeOfAllocation;\r
+       }\r
+\r
+       public BigInteger getTypicalSuPerJob() {\r
+               return this.typicalSuPerJob;\r
+       }\r
+\r
+       public void setTypicalSuPerJob(BigInteger typicalSuPerJob) {\r
+               this.typicalSuPerJob = typicalSuPerJob;\r
+       }\r
+\r
+}
\ No newline at end of file
diff --git a/allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/entities/UserAllocationDetailPKEntity.java b/allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/entities/UserAllocationDetailPKEntity.java
new file mode 100644 (file)
index 0000000..93f8502
--- /dev/null
@@ -0,0 +1,56 @@
+package org.apache.airavata.allocation.manager.db.entities;\r
+\r
+import java.io.Serializable;\r
+import javax.persistence.*;\r
+\r
+/**\r
+ * The primary key class for the user_allocation_details database table.\r
+ * \r
+ */\r
+@Embeddable\r
+public class UserAllocationDetailPK implements Serializable {\r
+       //default serial version id, required for serializable classes.\r
+       private static final long serialVersionUID = 1L;\r
+\r
+       @Column(name="PROJECT_ID")\r
+       private String projectId;\r
+\r
+       private String username;\r
+\r
+       public UserAllocationDetailPK() {\r
+       }\r
+       public String getProjectId() {\r
+               return this.projectId;\r
+       }\r
+       public void setProjectId(String projectId) {\r
+               this.projectId = projectId;\r
+       }\r
+       public String getUsername() {\r
+               return this.username;\r
+       }\r
+       public void setUsername(String username) {\r
+               this.username = username;\r
+       }\r
+\r
+       public boolean equals(Object other) {\r
+               if (this == other) {\r
+                       return true;\r
+               }\r
+               if (!(other instanceof UserAllocationDetailPK)) {\r
+                       return false;\r
+               }\r
+               UserAllocationDetailPK castOther = (UserAllocationDetailPK)other;\r
+               return \r
+                       this.projectId.equals(castOther.projectId)\r
+                       && this.username.equals(castOther.username);\r
+       }\r
+\r
+       public int hashCode() {\r
+               final int prime = 31;\r
+               int hash = 17;\r
+               hash = hash * prime + this.projectId.hashCode();\r
+               hash = hash * prime + this.username.hashCode();\r
+               \r
+               return hash;\r
+       }\r
+}
\ No newline at end of file
diff --git a/allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/entities/UserDetailEntity.java b/allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/entities/UserDetailEntity.java
new file mode 100644 (file)
index 0000000..b27a6bc
--- /dev/null
@@ -0,0 +1,75 @@
+package org.apache.airavata.allocation.manager.db.entities;\r
+\r
+import java.io.Serializable;\r
+import javax.persistence.*;\r
+\r
+\r
+/**\r
+ * The persistent class for the user_details database table.\r
+ * \r
+ */\r
+@Entity\r
+@Table(name="user_details")\r
+@NamedQuery(name="UserDetail.findAll", query="SELECT u FROM UserDetail u")\r
+public class UserDetail implements Serializable {\r
+       private static final long serialVersionUID = 1L;\r
+\r
+       @Id\r
+       private String username;\r
+\r
+       @Lob\r
+       private String email;\r
+\r
+       @Lob\r
+       @Column(name="FULL_NAME")\r
+       private String fullName;\r
+\r
+       private String password;\r
+\r
+       @Column(name="USER_TYPE")\r
+       private String userType;\r
+\r
+       public UserDetail() {\r
+       }\r
+\r
+       public String getUsername() {\r
+               return this.username;\r
+       }\r
+\r
+       public void setUsername(String username) {\r
+               this.username = username;\r
+       }\r
+\r
+       public String getEmail() {\r
+               return this.email;\r
+       }\r
+\r
+       public void setEmail(String email) {\r
+               this.email = email;\r
+       }\r
+\r
+       public String getFullName() {\r
+               return this.fullName;\r
+       }\r
+\r
+       public void setFullName(String fullName) {\r
+               this.fullName = fullName;\r
+       }\r
+\r
+       public String getPassword() {\r
+               return this.password;\r
+       }\r
+\r
+       public void setPassword(String password) {\r
+               this.password = password;\r
+       }\r
+\r
+       public String getUserType() {\r
+               return this.userType;\r
+       }\r
+\r
+       public void setUserType(String userType) {\r
+               this.userType = userType;\r
+       }\r
+\r
+}
\ No newline at end of file
diff --git a/allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/repositories/AbstractRepository.java b/allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/repositories/AbstractRepository.java
new file mode 100644 (file)
index 0000000..0ca393e
--- /dev/null
@@ -0,0 +1,170 @@
+/**
+ *
+ * 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.sharing.registry.db.repositories;
+
+import org.apache.airavata.sharing.registry.db.utils.Committer;
+import org.apache.airavata.sharing.registry.db.utils.DBConstants;
+import org.apache.airavata.sharing.registry.db.utils.JPAUtils;
+import org.apache.airavata.sharing.registry.db.utils.ObjectMapperSingleton;
+import org.apache.airavata.sharing.registry.models.SharingRegistryException;
+import org.dozer.Mapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public abstract class AbstractRepository<T, E, Id> {
+    private final static Logger logger = LoggerFactory.getLogger(AbstractRepository.class);
+
+    private Class<T> thriftGenericClass;
+    private Class<E> dbEntityGenericClass;
+
+    public AbstractRepository(Class<T> thriftGenericClass, Class<E> dbEntityGenericClass){
+        this.thriftGenericClass = thriftGenericClass;
+        this.dbEntityGenericClass = dbEntityGenericClass;
+    }
+
+    public T create(T t) throws SharingRegistryException {
+        return update(t);
+    }
+
+    //FIXME do a bulk insert
+    public List<T> create(List<T> tList) throws SharingRegistryException {
+        return update(tList);
+    }
+    
+    public List<T> create(String query) throws SharingRegistryException {
+       // String query = "INSERT INTO " + dbEntityGenericClass.getSimpleName() + " values("+values+")";
+       execute(entityManager -> {
+            javax.persistence.Query q = entityManager.createQuery(query);
+        });
+    }
+
+    public  T update(T t) throws SharingRegistryException {
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        E entity = mapper.map(t, dbEntityGenericClass);
+        E persistedCopy = execute(entityManager -> entityManager.merge(entity));
+        return mapper.map(persistedCopy, thriftGenericClass);
+    }
+
+    //FIXME do a bulk update
+    public  List<T> update(List<T> tList) throws SharingRegistryException {
+        List<T> returnList = new ArrayList<>();
+        for(T temp : tList)
+            returnList.add(update(temp));
+        return returnList;
+    }
+
+    public boolean delete(Id id) throws SharingRegistryException {
+        execute(entityManager -> {
+             E entity = entityManager.find(dbEntityGenericClass, id);
+             entityManager.remove(entity);
+             return entity;
+         });
+        return true;
+    }
+
+    public boolean delete(List<Id> idList) throws SharingRegistryException {
+        for(Id id : idList)
+            delete(id);
+        return true;
+    }
+
+    public T get(Id id) throws SharingRegistryException {
+        E entity = execute(entityManager -> entityManager
+                .find(dbEntityGenericClass, id));
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        if(entity == null)
+            return null;
+        return mapper.map(entity, thriftGenericClass);
+    }
+
+    public boolean isExists(Id id) throws SharingRegistryException {
+        return get(id) != null;
+    }
+
+    public List<T> get(List<Id> idList) throws SharingRegistryException {
+        List<T> returnList = new ArrayList<>();
+        for(Id id : idList)
+            returnList.add(get(id));
+        return returnList;
+    }
+
+    public List<T> select(Map<String, String> filters, int offset, int limit) throws SharingRegistryException {
+        String query = "SELECT DISTINCT p from " + dbEntityGenericClass.getSimpleName() + " as p";
+        ArrayList<String> parameters = new ArrayList<>();
+        int parameterCount = 1;
+        if (filters != null && filters.size() != 0) {
+            query += " WHERE ";
+            for (String k : filters.keySet()) {
+                query += "p." + k + " = ?" + parameterCount + " AND ";
+                parameters.add(filters.get(k));
+                parameterCount++;
+            }
+            query = query.substring(0, query.length() - 5);
+        }
+
+        query += " ORDER BY p.createdTime DESC";
+        String queryString = query;
+        int newLimit = limit < 0 ? DBConstants.SELECT_MAX_ROWS: limit;
+        List resultSet = execute(entityManager -> {
+            javax.persistence.Query q = entityManager.createQuery(queryString);
+            for (int i = 0; i < parameters.size(); i++) {
+                q.setParameter(i + 1, parameters.get(i));
+            }
+            return q.setFirstResult(offset).setMaxResults(newLimit).getResultList();
+        });
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        List<T> gatewayList = new ArrayList<>();
+        resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, thriftGenericClass)));
+        return gatewayList;
+    }
+
+    public List<T> select(String queryString, Map<String,Object> queryParameters, int offset, int limit) throws SharingRegistryException {
+        int newLimit = limit < 0 ? DBConstants.SELECT_MAX_ROWS: limit;
+        List resultSet = execute(entityManager -> {
+            Query q =  entityManager.createQuery(queryString);
+            for(Map.Entry<String, Object> queryParam : queryParameters.entrySet()){
+                q.setParameter(queryParam.getKey(), queryParam.getValue());
+            }
+            return q.setFirstResult(offset).setMaxResults(newLimit).getResultList();
+        });
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        List<T> gatewayList = new ArrayList<>();
+        resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, thriftGenericClass)));
+        return gatewayList;
+    }
+
+    public <R> R execute(Committer<EntityManager, R> committer) throws SharingRegistryException {
+        EntityManager entityManager = JPAUtils.getEntityManager();
+        try {
+            entityManager.getTransaction().begin();
+            R r = committer.commit(entityManager);
+            entityManager.getTransaction().commit();
+            return r;
+        } finally {
+            entityManager.close();
+        }
+    }
+}
\ No newline at end of file
diff --git a/allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/repositories/RequestStatusRepository.java b/allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/repositories/RequestStatusRepository.java
new file mode 100644 (file)
index 0000000..52a2c4e
--- /dev/null
@@ -0,0 +1,14 @@
+package org.apache.airavata.allocation.manager.db.repositories;
+
+import org.apache.airavata.allocation.manager.db.entities.RequestStatusEntity;
+import org.apache.airavata.sharing.registry.models.RequestStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RequestStatusRepository extends AbstractRepository<RequestStatus, RequestStatusEntity, String> {
+    private final static Logger logger = LoggerFactory.getLogger(DomainRepository.class);
+
+    public RequestStatusRepository(){
+        super(RequestStatus.class, RequestStatusEntity.class);
+    }
+}
\ No newline at end of file
diff --git a/allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/repositories/UserAllocationDetailPKRepository.java b/allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/repositories/UserAllocationDetailPKRepository.java
new file mode 100644 (file)
index 0000000..0644f8a
--- /dev/null
@@ -0,0 +1,14 @@
+package org.apache.airavata.allocation.manager.db.repositories;
+
+import org.apache.airavata.allocation.manager.db.entities.UserAllocationDetailPKEntity;
+import org.apache.airavata.sharing.registry.models.UserAllocationDetailPK;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class UserAllocationDetailPKRepository extends AbstractRepository<UserAllocationDetailPK, UserAllocationDetailPKEntity, String> {
+    private final static Logger logger = LoggerFactory.getLogger(DomainRepository.class);
+
+    public UserAllocationDetailPKRepository(){
+        super(UserAllocationDetailPK.class, UserAllocationDetailPKEntity.class);
+    }
+}
\ No newline at end of file
diff --git a/allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/repositories/UserAllocationDetailRepository.java b/allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/repositories/UserAllocationDetailRepository.java
new file mode 100644 (file)
index 0000000..35366d6
--- /dev/null
@@ -0,0 +1,14 @@
+package org.apache.airavata.allocation.manager.db.repositories;
+
+import org.apache.airavata.allocation.manager.db.entities.UserAllocationDetailEntity;
+import org.apache.airavata.sharing.registry.models.UserAllocationDetail;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class UserAllocationDetailRepository extends AbstractRepository<UserAllocationDetail, UserAllocationDetailEntity, String> {
+    private final static Logger logger = LoggerFactory.getLogger(DomainRepository.class);
+
+    public UserAllocationDetailRepository(){
+        super(UserAllocationDetail.class, UserAllocationDetailEntity.class);
+    }
+}
\ No newline at end of file
diff --git a/allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/repositories/UserDetailRepository.java b/allocation-manager/allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/repositories/UserDetailRepository.java
new file mode 100644 (file)
index 0000000..55cd888
--- /dev/null
@@ -0,0 +1,19 @@
+package org.apache.airavata.allocation.manager.db.repositories;
+
+import org.apache.airavata.allocation.manager.db.entities.UserDetailEntity;
+import org.apache.airavata.sharing.registry.models.UserDetail;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class UserDetailRepository extends AbstractRepository<UserDetail, UserAllocationEntity, String> {
+    private final static Logger logger = LoggerFactory.getLogger(DomainRepository.class);
+
+    public UserDetailRepository(){
+        super(UserDetail.class, UserDetailEntity.class);
+    }
+
+    public static void main(String args[])
+    {
+
+    }
+}
\ No newline at end of file
diff --git a/allocation-manager/allocation-manager-server/src/main/resources/META-INF/persistence.xml b/allocation-manager/allocation-manager-server/src/main/resources/META-INF/persistence.xml
new file mode 100644 (file)
index 0000000..a006ad6
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
+
+    <persistence-unit name="airavata-allocation-manager">
+        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+        <class>org.apache.airavata.allocation.manager.db.entities.UserAllocationDetailEntity</class>
+        <class>org.apache.airavata.allocation.manager.db.entities.UserAllocationDetailPKEntity</class>
+        <class>org.apache.airavata.allocation.manager.db.entities.RequestStatusEntity</class>
+        <class>org.apache.airavata.allocation.manager.db.entities.UserDetailEntity</class>
+    </persistence-unit>
+</persistence>
diff --git a/allocation-manager/allocation-manager-server/src/main/resources/allocation-manager-mysql.sql b/allocation-manager/allocation-manager-server/src/main/resources/allocation-manager-mysql.sql
new file mode 100644 (file)
index 0000000..20824f6
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+CREATE TABLE IF NOT EXISTS USER_ALLOCATION_DETAILS (
+    REQUESTED_DATE BIGINT NOT NULL,
+    TITLE TEXT NOT NULL,
+    PROJECT_DESCRIPTION TEXT NOT NULL,
+    KEYWORDS TEXT,
+    FIELD_OF_SCIENCE TEXT,
+    DOCUMENTS BLOB,
+    TYPE_OF_ALLOCATION VARCHAR (255) NOT NULL,
+    USERNAME VARCHAR (255) NOT NULL,
+    PROJECT_ID VARCHAR (255) ,
+    APPLICATIONS_TO_BE_USED TEXT,
+    SPECIFIC_RESOURCE_SELECTION TEXT,
+    SERVICE_UNITS BIGINT default 1,
+    TYPICAL_SU_PER_JOB BIGINT,
+    MAX_MEMORY_PER_CPU BIGINT,
+    DISK_USAGE_RANGE_PER_JOB BIGINT,
+    NUMBER_OF_CPU_PER_JOB BIGINT,
+    PROJECT_REVIEWED_AND_FUNDED_BY TEXT,
+    PRIMARY KEY (PROJECT_ID, USERNAME)
+);
+
+CREATE TABLE IF NOT EXISTS USER_DETAILS (
+    USERNAME VARCHAR (255) PRIMARY KEY,
+    PASSWORD VARCHAR (255) NOT NULL,
+    FULL_NAME TEXT,
+    EMAIL TEXT NOT NULL,
+    USER_TYPE VARCHAR (255) NOT NULL
+);
+
+CREATE TABLE IF NOT EXISTS REQUEST_STATUS (
+    PROJECT_ID VARCHAR (255) PRIMARY KEY,
+    STATUS VARCHAR (255) NOT NULL,
+    REVIEWERS TEXT,
+    START_DATE BIGINT,
+    END_DATE BIGINT,
+    AWARD_ALLOCATION BIGINT
+);