http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment_Input_PK.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment_Input_PK.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment_Input_PK.java new file mode 100644 index 0000000..73a83a7 --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment_Input_PK.java @@ -0,0 +1,64 @@ +/* + * + * 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.persistance.registry.jpa.model; + +import java.io.Serializable; + +public class Experiment_Input_PK implements Serializable { + private String experiment_id; + private String ex_key; + + public Experiment_Input_PK(String experiment_id, String ex_key) { + this.experiment_id = experiment_id; + this.ex_key = ex_key; + } + + public Experiment_Input_PK() { + ; + } + + @Override + public boolean equals(Object o) { + return false; + } + + @Override + public int hashCode() { + return 1; + } + + public String getExperiment_id() { + return experiment_id; + } + + public void setExperiment_id(String experiment_id) { + this.experiment_id = experiment_id; + } + + public String getEx_key() { + return ex_key; + } + + public void setEx_key(String ex_key) { + this.ex_key = ex_key; + } +}
http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment_Output.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment_Output.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment_Output.java new file mode 100644 index 0000000..ece544e --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment_Output.java @@ -0,0 +1,151 @@ +/* + * + * 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.persistance.registry.jpa.model; + +import org.apache.openjpa.persistence.DataCache; + +import javax.persistence.*; +import java.io.Serializable; + +@DataCache +@Entity +@Table(name ="EXPERIMENT_OUTPUT") +@IdClass(Experiment_Output_PK.class) +public class Experiment_Output implements Serializable { + @Id + @Column(name = "EXPERIMENT_ID") + private String experiment_id; + + @Id + @Column(name = "OUTPUT_KEY") + private String ex_key; + @Lob + @Column(name = "VALUE") + private char[] value; + @Column(name = "DATA_TYPE") + private String dataType; + + @Column(name = "IS_REQUIRED") + private boolean isRequired; + @Column(name="REQUIRED_TO_COMMANDLINE") + private boolean requiredToCMD; + @Column(name = "DATA_MOVEMENT") + private boolean dataMovement; + @Column(name = "DATA_NAME_LOCATION") + private String dataNameLocation; + @Column(name = "SEARCH_QUERY") + private String searchQuery; + @Column(name = "APP_ARGUMENT") + private String applicationArgument; + + @ManyToOne + @JoinColumn(name = "EXPERIMENT_ID") + private Experiment experiment; + + public String getExperiment_id() { + return experiment_id; + } + + public void setExperiment_id(String experiment_id) { + this.experiment_id = experiment_id; + } + + public String getEx_key() { + return ex_key; + } + + public void setEx_key(String ex_key) { + this.ex_key = ex_key; + } + + public char[] getValue() { + return value; + } + + public void setValue(char[] value) { + this.value = value; + } + + public String getDataType() { + return dataType; + } + + public void setDataType(String dataType) { + this.dataType = dataType; + } + + public Experiment getExperiment() { + return experiment; + } + + public void setExperiment(Experiment experiment) { + this.experiment = experiment; + } + + public boolean isRequired() { + return isRequired; + } + + public void setRequired(boolean isRequired) { + this.isRequired = isRequired; + } + + public boolean isRequiredToCMD() { + return requiredToCMD; + } + + public void setRequiredToCMD(boolean requiredToCMD) { + this.requiredToCMD = requiredToCMD; + } + + public boolean isDataMovement() { + return dataMovement; + } + + public void setDataMovement(boolean dataMovement) { + this.dataMovement = dataMovement; + } + + public String getDataNameLocation() { + return dataNameLocation; + } + + public void setDataNameLocation(String dataNameLocation) { + this.dataNameLocation = dataNameLocation; + } + + public String getSearchQuery() { + return searchQuery; + } + + public void setSearchQuery(String searchQuery) { + this.searchQuery = searchQuery; + } + + public String getApplicationArgument() { + return applicationArgument; + } + + public void setApplicationArgument(String applicationArgument) { + this.applicationArgument = applicationArgument; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment_Output_PK.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment_Output_PK.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment_Output_PK.java new file mode 100644 index 0000000..c41d8d9 --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment_Output_PK.java @@ -0,0 +1,64 @@ +/* + * + * 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.persistance.registry.jpa.model; + +import java.io.Serializable; + +public class Experiment_Output_PK implements Serializable { + private String experiment_id; + private String ex_key; + + public Experiment_Output_PK(String experiment_id, String ex_key) { + this.experiment_id = experiment_id; + this.ex_key = ex_key; + } + + public Experiment_Output_PK() { + ; + } + + @Override + public boolean equals(Object o) { + return false; + } + + @Override + public int hashCode() { + return 1; + } + + public String getExperiment_id() { + return experiment_id; + } + + public void setExperiment_id(String experiment_id) { + this.experiment_id = experiment_id; + } + + public String getEx_key() { + return ex_key; + } + + public void setEx_key(String ex_key) { + this.ex_key = ex_key; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Gateway.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Gateway.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Gateway.java new file mode 100644 index 0000000..7619f17 --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Gateway.java @@ -0,0 +1,76 @@ +/* + * + * 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.persistance.registry.jpa.model; + +import org.apache.openjpa.persistence.DataCache; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import java.io.Serializable; + +@DataCache +@Entity +@Table(name ="GATEWAY") +public class Gateway implements Serializable { + @Id + @Column(name = "GATEWAY_ID") + private String gateway_id; + @Column(name = "GATEWAY_NAME") + private String gateway_name; + @Column(name = "DOMAIN") + private String domain; + @Column(name = "EMAIL_ADDRESS") + private String emailAddress; + + public String getGateway_name() { + return gateway_name; + } + + public void setGateway_name(String gateway_name) { + this.gateway_name = gateway_name; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getGateway_id() { + return gateway_id; + } + + public void setGateway_id(String gateway_id) { + this.gateway_id = gateway_id; + } + + public String getEmailAddress() { + return emailAddress; + } + + public void setEmailAddress(String emailAddress) { + this.emailAddress = emailAddress; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Gateway_Worker.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Gateway_Worker.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Gateway_Worker.java new file mode 100644 index 0000000..12f3202 --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Gateway_Worker.java @@ -0,0 +1,82 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.persistance.registry.jpa.model; + +import org.apache.openjpa.persistence.DataCache; + +import javax.persistence.*; +import java.io.Serializable; + +@DataCache +@Entity +@Table(name ="GATEWAY_WORKER") +@IdClass(Gateway_Worker_PK.class) +public class Gateway_Worker implements Serializable { + @Id + @Column(name = "GATEWAY_ID") + private String gateway_id; + + @Id + @Column(name = "USER_NAME") + private String user_name; + + @ManyToOne(cascade=CascadeType.MERGE) + @JoinColumn(name = "GATEWAY_ID") + private Gateway gateway; + + + @ManyToOne(cascade=CascadeType.MERGE) + @JoinColumn(name = "USER_NAME") + private Users user; + + public String getUser_name() { + return user_name; + } + + public void setUser_name(String user_name) { + this.user_name = user_name; + } + + public void setGateway(Gateway gateway) { + this.gateway = gateway; + } + + public Gateway getGateway() { + return gateway; + } + + public Users getUser() { + return user; + } + + public void setUser(Users user) { + this.user = user; + } + + public String getGateway_id() { + return gateway_id; + } + + public void setGateway_id(String gateway_id) { + this.gateway_id = gateway_id; + } +} + http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Gateway_Worker_PK.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Gateway_Worker_PK.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Gateway_Worker_PK.java new file mode 100644 index 0000000..b2a93a6 --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Gateway_Worker_PK.java @@ -0,0 +1,64 @@ +/* + * + * 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.persistance.registry.jpa.model; + +import java.io.Serializable; + +public class Gateway_Worker_PK implements Serializable { + private String gateway_id; + private String user_name; + + public Gateway_Worker_PK(String gateway_id, String user_name) { + this.gateway_id = gateway_id; + this.user_name = user_name; + } + + public Gateway_Worker_PK() { + ; + } + + @Override + public boolean equals(Object o) { + return false; + } + + @Override + public int hashCode() { + return 1; + } + + public String getUser_name() { + return user_name; + } + + public void setUser_name(String user_name) { + this.user_name = user_name; + } + + public String getGateway_id() { + return gateway_id; + } + + public void setGateway_id(String gateway_id) { + this.gateway_id = gateway_id; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/JobDetail.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/JobDetail.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/JobDetail.java new file mode 100644 index 0000000..36f12f8 --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/JobDetail.java @@ -0,0 +1,120 @@ +/* + * + * 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.persistance.registry.jpa.model; + +import org.apache.openjpa.persistence.DataCache; + +import javax.persistence.*; +import java.io.Serializable; +import java.sql.Timestamp; + +@DataCache +@Entity +@Table(name = "JOB_DETAIL") +@IdClass(JobDetails_PK.class) +public class JobDetail implements Serializable { + @Id + @Column(name = "JOB_ID") + private String jobId; + @Id + @Column(name = "TASK_ID") + private String taskId; + @Column(name = "JOB_DESCRIPTION") + @Lob + private char[] jobDescription; + @Column(name = "CREATION_TIME") + private Timestamp creationTime; + @Column(name = "COMPUTE_RESOURCE_CONSUMED") + private String computeResourceConsumed; + @Column(name = "JOBNAME") + private String jobName; + @Column(name = "WORKING_DIR") + private String workingDir; + + @ManyToOne(cascade= CascadeType.MERGE) + @JoinColumn(name = "TASK_ID") + private TaskDetail task; + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public char[] getJobDescription() { + return jobDescription; + } + + public void setJobDescription(char[] jobDescription) { + this.jobDescription = jobDescription; + } + + public Timestamp getCreationTime() { + return creationTime; + } + + public void setCreationTime(Timestamp creationTime) { + this.creationTime = creationTime; + } + + public TaskDetail getTask() { + return task; + } + + public void setTask(TaskDetail task) { + this.task = task; + } + + public String getComputeResourceConsumed() { + return computeResourceConsumed; + } + + public void setComputeResourceConsumed(String computeResourceConsumed) { + this.computeResourceConsumed = computeResourceConsumed; + } + + public String getJobName() { + return jobName; + } + + public void setJobName(String jobName) { + this.jobName = jobName; + } + + public String getWorkingDir() { + return workingDir; + } + + public void setWorkingDir(String workingDir) { + this.workingDir = workingDir; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/JobDetails_PK.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/JobDetails_PK.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/JobDetails_PK.java new file mode 100644 index 0000000..1247fb6 --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/JobDetails_PK.java @@ -0,0 +1,64 @@ +/* + * + * 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.persistance.registry.jpa.model; + +import java.io.Serializable; + +public class JobDetails_PK implements Serializable { + private String jobId; + private String taskId; + + public JobDetails_PK(String jobId, String taskId) { + this.jobId = jobId; + this.taskId = taskId; + } + + public JobDetails_PK() { + ; + } + + @Override + public boolean equals(Object o) { + return false; + } + + @Override + public int hashCode() { + return 1; + } + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/NodeInput.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/NodeInput.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/NodeInput.java new file mode 100644 index 0000000..7e48cbf --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/NodeInput.java @@ -0,0 +1,171 @@ +/* + * + * 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.persistance.registry.jpa.model; + +import org.apache.openjpa.persistence.DataCache; + +import javax.persistence.*; +import java.io.Serializable; + +@DataCache +@Entity +@Table(name = "NODE_INPUT") +@IdClass(NodeInput_PK.class) +public class NodeInput implements Serializable { + @Id + @Column(name = "NODE_INSTANCE_ID") + private String nodeId; + @Id + @Column(name = "INPUT_KEY") + private String inputKey; + @Column(name = "DATA_TYPE") + private String dataType; + @Column(name = "METADATA") + private String metadata; + @Column(name = "VALUE") + private String value; + @Column(name = "APP_ARGUMENT") + private String appArgument; + @Column(name = "INPUT_ORDER") + private int inputOrder; + + @Column(name = "STANDARD_INPUT") + private boolean standardInput; + + @Column(name = "USER_FRIENDLY_DESC") + private String userFriendlyDesc; + + @Column(name="IS_REQUIRED") + private boolean isRequired; + @Column(name="REQUIRED_TO_COMMANDLINE") + private boolean requiredToCMD; + @Column(name = "DATA_STAGED") + private boolean dataStaged; + + @ManyToOne(cascade= CascadeType.MERGE) + @JoinColumn(name = "NODE_INSTANCE_ID") + private WorkflowNodeDetail nodeDetails; + + 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 getMetadata() { + return metadata; + } + + public void setMetadata(String metadata) { + this.metadata = metadata; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getNodeId() { + return nodeId; + } + + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } + + public WorkflowNodeDetail getNodeDetails() { + return nodeDetails; + } + + public void setNodeDetails(WorkflowNodeDetail nodeDetails) { + this.nodeDetails = nodeDetails; + } + + public String getAppArgument() { + return appArgument; + } + + public void setAppArgument(String appArgument) { + this.appArgument = appArgument; + } + + public boolean isStandardInput() { + return standardInput; + } + + public void setStandardInput(boolean standardInput) { + this.standardInput = standardInput; + } + + public String getUserFriendlyDesc() { + return userFriendlyDesc; + } + + public void setUserFriendlyDesc(String userFriendlyDesc) { + this.userFriendlyDesc = userFriendlyDesc; + } + + public int getInputOrder() { + return inputOrder; + } + + public void setInputOrder(int inputOrder) { + this.inputOrder = inputOrder; + } + + public boolean getIsRequired() { + return isRequired; + } + + public void setIsRequired(boolean isRequired) { + this.isRequired = isRequired; + } + + 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; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/NodeInput_PK.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/NodeInput_PK.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/NodeInput_PK.java new file mode 100644 index 0000000..9db1cbe --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/NodeInput_PK.java @@ -0,0 +1,64 @@ +/* + * + * 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.persistance.registry.jpa.model; + +import java.io.Serializable; + +public class NodeInput_PK implements Serializable { + private String nodeId; + private String inputKey; + + public NodeInput_PK(String nodeId, String inputKey) { + this.nodeId = nodeId; + this.inputKey = inputKey; + } + + public NodeInput_PK() { + ; + } + + @Override + public boolean equals(Object o) { + return false; + } + + @Override + public int hashCode() { + return 1; + } + + public String getNodeId() { + return nodeId; + } + + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } + + public String getInputKey() { + return inputKey; + } + + public void setInputKey(String inputKey) { + this.inputKey = inputKey; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/NodeOutput.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/NodeOutput.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/NodeOutput.java new file mode 100644 index 0000000..9281ee8 --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/NodeOutput.java @@ -0,0 +1,148 @@ +/* + * + * 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.persistance.registry.jpa.model; + +import org.apache.openjpa.persistence.DataCache; + +import javax.persistence.*; +import java.io.Serializable; + +@DataCache +@Entity +@Table(name = "NODE_OUTPUT") +@IdClass(NodeOutput_PK.class) +public class NodeOutput implements Serializable { + @Id + @Column(name = "NODE_INSTANCE_ID") + private String nodeId; + @Id + @Column(name = "OUTPUT_KEY") + private String outputKey; + @Column(name = "DATA_TYPE") + private String dataType; + @Column(name = "VALUE") + private String value; + @Column(name = "IS_REQUIRED") + private boolean isRequired; + @Column(name="REQUIRED_TO_COMMANDLINE") + private boolean requiredToCMD; + @Column(name = "DATA_MOVEMENT") + private boolean dataMovement; + @Column(name = "DATA_NAME_LOCATION") + private String dataNameLocation; + @Column(name = "SEARCH_QUERY") + private String searchQuery; + @Column(name = "APP_ARGUMENT") + private String applicationArgument; + + @ManyToOne(cascade= CascadeType.MERGE) + @JoinColumn(name = "NODE_INSTANCE_ID") + private WorkflowNodeDetail node; + + public String getNodeId() { + return nodeId; + } + + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public WorkflowNodeDetail getNode() { + return node; + } + + public void setNode(WorkflowNodeDetail node) { + this.node = node; + } + + public String getOutputKey() { + return outputKey; + } + + public void setOutputKey(String outputKey) { + this.outputKey = outputKey; + } + + public String getDataType() { + return dataType; + } + + public void setDataType(String dataType) { + this.dataType = dataType; + } + + public boolean isRequired() { + return isRequired; + } + + public void setRequired(boolean isRequired) { + this.isRequired = isRequired; + } + + public boolean isRequiredToCMD() { + return requiredToCMD; + } + + public void setRequiredToCMD(boolean requiredToCMD) { + this.requiredToCMD = requiredToCMD; + } + + public boolean isDataMovement() { + return dataMovement; + } + + public void setDataMovement(boolean dataMovement) { + this.dataMovement = dataMovement; + } + + public String getDataNameLocation() { + return dataNameLocation; + } + + public void setDataNameLocation(String dataNameLocation) { + this.dataNameLocation = dataNameLocation; + } + + public String getSearchQuery() { + return searchQuery; + } + + public void setSearchQuery(String searchQuery) { + this.searchQuery = searchQuery; + } + + public String getApplicationArgument() { + return applicationArgument; + } + + public void setApplicationArgument(String applicationArgument) { + this.applicationArgument = applicationArgument; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/NodeOutput_PK.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/NodeOutput_PK.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/NodeOutput_PK.java new file mode 100644 index 0000000..84fded8 --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/NodeOutput_PK.java @@ -0,0 +1,64 @@ +/* + * + * 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.persistance.registry.jpa.model; + +import java.io.Serializable; + +public class NodeOutput_PK implements Serializable { + private String nodeId; + private String outputKey; + + public NodeOutput_PK(String nodeId, String outputKey) { + this.nodeId = nodeId; + this.outputKey = outputKey; + } + + public NodeOutput_PK() { + ; + } + + @Override + public boolean equals(Object o) { + return false; + } + + @Override + public int hashCode() { + return 1; + } + + public String getNodeId() { + return nodeId; + } + + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } + + public String getOutputKey() { + return outputKey; + } + + public void setOutputKey(String outputKey) { + this.outputKey = outputKey; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Notification_Email.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Notification_Email.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Notification_Email.java new file mode 100644 index 0000000..524994e --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Notification_Email.java @@ -0,0 +1,97 @@ +/* + * + * 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.persistance.registry.jpa.model; + +import org.apache.openjpa.persistence.DataCache; + +import javax.persistence.*; +import java.io.Serializable; + +@DataCache +@Entity +@Table(name ="NOTIFICATION_EMAIL") +public class Notification_Email implements Serializable { + @Id + @GeneratedValue + private int emailId; + @Column(name = "EXPERIMENT_ID") + private String experiment_id; + @Column(name = "TASK_ID") + private String taskId; + @Column(name = "EMAIL_ADDRESS") + private String emailAddress; + + @ManyToOne + @JoinColumn(name = "EXPERIMENT_ID") + private Experiment experiment; + @ManyToOne + @JoinColumn(name = "TASK_ID") + private TaskDetail taskDetail; + + public String getExperiment_id() { + return experiment_id; + } + + public void setExperiment_id(String experiment_id) { + this.experiment_id = experiment_id; + } + + public Experiment getExperiment() { + return experiment; + } + + public void setExperiment(Experiment experiment) { + this.experiment = experiment; + } + + public String getEmailAddress() { + return emailAddress; + } + + public void setEmailAddress(String emailAddress) { + this.emailAddress = emailAddress; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public TaskDetail getTaskDetail() { + return taskDetail; + } + + public void setTaskDetail(TaskDetail taskDetail) { + this.taskDetail = taskDetail; + } + + public int getEmailId() { + return emailId; + } + + public void setEmailId(int emailId) { + this.emailId = emailId; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Project.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Project.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Project.java new file mode 100644 index 0000000..054411d --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Project.java @@ -0,0 +1,125 @@ +/* + * + * 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.persistance.registry.jpa.model; + +import org.apache.openjpa.persistence.DataCache; + +import javax.persistence.*; +import java.io.Serializable; +import java.sql.Timestamp; + +@DataCache +@Entity +@Table(name ="PROJECT") +public class Project implements Serializable { + @Id + @Column(name = "PROJECT_ID") + private String project_id; + + @Column(name = "GATEWAY_ID") + private String gateway_id; + + @Column(name = "PROJECT_NAME") + private String project_name; + + @Column(name = "DESCRIPTION") + private String description; + + @Column(name = "USER_NAME") + private String user_name; + + @Column(name = "CREATION_TIME") + private Timestamp creationTime; + + @ManyToOne(cascade=CascadeType.MERGE) + @JoinColumn(name = "GATEWAY_ID") + private Gateway gateway; + + @ManyToOne(cascade=CascadeType.MERGE) + @JoinColumn(name = "USER_NAME") + private Users users; + + + public String getProject_name() { + return project_name; + } + + public Gateway getGateway() { + return gateway; + } + + public void setProject_name(String project_name) { + this.project_name = project_name; + } + + public void setGateway(Gateway gateway) { + this.gateway = gateway; + } + + public Users getUsers() { + return users; + } + + public void setUsers(Users users) { + this.users = users; + } + + 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; + } + + public void setProject_id(String project_id) { + this.project_id = project_id; + } + + public String getProject_id() { + return project_id; + } + + public String getUser_name() { + return user_name; + } + + public void setUser_name(String user_name) { + this.user_name = user_name; + } + + public String getGateway_id() { + return gateway_id; + } + + public void setGateway_id(String gateway_id) { + this.gateway_id = gateway_id; + } +} + http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/ProjectUser.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/ProjectUser.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/ProjectUser.java new file mode 100644 index 0000000..5b930d1 --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/ProjectUser.java @@ -0,0 +1,81 @@ +/* + * + * 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.persistance.registry.jpa.model; + + +import org.apache.openjpa.persistence.DataCache; + +import javax.persistence.*; +import java.io.Serializable; + +@DataCache +@Entity +@IdClass(ProjectUser_PK.class) +@Table(name = "PROJECT_USER") +public class ProjectUser implements Serializable { + @Id + @Column(name = "PROJECT_ID") + private String projectID; + @Id + @Column(name = "USER_NAME") + private String userName; + + @ManyToOne(cascade=CascadeType.MERGE) + @JoinColumn(name = "PROJECT_ID") + private Project project; + + @ManyToOne(cascade=CascadeType.MERGE) + @JoinColumn(name = "USER_NAME") + private Users user; + + public String getProjectId() { + return projectID; + } + + public void setProjectId(String projectID) { + this.projectID = projectID; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public Project getProject() { + return project; + } + + public void setProject(Project project) { + this.project = project; + } + + public Users getUser() { + return user; + } + + public void setUser(Users user) { + this.user = user; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/ProjectUser_PK.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/ProjectUser_PK.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/ProjectUser_PK.java new file mode 100644 index 0000000..e3eff9c --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/ProjectUser_PK.java @@ -0,0 +1,64 @@ +/* + * + * 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.persistance.registry.jpa.model; + +import java.io.Serializable; + +public class ProjectUser_PK implements Serializable { + private String projectID; + private String userName; + + public ProjectUser_PK(String projectID, String userName) { + this.projectID = projectID; + this.userName = userName; + } + + public ProjectUser_PK() { + ; + } + + @Override + public boolean equals(Object o) { + return false; + } + + @Override + public int hashCode() { + return 1; + } + + public String getProjectId() { + return projectID; + } + + public void setProjectId(String projectID) { + this.projectID = projectID; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/QosParam.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/QosParam.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/QosParam.java new file mode 100644 index 0000000..a0dbfa0 --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/QosParam.java @@ -0,0 +1,119 @@ +/* + * + * 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.persistance.registry.jpa.model; + +import org.apache.openjpa.persistence.DataCache; + +import javax.persistence.*; +import java.io.Serializable; + +@DataCache +@Entity +@Table(name = "QOS_PARAMS") +public class QosParam implements Serializable { + @Id + @GeneratedValue + @Column(name = "QOS_ID") + private int qosId; + @Column(name = "EXPERIMENT_ID") + private String expId; + @Column(name = "TASK_ID") + private String taskId; + @Column(name = "START_EXECUTION_AT") + private String startExecutionAt; + @Column(name = "EXECUTE_BEFORE") + private String executeBefore; + @Column(name = "NO_OF_RETRIES") + private int noOfRetries; + + @ManyToOne(cascade= CascadeType.MERGE) + @JoinColumn(name = "EXPERIMENT_ID") + private Experiment experiment; + + @ManyToOne(cascade= CascadeType.MERGE) + @JoinColumn(name = "TASK_ID") + private TaskDetail task; + + public int getQosId() { + return qosId; + } + + public void setQosId(int qosId) { + this.qosId = qosId; + } + + public String getExpId() { + return expId; + } + + public void setExpId(String expId) { + this.expId = expId; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getStartExecutionAt() { + return startExecutionAt; + } + + public void setStartExecutionAt(String startExecutionAt) { + this.startExecutionAt = startExecutionAt; + } + + public String getExecuteBefore() { + return executeBefore; + } + + public void setExecuteBefore(String executeBefore) { + this.executeBefore = executeBefore; + } + + public int getNoOfRetries() { + return noOfRetries; + } + + public void setNoOfRetries(int noOfRetries) { + this.noOfRetries = noOfRetries; + } + + public Experiment getExperiment() { + return experiment; + } + + public void setExperiment(Experiment experiment) { + this.experiment = experiment; + } + + public TaskDetail getTask() { + return task; + } + + public void setTask(TaskDetail task) { + this.task = task; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Status.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Status.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Status.java new file mode 100644 index 0000000..4783af5 --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Status.java @@ -0,0 +1,174 @@ +/* + * + * 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.persistance.registry.jpa.model; + +import org.apache.openjpa.persistence.DataCache; + +import javax.persistence.*; +import java.io.Serializable; +import java.sql.Timestamp; + +@DataCache +@Entity +@Table(name = "STATUS") +public class Status implements Serializable { + @Id + @GeneratedValue + @Column(name = "STATUS_ID") + private int statusId; + @Column(name = "EXPERIMENT_ID") + private String expId; + @Column(name = "NODE_INSTANCE_ID") + private String nodeId; + @Column(name = "TRANSFER_ID") + private String transferId; + @Column(name = "TASK_ID") + private String taskId; + @Column(name = "JOB_ID") + private String jobId; + @Column(name = "STATE") + private String state; + @Column(name = "STATUS_UPDATE_TIME") + private Timestamp statusUpdateTime; + @Column(name = "STATUS_TYPE") + private String statusType; + + @ManyToOne(cascade= CascadeType.MERGE) + @JoinColumn(name = "EXPERIMENT_ID") + private Experiment experiment; + + @ManyToOne(cascade= CascadeType.MERGE) + @JoinColumn(name = "TASK_ID") + private TaskDetail task; + + @ManyToOne(cascade= CascadeType.MERGE) + @JoinColumn(name = "NODE_INSTANCE_ID") + private WorkflowNodeDetail node; + + @ManyToOne(cascade= CascadeType.MERGE) + @JoinColumn(name = "TRANSFER_ID") + private DataTransferDetail transferDetail; + + public int getStatusId() { + return statusId; + } + + public void setStatusId(int statusId) { + this.statusId = statusId; + } + + public String getExpId() { + return expId; + } + + public void setExpId(String expId) { + this.expId = expId; + } + + public String getNodeId() { + return nodeId; + } + + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } + + public String getTransferId() { + return transferId; + } + + public void setTransferId(String transferId) { + this.transferId = transferId; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public Timestamp getStatusUpdateTime() { + return statusUpdateTime; + } + + public void setStatusUpdateTime(Timestamp statusUpdateTime) { + this.statusUpdateTime = statusUpdateTime; + } + + public String getStatusType() { + return statusType; + } + + public void setStatusType(String statusType) { + this.statusType = statusType; + } + + public Experiment getExperiment() { + return experiment; + } + + public void setExperiment(Experiment experiment) { + this.experiment = experiment; + } + + public TaskDetail getTask() { + return task; + } + + public void setTask(TaskDetail task) { + this.task = task; + } + + public WorkflowNodeDetail getNode() { + return node; + } + + public void setNode(WorkflowNodeDetail node) { + this.node = node; + } + + public DataTransferDetail getTransferDetail() { + return transferDetail; + } + + public void setTransferDetail(DataTransferDetail transferDetail) { + this.transferDetail = transferDetail; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/TaskDetail.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/TaskDetail.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/TaskDetail.java new file mode 100644 index 0000000..ebd7758 --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/TaskDetail.java @@ -0,0 +1,119 @@ +/* + * + * 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.persistance.registry.jpa.model; + +import org.apache.openjpa.persistence.DataCache; + +import javax.persistence.*; + +import java.io.Serializable; +import java.sql.Timestamp; + +@DataCache +@Entity +@Table(name = "TASK_DETAIL") +public class TaskDetail implements Serializable { + @Id + @Column(name = "TASK_ID") + private String taskId; + @Column(name = "NODE_INSTANCE_ID") + private String nodeId; + @Column(name = "CREATION_TIME") + private Timestamp creationTime; + @Column(name = "APPLICATION_ID") + private String appId; + @Column(name = "APPLICATION_VERSION") + private String appVersion; + @Column(name = "ALLOW_NOTIFICATION") + private boolean allowNotification; + + @Column(name = "APPLICATION_DEPLOYMENT_ID") + private String applicationDeploymentId; + + @ManyToOne(cascade= CascadeType.MERGE) + @JoinColumn(name = "NODE_INSTANCE_ID") + private WorkflowNodeDetail nodeDetail; + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getNodeId() { + return nodeId; + } + + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } + + public Timestamp getCreationTime() { + return creationTime; + } + + public void setCreationTime(Timestamp creationTime) { + this.creationTime = creationTime; + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getAppVersion() { + return appVersion; + } + + public void setAppVersion(String appVersion) { + this.appVersion = appVersion; + } + + public WorkflowNodeDetail getNodeDetail() { + return nodeDetail; + } + + public void setNodeDetail(WorkflowNodeDetail nodeDetail) { + this.nodeDetail = nodeDetail; + } + + public String getApplicationDeploymentId() { + return applicationDeploymentId; + } + + public void setApplicationDeploymentId(String applicationDeploymentId) { + this.applicationDeploymentId = applicationDeploymentId; + } + + public boolean isAllowNotification() { + return allowNotification; + } + + public void setAllowNotification(boolean allowNotification) { + this.allowNotification = allowNotification; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Users.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Users.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Users.java new file mode 100644 index 0000000..9005985 --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Users.java @@ -0,0 +1,55 @@ +/* + * + * 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.persistance.registry.jpa.model; + +import org.apache.openjpa.persistence.DataCache; + +import javax.persistence.*; +import java.io.Serializable; + +@DataCache +@Entity +@Table(name ="USERS") +public class Users implements Serializable { + + @Id + @Column(name = "USER_NAME") + private String user_name; + @Column(name = "PASSWORD") + private String password; + + + public String getUser_name() { + return user_name; + } + + public void setUser_name(String user_name) { + this.user_name = user_name; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/WorkflowNodeDetail.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/WorkflowNodeDetail.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/WorkflowNodeDetail.java new file mode 100644 index 0000000..b4ae29e --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/WorkflowNodeDetail.java @@ -0,0 +1,107 @@ +/* + * + * 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.persistance.registry.jpa.model; + +import org.apache.openjpa.persistence.DataCache; + +import javax.persistence.*; +import java.io.Serializable; +import java.sql.Timestamp; + +@DataCache +@Entity +@Table(name = "WORKFLOW_NODE_DETAIL") +public class WorkflowNodeDetail implements Serializable { + @Column(name = "EXPERIMENT_ID") + private String expId; + @Id + @Column(name = "NODE_INSTANCE_ID") + private String nodeId; + @Column(name = "EXECUTION_UNIT") + private String executionUnit; + @Column(name = "EXECUTION_UNIT_DATA") + private String executionUnitData; + @Column(name = "CREATION_TIME") + private Timestamp creationTime; + @Column(name = "NODE_NAME") + private String nodeName; + + @ManyToOne(cascade= CascadeType.MERGE) + @JoinColumn(name = "EXPERIMENT_ID") + private Experiment experiment; + + public String getExpId() { + return expId; + } + + public void setExpId(String expId) { + this.expId = expId; + } + + public String getNodeId() { + return nodeId; + } + + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } + + public Timestamp getCreationTime() { + return creationTime; + } + + public void setCreationTime(Timestamp creationTime) { + this.creationTime = creationTime; + } + + public String getNodeName() { + return nodeName; + } + + public void setNodeName(String nodeName) { + this.nodeName = nodeName; + } + + public Experiment getExperiment() { + return experiment; + } + + public void setExperiment(Experiment experiment) { + this.experiment = experiment; + } + + public String getExecutionUnitData() { + return executionUnitData; + } + + public void setExecutionUnitData(String executionUnitData) { + this.executionUnitData = executionUnitData; + } + + public String getExecutionUnit() { + return executionUnit; + } + + public void setExecutionUnit(String executionUnit) { + this.executionUnit = executionUnit; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/ExperimentRegistry.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/ExperimentRegistry.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/ExperimentRegistry.java new file mode 100644 index 0000000..515218d --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/ExperimentRegistry.java @@ -0,0 +1,28 @@ +/* + * + * 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.persistance.registry.jpa.mongo; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ExperimentRegistry { + private final static Logger logger = LoggerFactory.getLogger(ExperimentRegistry.class); +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/Test.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/Test.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/Test.java new file mode 100644 index 0000000..4f0dcca --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/Test.java @@ -0,0 +1,81 @@ +/* + * + * 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.persistance.registry.jpa.mongo; + +import org.apache.airavata.common.utils.AiravataUtils; +import org.apache.airavata.model.workspace.experiment.Experiment; +import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory; +import org.apache.airavata.persistance.registry.jpa.mongo.dao.ExperimentDao; +import org.apache.airavata.persistance.registry.jpa.mongo.utils.MongoUtil; +import org.apache.airavata.registry.cpi.Registry; +import org.apache.airavata.registry.cpi.RegistryException; +import org.apache.airavata.registry.cpi.RegistryModelType; +import org.junit.Assert; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; + +public class Test { + private final static Logger logger = LoggerFactory.getLogger(Test.class); + + public static void main(String[] args) throws RegistryException, IOException { + AiravataUtils.setExecutionAsServer(); + Registry registry = RegistryFactory.getDefaultRegistry(); +// String experiemtnId = "SLM-Espresso-Stampede_45667ea8-aae3-4a8e-807d-a16312035c35"; +// long time1 = System.currentTimeMillis(); +// Experiment experiement = (Experiment) registry.getExperiment(RegistryModelType.EXPERIMENT, experiemtnId); +// long time2 = System.currentTimeMillis(); +// System.out.println(time2-time1); +// +// ExperimentDao experimentDao = new ExperimentDao(); +// experimentDao.createExperiment(experiement); +// time1 = System.currentTimeMillis(); +// Experiment persistedExperiment = experimentDao.getExperiment(experiement.getExperimentId()); +// time2 = System.currentTimeMillis(); +// System.out.println(time2-time1); +// +// Assert.assertEquals(experiement, persistedExperiment); + + MongoUtil.dropAiravataRegistry(); + + ExperimentDao experimentDao = new ExperimentDao(); + BufferedReader reader = new BufferedReader(new FileReader("/home/supun/Downloads/EXPERIMENT.csv")); + String temp = reader.readLine(); + int i = 1; + while(temp != null && !temp.isEmpty()){ + try{ + Experiment experiement = (Experiment) registry.get(RegistryModelType.EXPERIMENT, temp.trim()); + experimentDao.createExperiment(experiement); + Experiment persistedExperiment = experimentDao.getExperiment(experiement.getExperimentId()); + Assert.assertEquals(experiement, persistedExperiment); + System.out.println(i+" :"+experiement.getExperimentId()); + i++; + }catch (Exception e){ + System.out.println(temp); + e.printStackTrace(); + } + temp = reader.readLine(); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/conversion/AbstractThriftDeserializer.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/conversion/AbstractThriftDeserializer.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/conversion/AbstractThriftDeserializer.java new file mode 100644 index 0000000..ba597ee --- /dev/null +++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/conversion/AbstractThriftDeserializer.java @@ -0,0 +1,152 @@ +/* + * + * 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.persistance.registry.jpa.mongo.conversion; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.node.JsonNodeType; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fasterxml.jackson.databind.type.TypeFactory; +import com.google.common.base.CaseFormat; +import org.apache.thrift.TBase; +import org.apache.thrift.TException; +import org.apache.thrift.TFieldIdEnum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.ParameterizedType; +import java.util.Iterator; +import java.util.Map; + +/** + * This abstract class represents a generic de-serializer for converting JSON to Thrift-based entities. + * + * @param <E> An implementation of the {@link org.apache.thrift.TFieldIdEnum} interface. + * @param <T> An implementation of the {@link org.apache.thrift.TBase} interface. + */ +public abstract class AbstractThriftDeserializer<E extends TFieldIdEnum, T extends TBase<T, E>> extends JsonDeserializer<T> { + + private static Logger log = LoggerFactory.getLogger(AbstractThriftDeserializer.class); + + @Override + public T deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { + final T instance = newInstance(); + final ObjectMapper mapper = (ObjectMapper)jp.getCodec(); + final ObjectNode rootNode = (ObjectNode)mapper.readTree(jp); + final Iterator<Map.Entry<String, JsonNode>> iterator = rootNode.fields(); + + while(iterator.hasNext()) { + final Map.Entry<String, JsonNode> currentField = iterator.next(); + try { + /* + * If the current node is not a null value, process it. Otherwise, + * skip it. Jackson will treat the null as a 0 for primitive + * number types, which in turn will make Thrift think the field + * has been set. Also we ignore the MongoDB specific _id field + */ + if(!currentField.getKey().equalsIgnoreCase("_id") + && currentField.getValue().getNodeType() != JsonNodeType.NULL) { + final E field = getField(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_UNDERSCORE, currentField.getKey())); + final JsonParser parser = currentField.getValue().traverse(); + parser.setCodec(mapper); + final Object value = mapper.readValue(parser, generateValueType(instance, field)); + if(value != null) { + log.debug(String.format("Field %s produced value %s of type %s.", + currentField.getKey(), value, value.getClass().getName())); + instance.setFieldValue(field, value); + } else { + log.debug("Field {} contains a null value. Skipping...", currentField.getKey()); + } + } else { + log.debug("Field {} contains a null value. Skipping...", currentField.getKey()); + } + } catch (final NoSuchFieldException | IllegalArgumentException e) { + log.error("Unable to de-serialize field '{}'.", currentField.getKey(), e); + ctxt.mappingException(e.getMessage()); + } + } + + try { + // Validate that the instance contains all required fields. + validate(instance); + } catch (final TException e) { + log.error(String.format("Unable to deserialize JSON '%s' to type '%s'.", + jp.getValueAsString(), instance.getClass().getName(), e)); + ctxt.mappingException(e.getMessage()); + } + + return instance; + } + + /** + * Returns the {@code <E>} enumerated value that represents the target + * field in the Thrift entity referenced in the JSON document. + * @param fieldName The name of the Thrift entity target field. + * @return The {@code <E>} enumerated value that represents the target + * field in the Thrift entity referenced in the JSON document. + */ + protected abstract E getField(String fieldName); + + /** + * Creates a new instance of the Thrift entity class represented by this deserializer. + * @return A new instance of the Thrift entity class represented by this deserializer. + */ + protected abstract T newInstance(); + + /** + * Validates that the Thrift entity instance contains all required fields after deserialization. + * @param instance A Thrift entity instance. + * @throws org.apache.thrift.TException if unable to validate the instance. + */ + protected abstract void validate(T instance) throws TException; + + /** + * Generates a {@link JavaType} that matches the target Thrift field represented by the provided + * {@code <E>} enumerated value. If the field's type includes generics, the generics will + * be added to the generated {@link JavaType} to support proper conversion. + * @param thriftInstance The Thrift-generated class instance that will be converted to/from JSON. + * @param field A {@code <E>} enumerated value that represents a field in a Thrift-based entity. + * @return The {@link JavaType} representation of the type associated with the field. + * @throws NoSuchFieldException if unable to determine the field's type. + * @throws SecurityException if unable to determine the field's type. + */ + protected JavaType generateValueType(final T thriftInstance, final E field) throws NoSuchFieldException, SecurityException { + final TypeFactory typeFactory = TypeFactory.defaultInstance(); + + final Field declaredField = thriftInstance.getClass().getDeclaredField(field.getFieldName()); + if(declaredField.getType().equals(declaredField.getGenericType())) { + log.debug("Generating JavaType for type '{}'.", declaredField.getType()); + return typeFactory.constructType(declaredField.getType()); + } else { + final ParameterizedType type = (ParameterizedType)declaredField.getGenericType(); + final Class<?>[] parameterizedTypes = new Class<?>[type.getActualTypeArguments().length]; + for(int i=0; i<type.getActualTypeArguments().length; i++) { + parameterizedTypes[i] = (Class<?>)type.getActualTypeArguments()[i]; + } + log.debug("Generating JavaType for type '{}' with generics '{}'", declaredField.getType(), parameterizedTypes); + return typeFactory.constructParametricType(declaredField.getType(), parameterizedTypes); + } + } + +} \ No newline at end of file
