You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by di...@apache.org on 2026/07/25 14:05:36 UTC
(airavata) branch refactor-single-module updated: Adding project data models
This is an automated email from the ASF dual-hosted git repository.
DImuthuUpe pushed a commit to branch refactor-single-module
in repository https://gitbox.apache.org/repos/asf/airavata.git
The following commit(s) were added to refs/heads/refactor-single-module by this push:
new 993d361e03 Adding project data models
993d361e03 is described below
commit 993d361e03b9586274a8b9a4a35d679c847ff45a
Author: DImuthuUpe <di...@gmail.com>
AuthorDate: Sat Jul 25 10:05:30 2026 -0400
Adding project data models
---
.../java/org/apache/airavata/common/Constants.java | 66 +++++++
.../experiment/mapper/ExperimentMapper.java | 8 +
.../airavata/experiment/model/ProjectEntity.java | 103 ++++++++++
.../experiment/repository/ProjectRepository.java | 219 +++++++++++++++++++++
4 files changed, 396 insertions(+)
diff --git a/src/main/java/org/apache/airavata/common/Constants.java b/src/main/java/org/apache/airavata/common/Constants.java
index d9fdc94661..80bb2b2826 100644
--- a/src/main/java/org/apache/airavata/common/Constants.java
+++ b/src/main/java/org/apache/airavata/common/Constants.java
@@ -55,4 +55,70 @@ public final class Constants {
public static final String ROLE_READ_ONLY_ADMIN = "admin-ro";
public static final String ENABLE_STREAMING_TRANSFER = "enable.streaming.transfer";
+
+ public final class FieldConstants {
+ public final class ProjectConstants {
+ public static final String PROJECT_ID = "projectID";
+ public static final String GATEWAY_ID = "gateway_id";
+ public static final String OWNER = "owner";
+ public static final String PROJECT_NAME = "name";
+ public static final String DESCRIPTION = "description";
+ public static final String CREATION_TIME = "creationTime";
+ }
+
+ public final class ExperimentConstants {
+ public static final String EXPERIMENT_ID = "experimentId";
+ public static final String PROJECT_ID = "projectId";
+ public static final String GATEWAY_ID = "gatewayId";
+ public static final String EXPERIMENT_TYPE = "experimentType";
+ public static final String USER_NAME = "userName";
+ public static final String EXPERIMENT_NAME = "experimentName";
+ public static final String CREATION_TIME = "creationTime";
+ public static final String DESCRIPTION = "description";
+ public static final String EXECUTION_ID = "executionId";
+ public static final String GATEWAY_EXECUTION_ID = "gatewayExecutionId";
+ public static final String ENABLE_EMAIL_NOTIFICATION = "enableEmailNotification";
+ public static final String EMAIL_ADDRESSES = "emailAddresses";
+ public static final String EXPERIMENT_INPUTS = "experimentInputs";
+ public static final String EXPERIMENT_OUTPUTS = "experimentOutputs";
+ public static final String EXPERIMENT_STATUS = "experimentStatus";
+ public static final String EXPERIMENT_ERRORS = "experimentErrors";
+ public static final String USER_CONFIGURATION_DATA = "userConfigurationData";
+ public static final String FROM_DATE = "fromDate";
+ public static final String TO_DATE = "toDate";
+ public static final String RESOURCE_HOST_ID = "resourceHostId";
+ }
+
+ public final class UserConfigurationDataConstants {
+ public static final String EXPERIMENT_ID = "experimentId";
+ public static final String AIRAVATA_AUTO_SCHEDULE = "airavataAutoSchedule";
+ public static final String OVERRIDE_MANUAL_PARAMS = "overrideManualScheduledParams";
+ public static final String SHARE_EXP = "shareExperimentPublicly";
+ public static final String COMPUTATIONAL_RESOURCE_SCHEDULING = "computationalResourceScheduling";
+ }
+
+ public final class ProcessConstants {
+ public static final String EXPERIMENT_ID = "experimentId";
+ public static final String PROCESS_ID = "processId";
+ public static final String PROCESS_STATUS = "processStatus";
+ public static final String PROCESS_ERROR = "processError";
+ public static final String PROCESS_INPUTS = "processInputs";
+ public static final String PROCESS_OUTPUTS = "processOutputs";
+ public static final String PROCESS_RESOURCE_SCHEDULE = "processResourceSchedule";
+ }
+
+ public final class TaskConstants {
+ public static final String PARENT_PROCESS_ID = "parentProcessId";
+ public static final String TASK_ID = "taskId";
+ public static final String TASK_STATUS = "taskStatus";
+ public static final String TASK_ERROR = "taskError";
+ }
+
+ public final class JobConstants {
+ public static final String JOB_ID = "jobId";
+ public static final String PROCESS_ID = "processId";
+ public static final String TASK_ID = "taskId";
+ public static final String JOB_STATUS = "taskStatus";
+ }
+ }
}
diff --git a/src/main/java/org/apache/airavata/experiment/mapper/ExperimentMapper.java b/src/main/java/org/apache/airavata/experiment/mapper/ExperimentMapper.java
index b0a9db7598..52d1170eb4 100644
--- a/src/main/java/org/apache/airavata/experiment/mapper/ExperimentMapper.java
+++ b/src/main/java/org/apache/airavata/experiment/mapper/ExperimentMapper.java
@@ -28,6 +28,7 @@ import org.apache.airavata.model.commons.proto.ErrorModel;
import org.apache.airavata.model.experiment.proto.ExperimentModel;
import org.apache.airavata.model.experiment.proto.ExperimentSummaryModel;
import org.apache.airavata.model.status.proto.ExperimentStatus;
+import org.apache.airavata.model.workspace.proto.Project;
import org.apache.airavata.experiment.model.*;
import org.mapstruct.AfterMapping;
import org.mapstruct.Mapper;
@@ -41,6 +42,13 @@ public interface ExperimentMapper extends CommonMapperConversions {
ExperimentMapper INSTANCE = Mappers.getMapper(ExperimentMapper.class);
+ // --- Project ---
+ @Mapping(target = "projectId", source = "projectID")
+ Project projectToModel(ProjectEntity entity);
+
+ @Mapping(target = "projectID", source = "projectId")
+ ProjectEntity projectToEntity(Project model);
+
// --- Experiment ---
@Mapping(target = "emailAddressesList", ignore = true)
ExperimentModel experimentToModel(ExperimentEntity entity);
diff --git a/src/main/java/org/apache/airavata/experiment/model/ProjectEntity.java b/src/main/java/org/apache/airavata/experiment/model/ProjectEntity.java
new file mode 100644
index 0000000000..85fc1402c8
--- /dev/null
+++ b/src/main/java/org/apache/airavata/experiment/model/ProjectEntity.java
@@ -0,0 +1,103 @@
+/**
+*
+* 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.experiment.model;
+
+import jakarta.persistence.*;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ * The persistent class for the project database table.
+ */
+@Entity
+@Table(name = "PROJECT")
+public class ProjectEntity implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @Column(name = "PROJECT_ID")
+ private String projectID;
+
+ @Column(name = "USER_NAME")
+ private String owner;
+
+ @Column(name = "GATEWAY_ID")
+ private String gatewayId;
+
+ @Column(name = "PROJECT_NAME")
+ private String name;
+
+ @Column(name = "DESCRIPTION")
+ private String description;
+
+ @Column(name = "CREATION_TIME")
+ private Timestamp creationTime;
+
+ public ProjectEntity() {
+ }
+
+ public String getProjectID() {
+ return projectID;
+ }
+
+ public void setProjectID(String projectID) {
+ this.projectID = projectID;
+ }
+
+ public String getOwner() {
+ return owner;
+ }
+
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+
+ public String getGatewayId() {
+ return gatewayId;
+ }
+
+ public void setGatewayId(String gatewayId) {
+ this.gatewayId = gatewayId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Timestamp getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Timestamp creationTime) {
+ this.creationTime = creationTime;
+ }
+}
diff --git a/src/main/java/org/apache/airavata/experiment/repository/ProjectRepository.java b/src/main/java/org/apache/airavata/experiment/repository/ProjectRepository.java
new file mode 100644
index 0000000000..b59a6bac85
--- /dev/null
+++ b/src/main/java/org/apache/airavata/experiment/repository/ProjectRepository.java
@@ -0,0 +1,219 @@
+/**
+*
+* 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.experiment.repository;
+
+import java.sql.Timestamp;
+import java.util.*;
+import org.apache.airavata.db.AbstractRepository;
+import org.apache.airavata.db.DBConstants;
+import org.apache.airavata.db.QueryConstants;
+import org.apache.airavata.common.Constants;
+import org.apache.airavata.common.ResultOrderType;
+import org.apache.airavata.model.workspace.proto.Project;
+import org.apache.airavata.experiment.mapper.ExperimentMapper;
+import org.apache.airavata.experiment.model.ProjectEntity;
+import org.apache.airavata.common.AiravataUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ProjectRepository extends AbstractRepository<Project, ProjectEntity, String> {
+ private static final Logger logger = LoggerFactory.getLogger(ProjectRepository.class);
+
+ public ProjectRepository() {
+ super(Project.class, ProjectEntity.class);
+ }
+
+ @Override
+ protected Project toModel(ProjectEntity entity) {
+ return ExperimentMapper.INSTANCE.projectToModel(entity);
+ }
+
+ @Override
+ protected ProjectEntity toEntity(Project model) {
+ return ExperimentMapper.INSTANCE.projectToEntity(model);
+ }
+
+ protected String saveProjectData(Project project, String gatewayId) throws Exception {
+ ProjectEntity projectEntity = saveProject(project, gatewayId);
+ return projectEntity.getProjectID();
+ }
+
+ protected ProjectEntity saveProject(Project project, String gatewayId) throws Exception {
+ if (project.getProjectId().isEmpty() || project.getProjectId().equals("DO_NOT_SET_AT_CLIENTS")) {
+ logger.debug("Setting the Project's ProjectId");
+ project = project.toBuilder()
+ .setProjectId(AiravataUtils.getId(project.getName()))
+ .build();
+ }
+ ProjectEntity projectEntity = ExperimentMapper.INSTANCE.projectToEntity(project);
+
+ if (project.getGatewayId().isEmpty()) {
+ logger.debug("Setting the Project's GatewayId");
+ projectEntity.setGatewayId(gatewayId);
+ }
+
+ if (!isProjectExist(projectEntity.getProjectID())) {
+ logger.debug("Checking if the Project already exists");
+ projectEntity.setCreationTime(new Timestamp((System.currentTimeMillis())));
+ }
+
+ return execute(entityManager -> entityManager.merge(projectEntity));
+ }
+
+ public String addProject(Project project, String gatewayId) throws Exception {
+ return saveProjectData(project, gatewayId);
+ }
+
+ public void updateProject(Project project, String projectId) throws Exception {
+ project = project.toBuilder().setProjectId(projectId).build();
+ saveProjectData(project, project.getGatewayId());
+ }
+
+ public Project getProject(String projectId) throws Exception {
+ return get(projectId);
+ }
+
+ public List<Project> getProjectList(String fieldName, Object value) throws Exception {
+ return getProjectList(fieldName, value, -1, 0, null, null);
+ }
+
+ public List<Project> getProjectList(
+ String fieldName,
+ Object value,
+ int limit,
+ int offset,
+ Object orderByIdentifier,
+ ResultOrderType resultOrderType)
+ throws Exception {
+ Map<String, Object> queryParameters = new HashMap<>();
+
+ if (fieldName.equals(Constants.FieldConstants.ProjectConstants.OWNER)) {
+ logger.debug("Checking if the field name is owner");
+ queryParameters.put(DBConstants.Project.OWNER, value);
+ List<Project> projectList = select(QueryConstants.GET_ALL_PROJECTS_FOR_OWNER, limit, offset,
+ queryParameters);
+
+ if (projectList != null && !projectList.isEmpty()) {
+ logger.debug("The retrieved list is not empty or null");
+ return projectList;
+ }
+
+ } else {
+ logger.error("Unsupported field name for Project module.");
+ throw new IllegalArgumentException("Unsupported field name for Project module.");
+ }
+
+ return null;
+ }
+
+ public List<String> getProjectIDs(String fieldName, Object value) throws Exception {
+ List<Project> projectList = getProjectList(fieldName, value);
+ List<String> projectIds = new ArrayList<>();
+
+ if (projectList != null && !projectList.isEmpty()) {
+ logger.debug("The retrieved list is not empty or null");
+ for (Project project : projectList) {
+ projectIds.add(project.getProjectId());
+ }
+ }
+
+ return projectIds;
+ }
+
+ public List<Project> searchProjects(
+ Map<String, String> filters,
+ int limit,
+ int offset,
+ Object orderByIdentifier,
+ ResultOrderType resultOrderType)
+ throws Exception {
+ return searchAllAccessibleProjects(null, filters, limit, offset, orderByIdentifier, resultOrderType);
+ }
+
+ public List<Project> searchAllAccessibleProjects(
+ List<String> accessibleProjectIds,
+ Map<String, String> filters,
+ int limit,
+ int offset,
+ Object orderByIdentifier,
+ ResultOrderType resultOrderType)
+ throws Exception {
+ String query = "SELECT P FROM " + ProjectEntity.class.getSimpleName() + " P WHERE ";
+ Map<String, Object> queryParameters = new HashMap<>();
+
+ if (filters == null || !filters.containsKey(Constants.FieldConstants.ProjectConstants.GATEWAY_ID)) {
+ logger.error("GatewayId is required");
+ throw new Exception("GatewayId is required");
+ }
+
+ for (String field : filters.keySet()) {
+
+ if (field.equals(Constants.FieldConstants.ProjectConstants.GATEWAY_ID)) {
+ logger.debug("Filter Projects by Gateway ID");
+ queryParameters.put(DBConstants.Project.GATEWAY_ID, filters.get(field));
+ query += "P.gatewayId LIKE :" + DBConstants.Project.GATEWAY_ID + " AND ";
+ } else if (field.equals(Constants.FieldConstants.ProjectConstants.OWNER)) {
+ logger.debug("Filter Projects by Owner");
+ queryParameters.put(DBConstants.Project.OWNER, filters.get(field));
+ query += "P.owner LIKE :" + DBConstants.Project.OWNER + " AND ";
+ } else if (field.equals(Constants.FieldConstants.ProjectConstants.PROJECT_NAME)) {
+ logger.debug("Filter Projects by Project Name");
+ queryParameters.put(DBConstants.Project.PROJECT_NAME, filters.get(field));
+ query += "P.name LIKE :" + DBConstants.Project.PROJECT_NAME + " AND ";
+ } else if (field.equals(Constants.FieldConstants.ProjectConstants.DESCRIPTION)) {
+ logger.debug("Filter Projects by Description");
+ queryParameters.put(DBConstants.Project.DESCRIPTION, filters.get(field));
+ query += "P.description LIKE :" + DBConstants.Project.DESCRIPTION + " AND ";
+ } else {
+ logger.error("Unsupported field name for Project module.");
+ throw new IllegalArgumentException("Unsupported field name for Project module.");
+ }
+ }
+
+ if (accessibleProjectIds != null && !accessibleProjectIds.isEmpty()) {
+ logger.debug("Filter Projects by Accessible Project IDs");
+ queryParameters.put(DBConstants.Project.ACCESSIBLE_PROJECT_IDS, accessibleProjectIds);
+ query += "P.projectID IN :" + DBConstants.Project.ACCESSIBLE_PROJECT_IDS;
+ } else {
+ logger.debug("Removing the last operator from the query");
+ query = query.substring(0, query.length() - 5);
+ }
+
+ if (orderByIdentifier != null
+ && resultOrderType != null
+ && orderByIdentifier.equals(Constants.FieldConstants.ProjectConstants.CREATION_TIME)) {
+ String order = (resultOrderType == ResultOrderType.ASC) ? "ASC" : "DESC";
+ query += " ORDER BY P." + DBConstants.Project.CREATION_TIME + " " + order;
+ }
+
+ List<Project> projectList = select(query, limit, offset, queryParameters);
+ return projectList;
+ }
+
+ public boolean isProjectExist(String projectId) throws Exception {
+ return isExists(projectId);
+ }
+
+ public void removeProject(String projectId) throws Exception {
+ delete(projectId);
+ }
+}