adding workflow related data models
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/dbb1c97a Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/dbb1c97a Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/dbb1c97a Branch: refs/heads/master Commit: dbb1c97a11d806c2c726b0bfb1ed04b0a24c22bb Parents: 60de539 Author: Chathuri Wimalasena <[email protected]> Authored: Mon Oct 6 11:16:50 2014 -0400 Committer: Chathuri Wimalasena <[email protected]> Committed: Mon Oct 6 11:16:50 2014 -0400 ---------------------------------------------------------------------- .../lib/airavata/workflowDataModel_types.cpp | 86 +++- .../lib/airavata/workflowDataModel_types.h | 42 +- .../main/resources/lib/Airavata/Model/Types.php | 116 +++++ .../org/apache/airavata/model/Workflow.java | 429 ++++++++++++++++++- .../workflowDataModel.thrift | 6 +- .../catalog/data/impl/WorkflowCatalogImpl.java | 78 +++- .../catalog/data/model/Workflow.java | 13 + .../catalog/data/model/WorkflowInput.java | 127 ++++++ .../catalog/data/model/WorkflowInput_PK.java | 64 +++ .../catalog/data/model/WorkflowOutput.java | 87 ++++ .../catalog/data/model/WorkflowOutput_PK.java | 64 +++ .../data/resources/AbstractResource.java | 20 + .../data/resources/WorkflowInputResource.java | 412 ++++++++++++++++++ .../data/resources/WorkflowOutputResource.java | 377 ++++++++++++++++ .../data/resources/WorkflowResource.java | 12 + .../catalog/data/util/AppCatalogJPAUtils.java | 62 ++- .../data/util/AppCatalogResourceType.java | 4 +- .../data/util/AppCatalogThriftConversion.java | 50 ++- .../src/main/resources/META-INF/persistence.xml | 2 + .../src/main/resources/appcatalog-derby.sql | 25 ++ .../src/main/resources/appcatalog-mysql.sql | 27 +- 21 files changed, 2066 insertions(+), 37 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/dbb1c97a/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/airavata/workflowDataModel_types.cpp ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/airavata/workflowDataModel_types.cpp b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/airavata/workflowDataModel_types.cpp index 6608d3f..53f0b70 100644 --- a/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/airavata/workflowDataModel_types.cpp +++ b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/airavata/workflowDataModel_types.cpp @@ -27,8 +27,8 @@ -const char* Workflow::ascii_fingerprint = "F4A50F0EC638C7F66026F9B6678FD89B"; -const uint8_t Workflow::binary_fingerprint[16] = {0xF4,0xA5,0x0F,0x0E,0xC6,0x38,0xC7,0xF6,0x60,0x26,0xF9,0xB6,0x67,0x8F,0xD8,0x9B}; +const char* Workflow::ascii_fingerprint = "0F4DE03295CE4C20055DE0E68CFA7A65"; +const uint8_t Workflow::binary_fingerprint[16] = {0x0F,0x4D,0xE0,0x32,0x95,0xCE,0x4C,0x20,0x05,0x5D,0xE0,0xE6,0x8C,0xFA,0x7A,0x65}; uint32_t Workflow::read(::apache::thrift::protocol::TProtocol* iprot) { @@ -76,6 +76,54 @@ uint32_t Workflow::read(::apache::thrift::protocol::TProtocol* iprot) { xfer += iprot->skip(ftype); } break; + case 4: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readBinary(this->image); + this->__isset.image = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 5: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->workflowInputs.clear(); + uint32_t _size0; + ::apache::thrift::protocol::TType _etype3; + xfer += iprot->readListBegin(_etype3, _size0); + this->workflowInputs.resize(_size0); + uint32_t _i4; + for (_i4 = 0; _i4 < _size0; ++_i4) + { + xfer += this->workflowInputs[_i4].read(iprot); + } + xfer += iprot->readListEnd(); + } + this->__isset.workflowInputs = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 6: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->workflowOutputs.clear(); + uint32_t _size5; + ::apache::thrift::protocol::TType _etype8; + xfer += iprot->readListBegin(_etype8, _size5); + this->workflowOutputs.resize(_size5); + uint32_t _i9; + for (_i9 = 0; _i9 < _size5; ++_i9) + { + xfer += this->workflowOutputs[_i9].read(iprot); + } + xfer += iprot->readListEnd(); + } + this->__isset.workflowOutputs = true; + } else { + xfer += iprot->skip(ftype); + } + break; default: xfer += iprot->skip(ftype); break; @@ -109,6 +157,37 @@ uint32_t Workflow::write(::apache::thrift::protocol::TProtocol* oprot) const { xfer += oprot->writeString(this->graph); xfer += oprot->writeFieldEnd(); } + if (this->__isset.image) { + xfer += oprot->writeFieldBegin("image", ::apache::thrift::protocol::T_STRING, 4); + xfer += oprot->writeBinary(this->image); + xfer += oprot->writeFieldEnd(); + } + if (this->__isset.workflowInputs) { + xfer += oprot->writeFieldBegin("workflowInputs", ::apache::thrift::protocol::T_LIST, 5); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->workflowInputs.size())); + std::vector< ::apache::airavata::model::appcatalog::appinterface::InputDataObjectType> ::const_iterator _iter10; + for (_iter10 = this->workflowInputs.begin(); _iter10 != this->workflowInputs.end(); ++_iter10) + { + xfer += (*_iter10).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + } + if (this->__isset.workflowOutputs) { + xfer += oprot->writeFieldBegin("workflowOutputs", ::apache::thrift::protocol::T_LIST, 6); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->workflowOutputs.size())); + std::vector< ::apache::airavata::model::appcatalog::appinterface::OutputDataObjectType> ::const_iterator _iter11; + for (_iter11 = this->workflowOutputs.begin(); _iter11 != this->workflowOutputs.end(); ++_iter11) + { + xfer += (*_iter11).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + } xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; @@ -119,6 +198,9 @@ void swap(Workflow &a, Workflow &b) { swap(a.templateId, b.templateId); swap(a.name, b.name); swap(a.graph, b.graph); + swap(a.image, b.image); + swap(a.workflowInputs, b.workflowInputs); + swap(a.workflowOutputs, b.workflowOutputs); swap(a.__isset, b.__isset); } http://git-wip-us.apache.org/repos/asf/airavata/blob/dbb1c97a/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/airavata/workflowDataModel_types.h ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/airavata/workflowDataModel_types.h b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/airavata/workflowDataModel_types.h index e89e6e9..d688702 100644 --- a/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/airavata/workflowDataModel_types.h +++ b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/airavata/workflowDataModel_types.h @@ -30,22 +30,26 @@ #include <thrift/transport/TTransport.h> #include <thrift/cxxfunctional.h> +#include "applicationInterfaceModel_types.h" typedef struct _Workflow__isset { - _Workflow__isset() : graph(false) {} + _Workflow__isset() : graph(false), image(false), workflowInputs(false), workflowOutputs(false) {} bool graph; + bool image; + bool workflowInputs; + bool workflowOutputs; } _Workflow__isset; class Workflow { public: - static const char* ascii_fingerprint; // = "F4A50F0EC638C7F66026F9B6678FD89B"; - static const uint8_t binary_fingerprint[16]; // = {0xF4,0xA5,0x0F,0x0E,0xC6,0x38,0xC7,0xF6,0x60,0x26,0xF9,0xB6,0x67,0x8F,0xD8,0x9B}; + static const char* ascii_fingerprint; // = "0F4DE03295CE4C20055DE0E68CFA7A65"; + static const uint8_t binary_fingerprint[16]; // = {0x0F,0x4D,0xE0,0x32,0x95,0xCE,0x4C,0x20,0x05,0x5D,0xE0,0xE6,0x8C,0xFA,0x7A,0x65}; - Workflow() : templateId("DO_NOT_SET_AT_CLIENTS"), name(), graph() { + Workflow() : templateId("DO_NOT_SET_AT_CLIENTS"), name(), graph(), image() { } virtual ~Workflow() throw() {} @@ -53,6 +57,9 @@ class Workflow { std::string templateId; std::string name; std::string graph; + std::string image; + std::vector< ::apache::airavata::model::appcatalog::appinterface::InputDataObjectType> workflowInputs; + std::vector< ::apache::airavata::model::appcatalog::appinterface::OutputDataObjectType> workflowOutputs; _Workflow__isset __isset; @@ -69,6 +76,21 @@ class Workflow { __isset.graph = true; } + void __set_image(const std::string& val) { + image = val; + __isset.image = true; + } + + void __set_workflowInputs(const std::vector< ::apache::airavata::model::appcatalog::appinterface::InputDataObjectType> & val) { + workflowInputs = val; + __isset.workflowInputs = true; + } + + void __set_workflowOutputs(const std::vector< ::apache::airavata::model::appcatalog::appinterface::OutputDataObjectType> & val) { + workflowOutputs = val; + __isset.workflowOutputs = true; + } + bool operator == (const Workflow & rhs) const { if (!(templateId == rhs.templateId)) @@ -79,6 +101,18 @@ class Workflow { return false; else if (__isset.graph && !(graph == rhs.graph)) return false; + if (__isset.image != rhs.__isset.image) + return false; + else if (__isset.image && !(image == rhs.image)) + return false; + if (__isset.workflowInputs != rhs.__isset.workflowInputs) + return false; + else if (__isset.workflowInputs && !(workflowInputs == rhs.workflowInputs)) + return false; + if (__isset.workflowOutputs != rhs.__isset.workflowOutputs) + return false; + else if (__isset.workflowOutputs && !(workflowOutputs == rhs.workflowOutputs)) + return false; return true; } bool operator != (const Workflow &rhs) const { http://git-wip-us.apache.org/repos/asf/airavata/blob/dbb1c97a/airavata-api/airavata-client-sdks/airavata-php-sdk/src/main/resources/lib/Airavata/Model/Types.php ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-client-sdks/airavata-php-sdk/src/main/resources/lib/Airavata/Model/Types.php b/airavata-api/airavata-client-sdks/airavata-php-sdk/src/main/resources/lib/Airavata/Model/Types.php index f3ff86d..4e89132 100644 --- a/airavata-api/airavata-client-sdks/airavata-php-sdk/src/main/resources/lib/Airavata/Model/Types.php +++ b/airavata-api/airavata-client-sdks/airavata-php-sdk/src/main/resources/lib/Airavata/Model/Types.php @@ -23,6 +23,9 @@ class Workflow { public $templateId = "DO_NOT_SET_AT_CLIENTS"; public $name = null; public $graph = null; + public $image = null; + public $workflowInputs = null; + public $workflowOutputs = null; public function __construct($vals=null) { if (!isset(self::$_TSPEC)) { @@ -39,6 +42,28 @@ class Workflow { 'var' => 'graph', 'type' => TType::STRING, ), + 4 => array( + 'var' => 'image', + 'type' => TType::STRING, + ), + 5 => array( + 'var' => 'workflowInputs', + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\Airavata\Model\AppCatalog\AppInterface\InputDataObjectType', + ), + ), + 6 => array( + 'var' => 'workflowOutputs', + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\Airavata\Model\AppCatalog\AppInterface\OutputDataObjectType', + ), + ), ); } if (is_array($vals)) { @@ -51,6 +76,15 @@ class Workflow { if (isset($vals['graph'])) { $this->graph = $vals['graph']; } + if (isset($vals['image'])) { + $this->image = $vals['image']; + } + if (isset($vals['workflowInputs'])) { + $this->workflowInputs = $vals['workflowInputs']; + } + if (isset($vals['workflowOutputs'])) { + $this->workflowOutputs = $vals['workflowOutputs']; + } } } @@ -94,6 +128,49 @@ class Workflow { $xfer += $input->skip($ftype); } break; + case 4: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->image); + } else { + $xfer += $input->skip($ftype); + } + break; + case 5: + if ($ftype == TType::LST) { + $this->workflowInputs = array(); + $_size0 = 0; + $_etype3 = 0; + $xfer += $input->readListBegin($_etype3, $_size0); + for ($_i4 = 0; $_i4 < $_size0; ++$_i4) + { + $elem5 = null; + $elem5 = new \Airavata\Model\AppCatalog\AppInterface\InputDataObjectType(); + $xfer += $elem5->read($input); + $this->workflowInputs []= $elem5; + } + $xfer += $input->readListEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; + case 6: + if ($ftype == TType::LST) { + $this->workflowOutputs = array(); + $_size6 = 0; + $_etype9 = 0; + $xfer += $input->readListBegin($_etype9, $_size6); + for ($_i10 = 0; $_i10 < $_size6; ++$_i10) + { + $elem11 = null; + $elem11 = new \Airavata\Model\AppCatalog\AppInterface\OutputDataObjectType(); + $xfer += $elem11->read($input); + $this->workflowOutputs []= $elem11; + } + $xfer += $input->readListEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; default: $xfer += $input->skip($ftype); break; @@ -122,6 +199,45 @@ class Workflow { $xfer += $output->writeString($this->graph); $xfer += $output->writeFieldEnd(); } + if ($this->image !== null) { + $xfer += $output->writeFieldBegin('image', TType::STRING, 4); + $xfer += $output->writeString($this->image); + $xfer += $output->writeFieldEnd(); + } + if ($this->workflowInputs !== null) { + if (!is_array($this->workflowInputs)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('workflowInputs', TType::LST, 5); + { + $output->writeListBegin(TType::STRUCT, count($this->workflowInputs)); + { + foreach ($this->workflowInputs as $iter12) + { + $xfer += $iter12->write($output); + } + } + $output->writeListEnd(); + } + $xfer += $output->writeFieldEnd(); + } + if ($this->workflowOutputs !== null) { + if (!is_array($this->workflowOutputs)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('workflowOutputs', TType::LST, 6); + { + $output->writeListBegin(TType::STRUCT, count($this->workflowOutputs)); + { + foreach ($this->workflowOutputs as $iter13) + { + $xfer += $iter13->write($output); + } + } + $output->writeListEnd(); + } + $xfer += $output->writeFieldEnd(); + } $xfer += $output->writeFieldStop(); $xfer += $output->writeStructEnd(); return $xfer; http://git-wip-us.apache.org/repos/asf/airavata/blob/dbb1c97a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/Workflow.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/Workflow.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/Workflow.java index 04d92e7..21d2694 100644 --- a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/Workflow.java +++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/Workflow.java @@ -55,6 +55,9 @@ import org.slf4j.LoggerFactory; private static final org.apache.thrift.protocol.TField TEMPLATE_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("templateId", org.apache.thrift.protocol.TType.STRING, (short)1); private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)2); private static final org.apache.thrift.protocol.TField GRAPH_FIELD_DESC = new org.apache.thrift.protocol.TField("graph", org.apache.thrift.protocol.TType.STRING, (short)3); + private static final org.apache.thrift.protocol.TField IMAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("image", org.apache.thrift.protocol.TType.STRING, (short)4); + private static final org.apache.thrift.protocol.TField WORKFLOW_INPUTS_FIELD_DESC = new org.apache.thrift.protocol.TField("workflowInputs", org.apache.thrift.protocol.TType.LIST, (short)5); + private static final org.apache.thrift.protocol.TField WORKFLOW_OUTPUTS_FIELD_DESC = new org.apache.thrift.protocol.TField("workflowOutputs", org.apache.thrift.protocol.TType.LIST, (short)6); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { @@ -65,12 +68,18 @@ import org.slf4j.LoggerFactory; private String templateId; // required private String name; // required private String graph; // optional + private ByteBuffer image; // optional + private List<org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType> workflowInputs; // optional + private List<org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType> workflowOutputs; // optional /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum { TEMPLATE_ID((short)1, "templateId"), NAME((short)2, "name"), - GRAPH((short)3, "graph"); + GRAPH((short)3, "graph"), + IMAGE((short)4, "image"), + WORKFLOW_INPUTS((short)5, "workflowInputs"), + WORKFLOW_OUTPUTS((short)6, "workflowOutputs"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); @@ -91,6 +100,12 @@ import org.slf4j.LoggerFactory; return NAME; case 3: // GRAPH return GRAPH; + case 4: // IMAGE + return IMAGE; + case 5: // WORKFLOW_INPUTS + return WORKFLOW_INPUTS; + case 6: // WORKFLOW_OUTPUTS + return WORKFLOW_OUTPUTS; default: return null; } @@ -131,7 +146,7 @@ import org.slf4j.LoggerFactory; } // isset id assignments - private _Fields optionals[] = {_Fields.GRAPH}; + private _Fields optionals[] = {_Fields.GRAPH,_Fields.IMAGE,_Fields.WORKFLOW_INPUTS,_Fields.WORKFLOW_OUTPUTS}; public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); @@ -141,6 +156,14 @@ import org.slf4j.LoggerFactory; new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.GRAPH, new org.apache.thrift.meta_data.FieldMetaData("graph", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.IMAGE, new org.apache.thrift.meta_data.FieldMetaData("image", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))); + tmpMap.put(_Fields.WORKFLOW_INPUTS, new org.apache.thrift.meta_data.FieldMetaData("workflowInputs", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType.class)))); + tmpMap.put(_Fields.WORKFLOW_OUTPUTS, new org.apache.thrift.meta_data.FieldMetaData("workflowOutputs", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType.class)))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Workflow.class, metaDataMap); } @@ -172,6 +195,24 @@ import org.slf4j.LoggerFactory; if (other.isSetGraph()) { this.graph = other.graph; } + if (other.isSetImage()) { + this.image = org.apache.thrift.TBaseHelper.copyBinary(other.image); +; + } + if (other.isSetWorkflowInputs()) { + List<org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType> __this__workflowInputs = new ArrayList<org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType>(other.workflowInputs.size()); + for (org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType other_element : other.workflowInputs) { + __this__workflowInputs.add(new org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType(other_element)); + } + this.workflowInputs = __this__workflowInputs; + } + if (other.isSetWorkflowOutputs()) { + List<org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType> __this__workflowOutputs = new ArrayList<org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType>(other.workflowOutputs.size()); + for (org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType other_element : other.workflowOutputs) { + __this__workflowOutputs.add(new org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType(other_element)); + } + this.workflowOutputs = __this__workflowOutputs; + } } public Workflow deepCopy() { @@ -184,6 +225,9 @@ import org.slf4j.LoggerFactory; this.name = null; this.graph = null; + this.image = null; + this.workflowInputs = null; + this.workflowOutputs = null; } public String getTemplateId() { @@ -255,6 +299,114 @@ import org.slf4j.LoggerFactory; } } + public byte[] getImage() { + setImage(org.apache.thrift.TBaseHelper.rightSize(image)); + return image == null ? null : image.array(); + } + + public ByteBuffer bufferForImage() { + return image; + } + + public void setImage(byte[] image) { + setImage(image == null ? (ByteBuffer)null : ByteBuffer.wrap(image)); + } + + public void setImage(ByteBuffer image) { + this.image = image; + } + + public void unsetImage() { + this.image = null; + } + + /** Returns true if field image is set (has been assigned a value) and false otherwise */ + public boolean isSetImage() { + return this.image != null; + } + + public void setImageIsSet(boolean value) { + if (!value) { + this.image = null; + } + } + + public int getWorkflowInputsSize() { + return (this.workflowInputs == null) ? 0 : this.workflowInputs.size(); + } + + public java.util.Iterator<org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType> getWorkflowInputsIterator() { + return (this.workflowInputs == null) ? null : this.workflowInputs.iterator(); + } + + public void addToWorkflowInputs(org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType elem) { + if (this.workflowInputs == null) { + this.workflowInputs = new ArrayList<org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType>(); + } + this.workflowInputs.add(elem); + } + + public List<org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType> getWorkflowInputs() { + return this.workflowInputs; + } + + public void setWorkflowInputs(List<org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType> workflowInputs) { + this.workflowInputs = workflowInputs; + } + + public void unsetWorkflowInputs() { + this.workflowInputs = null; + } + + /** Returns true if field workflowInputs is set (has been assigned a value) and false otherwise */ + public boolean isSetWorkflowInputs() { + return this.workflowInputs != null; + } + + public void setWorkflowInputsIsSet(boolean value) { + if (!value) { + this.workflowInputs = null; + } + } + + public int getWorkflowOutputsSize() { + return (this.workflowOutputs == null) ? 0 : this.workflowOutputs.size(); + } + + public java.util.Iterator<org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType> getWorkflowOutputsIterator() { + return (this.workflowOutputs == null) ? null : this.workflowOutputs.iterator(); + } + + public void addToWorkflowOutputs(org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType elem) { + if (this.workflowOutputs == null) { + this.workflowOutputs = new ArrayList<org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType>(); + } + this.workflowOutputs.add(elem); + } + + public List<org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType> getWorkflowOutputs() { + return this.workflowOutputs; + } + + public void setWorkflowOutputs(List<org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType> workflowOutputs) { + this.workflowOutputs = workflowOutputs; + } + + public void unsetWorkflowOutputs() { + this.workflowOutputs = null; + } + + /** Returns true if field workflowOutputs is set (has been assigned a value) and false otherwise */ + public boolean isSetWorkflowOutputs() { + return this.workflowOutputs != null; + } + + public void setWorkflowOutputsIsSet(boolean value) { + if (!value) { + this.workflowOutputs = null; + } + } + public void setFieldValue(_Fields field, Object value) { switch (field) { case TEMPLATE_ID: @@ -281,6 +433,30 @@ import org.slf4j.LoggerFactory; } break; + case IMAGE: + if (value == null) { + unsetImage(); + } else { + setImage((ByteBuffer)value); + } + break; + + case WORKFLOW_INPUTS: + if (value == null) { + unsetWorkflowInputs(); + } else { + setWorkflowInputs((List<org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType>)value); + } + break; + + case WORKFLOW_OUTPUTS: + if (value == null) { + unsetWorkflowOutputs(); + } else { + setWorkflowOutputs((List<org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType>)value); + } + break; + } } @@ -295,6 +471,15 @@ import org.slf4j.LoggerFactory; case GRAPH: return getGraph(); + case IMAGE: + return getImage(); + + case WORKFLOW_INPUTS: + return getWorkflowInputs(); + + case WORKFLOW_OUTPUTS: + return getWorkflowOutputs(); + } throw new IllegalStateException(); } @@ -312,6 +497,12 @@ import org.slf4j.LoggerFactory; return isSetName(); case GRAPH: return isSetGraph(); + case IMAGE: + return isSetImage(); + case WORKFLOW_INPUTS: + return isSetWorkflowInputs(); + case WORKFLOW_OUTPUTS: + return isSetWorkflowOutputs(); } throw new IllegalStateException(); } @@ -356,6 +547,33 @@ import org.slf4j.LoggerFactory; return false; } + boolean this_present_image = true && this.isSetImage(); + boolean that_present_image = true && that.isSetImage(); + if (this_present_image || that_present_image) { + if (!(this_present_image && that_present_image)) + return false; + if (!this.image.equals(that.image)) + return false; + } + + boolean this_present_workflowInputs = true && this.isSetWorkflowInputs(); + boolean that_present_workflowInputs = true && that.isSetWorkflowInputs(); + if (this_present_workflowInputs || that_present_workflowInputs) { + if (!(this_present_workflowInputs && that_present_workflowInputs)) + return false; + if (!this.workflowInputs.equals(that.workflowInputs)) + return false; + } + + boolean this_present_workflowOutputs = true && this.isSetWorkflowOutputs(); + boolean that_present_workflowOutputs = true && that.isSetWorkflowOutputs(); + if (this_present_workflowOutputs || that_present_workflowOutputs) { + if (!(this_present_workflowOutputs && that_present_workflowOutputs)) + return false; + if (!this.workflowOutputs.equals(that.workflowOutputs)) + return false; + } + return true; } @@ -402,6 +620,36 @@ import org.slf4j.LoggerFactory; return lastComparison; } } + lastComparison = Boolean.valueOf(isSetImage()).compareTo(other.isSetImage()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetImage()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.image, other.image); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetWorkflowInputs()).compareTo(other.isSetWorkflowInputs()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetWorkflowInputs()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.workflowInputs, other.workflowInputs); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetWorkflowOutputs()).compareTo(other.isSetWorkflowOutputs()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetWorkflowOutputs()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.workflowOutputs, other.workflowOutputs); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -447,6 +695,36 @@ import org.slf4j.LoggerFactory; } first = false; } + if (isSetImage()) { + if (!first) sb.append(", "); + sb.append("image:"); + if (this.image == null) { + sb.append("null"); + } else { + org.apache.thrift.TBaseHelper.toString(this.image, sb); + } + first = false; + } + if (isSetWorkflowInputs()) { + if (!first) sb.append(", "); + sb.append("workflowInputs:"); + if (this.workflowInputs == null) { + sb.append("null"); + } else { + sb.append(this.workflowInputs); + } + first = false; + } + if (isSetWorkflowOutputs()) { + if (!first) sb.append(", "); + sb.append("workflowOutputs:"); + if (this.workflowOutputs == null) { + sb.append("null"); + } else { + sb.append(this.workflowOutputs); + } + first = false; + } sb.append(")"); return sb.toString(); } @@ -522,6 +800,52 @@ import org.slf4j.LoggerFactory; org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 4: // IMAGE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.image = iprot.readBinary(); + struct.setImageIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 5: // WORKFLOW_INPUTS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list0 = iprot.readListBegin(); + struct.workflowInputs = new ArrayList<org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType>(_list0.size); + for (int _i1 = 0; _i1 < _list0.size; ++_i1) + { + org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType _elem2; + _elem2 = new org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType(); + _elem2.read(iprot); + struct.workflowInputs.add(_elem2); + } + iprot.readListEnd(); + } + struct.setWorkflowInputsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 6: // WORKFLOW_OUTPUTS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list3 = iprot.readListBegin(); + struct.workflowOutputs = new ArrayList<org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType>(_list3.size); + for (int _i4 = 0; _i4 < _list3.size; ++_i4) + { + org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType _elem5; + _elem5 = new org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType(); + _elem5.read(iprot); + struct.workflowOutputs.add(_elem5); + } + iprot.readListEnd(); + } + struct.setWorkflowOutputsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -552,6 +876,41 @@ import org.slf4j.LoggerFactory; oprot.writeFieldEnd(); } } + if (struct.image != null) { + if (struct.isSetImage()) { + oprot.writeFieldBegin(IMAGE_FIELD_DESC); + oprot.writeBinary(struct.image); + oprot.writeFieldEnd(); + } + } + if (struct.workflowInputs != null) { + if (struct.isSetWorkflowInputs()) { + oprot.writeFieldBegin(WORKFLOW_INPUTS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.workflowInputs.size())); + for (org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType _iter6 : struct.workflowInputs) + { + _iter6.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (struct.workflowOutputs != null) { + if (struct.isSetWorkflowOutputs()) { + oprot.writeFieldBegin(WORKFLOW_OUTPUTS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.workflowOutputs.size())); + for (org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType _iter7 : struct.workflowOutputs) + { + _iter7.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } oprot.writeFieldStop(); oprot.writeStructEnd(); } @@ -575,10 +934,40 @@ import org.slf4j.LoggerFactory; if (struct.isSetGraph()) { optionals.set(0); } - oprot.writeBitSet(optionals, 1); + if (struct.isSetImage()) { + optionals.set(1); + } + if (struct.isSetWorkflowInputs()) { + optionals.set(2); + } + if (struct.isSetWorkflowOutputs()) { + optionals.set(3); + } + oprot.writeBitSet(optionals, 4); if (struct.isSetGraph()) { oprot.writeString(struct.graph); } + if (struct.isSetImage()) { + oprot.writeBinary(struct.image); + } + if (struct.isSetWorkflowInputs()) { + { + oprot.writeI32(struct.workflowInputs.size()); + for (org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType _iter8 : struct.workflowInputs) + { + _iter8.write(oprot); + } + } + } + if (struct.isSetWorkflowOutputs()) { + { + oprot.writeI32(struct.workflowOutputs.size()); + for (org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType _iter9 : struct.workflowOutputs) + { + _iter9.write(oprot); + } + } + } } @Override @@ -588,11 +977,43 @@ import org.slf4j.LoggerFactory; struct.setTemplateIdIsSet(true); struct.name = iprot.readString(); struct.setNameIsSet(true); - BitSet incoming = iprot.readBitSet(1); + BitSet incoming = iprot.readBitSet(4); if (incoming.get(0)) { struct.graph = iprot.readString(); struct.setGraphIsSet(true); } + if (incoming.get(1)) { + struct.image = iprot.readBinary(); + struct.setImageIsSet(true); + } + if (incoming.get(2)) { + { + org.apache.thrift.protocol.TList _list10 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.workflowInputs = new ArrayList<org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType>(_list10.size); + for (int _i11 = 0; _i11 < _list10.size; ++_i11) + { + org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType _elem12; + _elem12 = new org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType(); + _elem12.read(iprot); + struct.workflowInputs.add(_elem12); + } + } + struct.setWorkflowInputsIsSet(true); + } + if (incoming.get(3)) { + { + org.apache.thrift.protocol.TList _list13 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.workflowOutputs = new ArrayList<org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType>(_list13.size); + for (int _i14 = 0; _i14 < _list13.size; ++_i14) + { + org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType _elem15; + _elem15 = new org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType(); + _elem15.read(iprot); + struct.workflowOutputs.add(_elem15); + } + } + struct.setWorkflowOutputsIsSet(true); + } } } http://git-wip-us.apache.org/repos/asf/airavata/blob/dbb1c97a/airavata-api/thrift-interface-descriptions/workflowDataModel.thrift ---------------------------------------------------------------------- diff --git a/airavata-api/thrift-interface-descriptions/workflowDataModel.thrift b/airavata-api/thrift-interface-descriptions/workflowDataModel.thrift index ce8ab50..58ba75b 100644 --- a/airavata-api/thrift-interface-descriptions/workflowDataModel.thrift +++ b/airavata-api/thrift-interface-descriptions/workflowDataModel.thrift @@ -21,6 +21,7 @@ namespace java org.apache.airavata.model namespace php Airavata.Model +include "applicationInterfaceModel.thrift" /* * This file describes the definitions of the Airavata Execution Data Structures. Each of the @@ -33,5 +34,8 @@ const string DEFAULT_ID = "DO_NOT_SET_AT_CLIENTS" struct Workflow { 1: required string templateId = DEFAULT_ID, 2: required string name, - 3: optional string graph + 3: optional string graph, + 4: optional binary image, + 5: optional list<applicationInterfaceModel.InputDataObjectType> workflowInputs, + 6: optional list<applicationInterfaceModel.OutputDataObjectType> workflowOutputs } http://git-wip-us.apache.org/repos/asf/airavata/blob/dbb1c97a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/WorkflowCatalogImpl.java ---------------------------------------------------------------------- diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/WorkflowCatalogImpl.java b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/WorkflowCatalogImpl.java index df230fe..3474b40 100644 --- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/WorkflowCatalogImpl.java +++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/WorkflowCatalogImpl.java @@ -23,17 +23,19 @@ package org.apache.aiaravata.application.catalog.data.impl; import org.airavata.appcatalog.cpi.AppCatalogException; import org.airavata.appcatalog.cpi.WorkflowCatalog; -import org.apache.aiaravata.application.catalog.data.resources.AbstractResource; -import org.apache.aiaravata.application.catalog.data.resources.Resource; -import org.apache.aiaravata.application.catalog.data.resources.WorkflowResource; +import org.apache.aiaravata.application.catalog.data.resources.*; import org.apache.aiaravata.application.catalog.data.util.AppCatalogThriftConversion; import org.apache.aiaravata.application.catalog.data.util.AppCatalogUtils; import org.apache.airavata.model.Workflow; +import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType; +import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class WorkflowCatalogImpl implements WorkflowCatalog { private final static Logger logger = LoggerFactory.getLogger(WorkflowCatalogImpl.class); @@ -81,8 +83,39 @@ public class WorkflowCatalogImpl implements WorkflowCatalog { resource.setWfTemplateId(AppCatalogUtils.getID(workflow.getName())); resource.setWfName(workflow.getName()); resource.setGraph(workflow.getGraph()); + if (workflow.getImage() != null){ + resource.setImage(new String(workflow.getImage())); + } resource.save(); workflow.setTemplateId(resource.getWfTemplateId()); + List<InputDataObjectType> workflowInputs = workflow.getWorkflowInputs(); + if (workflowInputs != null && workflowInputs.size() != 0){ + for (InputDataObjectType input : workflowInputs){ + WorkflowInputResource wfInputResource = new WorkflowInputResource(); + wfInputResource.setWorkflowResource(resource); + wfInputResource.setInputKey(input.getName()); + wfInputResource.setInputVal(input.getValue()); + wfInputResource.setWfTemplateId(resource.getWfTemplateId()); + wfInputResource.setDataType(input.getType().toString()); + wfInputResource.setAppArgument(input.getApplicationArgument()); + wfInputResource.setStandareInput(input.isStandardInput()); + wfInputResource.setUserFriendlyDesc(input.getUserFriendlyDescription()); + wfInputResource.setMetadata(input.getMetaData()); + wfInputResource.save(); + } + } + List<OutputDataObjectType> workflowOutputs = workflow.getWorkflowOutputs(); + if (workflowOutputs != null && workflowOutputs.size() != 0){ + for (OutputDataObjectType output : workflowOutputs){ + WorkflowOutputResource outputResource = new WorkflowOutputResource(); + outputResource.setWorkflowResource(resource); + outputResource.setOutputKey(output.getName()); + outputResource.setOutputVal(output.getValue()); + outputResource.setWfTemplateId(resource.getWfTemplateId()); + outputResource.setDataType(output.getType().toString()); + outputResource.save(); + } + } return resource.getWfTemplateId(); } catch (Exception e) { logger.error("Error while saving the workflow...", e); @@ -97,7 +130,46 @@ public class WorkflowCatalogImpl implements WorkflowCatalog { WorkflowResource existingWF = (WorkflowResource)resource.get(workflowTemplateId); existingWF.setWfName(workflow.getName()); existingWF.setGraph(workflow.getGraph()); + if (workflow.getImage() != null){ + existingWF.setImage(new String(workflow.getImage())); + } existingWF.save(); + List<InputDataObjectType> existingwFInputs = workflow.getWorkflowInputs(); + if (existingwFInputs != null && existingwFInputs.size() != 0){ + for (InputDataObjectType input : existingwFInputs){ + WorkflowInputResource wfInputResource = new WorkflowInputResource(); + Map<String, String> ids = new HashMap<String, String>(); + ids.put(AbstractResource.WFInputConstants.WF_TEMPLATE_ID,existingWF.getWfTemplateId()); + ids.put(AbstractResource.WFInputConstants.INPUT_KEY,input.getName()); + WorkflowInputResource existingInput = (WorkflowInputResource)wfInputResource.get(ids); + existingInput.setWorkflowResource(existingWF); + existingInput.setInputKey(input.getName()); + existingInput.setInputVal(input.getValue()); + existingInput.setWfTemplateId(existingWF.getWfTemplateId()); + existingInput.setDataType(input.getType().toString()); + existingInput.setAppArgument(input.getApplicationArgument()); + existingInput.setStandareInput(input.isStandardInput()); + existingInput.setUserFriendlyDesc(input.getUserFriendlyDescription()); + existingInput.setMetadata(input.getMetaData()); + existingInput.save(); + } + } + List<OutputDataObjectType> workflowOutputs = workflow.getWorkflowOutputs(); + if (workflowOutputs != null && workflowOutputs.size() != 0){ + for (OutputDataObjectType output : workflowOutputs){ + WorkflowOutputResource outputResource = new WorkflowOutputResource(); + Map<String, String> ids = new HashMap<String, String>(); + ids.put(AbstractResource.WFOutputConstants.WF_TEMPLATE_ID,existingWF.getWfTemplateId()); + ids.put(AbstractResource.WFOutputConstants.OUTPUT_KEY,output.getName()); + WorkflowOutputResource existingOutput = (WorkflowOutputResource)outputResource.get(ids); + existingOutput.setWorkflowResource(existingWF); + existingOutput.setOutputKey(output.getName()); + existingOutput.setOutputVal(output.getValue()); + existingOutput.setWfTemplateId(existingWF.getWfTemplateId()); + existingOutput.setDataType(output.getType().toString()); + existingOutput.save(); + } + } } catch (Exception e) { logger.error("Error while updating the workflow...", e); throw new AppCatalogException(e); http://git-wip-us.apache.org/repos/asf/airavata/blob/dbb1c97a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/Workflow.java ---------------------------------------------------------------------- diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/Workflow.java b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/Workflow.java index 908c6fc..5ebe081 100644 --- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/Workflow.java +++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/Workflow.java @@ -52,6 +52,11 @@ public class Workflow implements Serializable { @Column(name = "UPDATE_TIME") private Timestamp updateTime; + @Lob + @Column(name = "IMAGE") + private byte[] image; + + public Timestamp getCreationTime() { return creationTime; } @@ -99,5 +104,13 @@ public class Workflow implements Serializable { public void setWfTemplateId(String wfTemplateId) { this.wfTemplateId=wfTemplateId; } + + public byte[] getImage() { + return image; + } + + public void setImage(byte[] image) { + this.image = image; + } } http://git-wip-us.apache.org/repos/asf/airavata/blob/dbb1c97a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/WorkflowInput.java ---------------------------------------------------------------------- diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/WorkflowInput.java b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/WorkflowInput.java new file mode 100644 index 0000000..81d2b6d --- /dev/null +++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/WorkflowInput.java @@ -0,0 +1,127 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.aiaravata.application.catalog.data.model; + + +import javax.persistence.*; +import java.io.Serializable; + +@Entity +@Table(name = "WORKFLOW_INPUT") +@IdClass(WorkflowInput_PK.class) +public class WorkflowInput implements Serializable { + @Id + @Column(name = "WF_TEMPLATE_ID") + private String wfTemplateId; + @Id + @Column(name = "INPUT_KEY") + private String inputKey; + @Lob + @Column(name = "INPUT_VALUE") + private char[] inputVal; + @Column(name = "DATA_TYPE") + private String dataType; + @Column(name = "METADATA") + private String metadata; + @Column(name = "APP_ARGUMENT") + private String appArgument; + @Column(name = "USER_FRIENDLY_DESC") + private String userFriendlyDesc; + @Column(name = "STANDARD_INPUT") + private boolean standardInput; + + @ManyToOne(cascade= CascadeType.MERGE) + @JoinColumn(name = "WF_TEMPLATE_ID") + private Workflow workflow; + + public String getWfTemplateId() { + return wfTemplateId; + } + + public void setWfTemplateId(String wfTemplateId) { + this.wfTemplateId = wfTemplateId; + } + + public String getInputKey() { + return inputKey; + } + + public void setInputKey(String inputKey) { + this.inputKey = inputKey; + } + + public char[] getInputVal() { + return inputVal; + } + + public void setInputVal(char[] inputVal) { + this.inputVal = inputVal; + } + + 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 getAppArgument() { + return appArgument; + } + + public void setAppArgument(String appArgument) { + this.appArgument = appArgument; + } + + public String getUserFriendlyDesc() { + return userFriendlyDesc; + } + + public void setUserFriendlyDesc(String userFriendlyDesc) { + this.userFriendlyDesc = userFriendlyDesc; + } + + public Workflow getWorkflow() { + return workflow; + } + + public void setWorkflow(Workflow workflow) { + this.workflow = workflow; + } + + public boolean isStandardInput() { + return standardInput; + } + + public void setStandardInput(boolean standardInput) { + this.standardInput = standardInput; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/dbb1c97a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/WorkflowInput_PK.java ---------------------------------------------------------------------- diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/WorkflowInput_PK.java b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/WorkflowInput_PK.java new file mode 100644 index 0000000..e84f572 --- /dev/null +++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/WorkflowInput_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.aiaravata.application.catalog.data.model; + +import java.io.Serializable; + +public class WorkflowInput_PK implements Serializable { + private String wfTemplateId; + private String inputKey; + + public WorkflowInput_PK(String wfTemplateId, String inputKey) { + this.wfTemplateId = wfTemplateId; + this.inputKey = inputKey; + } + + public WorkflowInput_PK() { + ; + } + + @Override + public boolean equals(Object o) { + return false; + } + + @Override + public int hashCode() { + return 1; + } + + public String getWfTemplateId() { + return wfTemplateId; + } + + public void setWfTemplateId(String wfTemplateId) { + this.wfTemplateId = wfTemplateId; + } + + public String getInputKey() { + return inputKey; + } + + public void setInputKey(String inputKey) { + this.inputKey = inputKey; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/dbb1c97a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/WorkflowOutput.java ---------------------------------------------------------------------- diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/WorkflowOutput.java b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/WorkflowOutput.java new file mode 100644 index 0000000..5532c6c --- /dev/null +++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/WorkflowOutput.java @@ -0,0 +1,87 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.aiaravata.application.catalog.data.model; + + +import javax.persistence.*; +import java.io.Serializable; + +@Entity +@Table(name = "WORKFLOW_OUTPUT") +@IdClass(WorkflowOutput_PK.class) +public class WorkflowOutput implements Serializable { + @Id + @Column(name = "WF_TEMPLATE_ID") + private String wfTemplateId; + @Id + @Column(name = "OUTPUT_KEY") + private String outputKey; + @Lob + @Column(name = "OUTPUT_VALUE") + private char[] outputVal; + @Column(name = "DATA_TYPE") + private String dataType; + + @ManyToOne(cascade= CascadeType.MERGE) + @JoinColumn(name = "WF_TEMPLATE_ID") + private Workflow workflow; + + public String getWfTemplateId() { + return wfTemplateId; + } + + public void setWfTemplateId(String wfTemplateId) { + this.wfTemplateId = wfTemplateId; + } + + public String getDataType() { + return dataType; + } + + public void setDataType(String dataType) { + this.dataType = dataType; + } + + public Workflow getWorkflow() { + return workflow; + } + + public void setWorkflow(Workflow workflow) { + this.workflow = workflow; + } + + public String getOutputKey() { + return outputKey; + } + + public void setOutputKey(String outputKey) { + this.outputKey = outputKey; + } + + public char[] getOutputVal() { + return outputVal; + } + + public void setOutputVal(char[] outputVal) { + this.outputVal = outputVal; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/dbb1c97a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/WorkflowOutput_PK.java ---------------------------------------------------------------------- diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/WorkflowOutput_PK.java b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/WorkflowOutput_PK.java new file mode 100644 index 0000000..4439340 --- /dev/null +++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/model/WorkflowOutput_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.aiaravata.application.catalog.data.model; + +import java.io.Serializable; + +public class WorkflowOutput_PK implements Serializable { + private String wfTemplateId; + private String outputKey; + + public WorkflowOutput_PK(String wfTemplateId, String outputKey) { + this.wfTemplateId = wfTemplateId; + this.outputKey = outputKey; + } + + public WorkflowOutput_PK() { + ; + } + + @Override + public boolean equals(Object o) { + return false; + } + + @Override + public int hashCode() { + return 1; + } + + public String getWfTemplateId() { + return wfTemplateId; + } + + public void setWfTemplateId(String wfTemplateId) { + this.wfTemplateId = wfTemplateId; + } + + public String getOutputKey() { + return outputKey; + } + + public void setOutputKey(String outputKey) { + this.outputKey = outputKey; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/dbb1c97a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/AbstractResource.java ---------------------------------------------------------------------- diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/AbstractResource.java b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/AbstractResource.java index 005f12b..403d9cf 100644 --- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/AbstractResource.java +++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/AbstractResource.java @@ -46,7 +46,9 @@ public abstract class AbstractResource implements Resource { public static final String APPLICATION_INTERFACE = "ApplicationInterface"; public static final String APP_MODULE_MAPPING = "AppModuleMapping"; public static final String APPLICATION_INPUT = "ApplicationInput"; + public static final String WORKFLOW_INPUT = "WorkflowInput"; public static final String APPLICATION_OUTPUT = "ApplicationOutput"; + public static final String WORKFLOW_OUTPUT = "WorkflowOutput"; public static final String GATEWAY_PROFILE = "GatewayProfile"; public static final String COMPUTE_RESOURCE_PREFERENCE = "ComputeResourcePreference"; public static final String BATCH_QUEUE = "BatchQueue"; @@ -223,6 +225,24 @@ public abstract class AbstractResource implements Resource { public static final String DATA_TYPE = "dataType"; } + public final class WFInputConstants { + public static final String WF_TEMPLATE_ID = "wfTemplateId"; + public static final String INPUT_KEY = "inputKey"; + public static final String INPUT_VALUE = "inputVal"; + public static final String DATA_TYPE = "dataType"; + public static final String METADATA = "metadata"; + public static final String APP_ARGUMENT = "appArgument"; + public static final String USER_FRIENDLY_DESC = "userFriendlyDesc"; + public static final String STANDARD_INPUT = "standardInput"; + } + + public final class WFOutputConstants { + public static final String WF_TEMPLATE_ID = "wfTemplateId"; + public static final String OUTPUT_KEY = "outputKey"; + public static final String OUTPUT_VALUE = "outputVal"; + public static final String DATA_TYPE = "dataType"; + } + public final class GatewayProfileConstants { public static final String GATEWAY_ID = "gatewayID"; public static final String GATEWAY_NAME = "gatewayName"; http://git-wip-us.apache.org/repos/asf/airavata/blob/dbb1c97a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/WorkflowInputResource.java ---------------------------------------------------------------------- diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/WorkflowInputResource.java b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/WorkflowInputResource.java new file mode 100644 index 0000000..75c1351 --- /dev/null +++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/WorkflowInputResource.java @@ -0,0 +1,412 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.aiaravata.application.catalog.data.resources; + +import org.airavata.appcatalog.cpi.AppCatalogException; +import org.apache.aiaravata.application.catalog.data.model.Workflow; +import org.apache.aiaravata.application.catalog.data.model.WorkflowInput; +import org.apache.aiaravata.application.catalog.data.model.WorkflowInput_PK; +import org.apache.aiaravata.application.catalog.data.util.AppCatalogJPAUtils; +import org.apache.aiaravata.application.catalog.data.util.AppCatalogQueryGenerator; +import org.apache.aiaravata.application.catalog.data.util.AppCatalogResourceType; +import org.apache.airavata.common.exception.ApplicationSettingsException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.persistence.EntityManager; +import javax.persistence.Query; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class WorkflowInputResource extends AbstractResource { + + private final static Logger logger = LoggerFactory.getLogger(WorkflowInputResource.class); + + private String wfTemplateId; + private String inputKey; + private String dataType; + private String inputVal; + private String metadata; + private String appArgument; + private String userFriendlyDesc; + private boolean standareInput; + + private WorkflowResource workflowResource; + + public void remove(Object identifier) throws AppCatalogException { + HashMap<String, String> ids; + if (identifier instanceof Map) { + ids = (HashMap) identifier; + } else { + logger.error("Identifier should be a map with the field name and it's value"); + throw new AppCatalogException("Identifier should be a map with the field name and it's value"); + } + + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_INPUT); + generator.setParameter(WFInputConstants.WF_TEMPLATE_ID, ids.get(WFInputConstants.WF_TEMPLATE_ID)); + generator.setParameter(WFInputConstants.INPUT_KEY, ids.get(WFInputConstants.INPUT_KEY)); + Query q = generator.deleteQuery(em); + q.executeUpdate(); + em.getTransaction().commit(); + em.close(); + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + public Resource get(Object identifier) throws AppCatalogException { + HashMap<String, String> ids; + if (identifier instanceof Map) { + ids = (HashMap<String, String>) identifier; + } else { + logger.error("Identifier should be a map with the field name and it's value"); + throw new AppCatalogException("Identifier should be a map with the field name and it's value"); + } + + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_INPUT); + generator.setParameter(WFInputConstants.WF_TEMPLATE_ID, ids.get(WFInputConstants.WF_TEMPLATE_ID)); + generator.setParameter(WFInputConstants.INPUT_KEY, ids.get(WFInputConstants.INPUT_KEY)); + Query q = generator.selectQuery(em); + WorkflowInput workflowInput = (WorkflowInput) q.getSingleResult(); + WorkflowInputResource workflowInputResource = + (WorkflowInputResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW_INPUT + , workflowInput); + em.getTransaction().commit(); + em.close(); + return workflowInputResource; + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + public List<Resource> get(String fieldName, Object value) throws AppCatalogException { + List<Resource> wfInputResources = new ArrayList<Resource>(); + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + Query q; + AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_INPUT); + List results; + if (fieldName.equals(WFInputConstants.WF_TEMPLATE_ID)) { + generator.setParameter(WFInputConstants.WF_TEMPLATE_ID, value); + q = generator.selectQuery(em); + results = q.getResultList(); + if (results.size() != 0) { + for (Object result : results) { + WorkflowInput workflowInput = (WorkflowInput) result; + WorkflowInputResource workflowInputResource = + (WorkflowInputResource) AppCatalogJPAUtils.getResource( + AppCatalogResourceType.WORKFLOW_INPUT, workflowInput); + wfInputResources.add(workflowInputResource); + } + } + } else if (fieldName.equals(WFInputConstants.INPUT_KEY)) { + generator.setParameter(WFInputConstants.INPUT_KEY, value); + q = generator.selectQuery(em); + results = q.getResultList(); + if (results.size() != 0) { + for (Object result : results) { + WorkflowInput workflowInput = (WorkflowInput) result; + WorkflowInputResource workflowInputResource = + (WorkflowInputResource) AppCatalogJPAUtils.getResource( + AppCatalogResourceType.WORKFLOW_INPUT, workflowInput); + wfInputResources.add(workflowInputResource); + } + } + } else if (fieldName.equals(WFInputConstants.DATA_TYPE)) { + generator.setParameter(WFInputConstants.DATA_TYPE, value); + q = generator.selectQuery(em); + results = q.getResultList(); + if (results.size() != 0) { + for (Object result : results) { + WorkflowInput workflowInput = (WorkflowInput) result; + WorkflowInputResource workflowInputResource = + (WorkflowInputResource) AppCatalogJPAUtils.getResource( + AppCatalogResourceType.WORKFLOW_INPUT, workflowInput); + wfInputResources.add(workflowInputResource); + } + } + } else { + em.getTransaction().commit(); + em.close(); + logger.error("Unsupported field name for WFInput Resource.", new IllegalArgumentException()); + throw new IllegalArgumentException("Unsupported field name for WFInput Resource."); + } + em.getTransaction().commit(); + em.close(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + return wfInputResources; + } + + public List<Resource> getAll() throws AppCatalogException { + return null; + } + + public List<String> getAllIds() throws AppCatalogException { + return null; + } + + public List<String> getIds(String fieldName, Object value) throws AppCatalogException { + List<String> wfInputResourceIDs = new ArrayList<String>(); + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + Query q; + AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_INPUT); + List results; + if (fieldName.equals(WFInputConstants.WF_TEMPLATE_ID)) { + generator.setParameter(WFInputConstants.WF_TEMPLATE_ID, value); + q = generator.selectQuery(em); + results = q.getResultList(); + if (results.size() != 0) { + for (Object result : results) { + WorkflowInput workflowInput = (WorkflowInput) result; + wfInputResourceIDs.add(workflowInput.getWfTemplateId()); + } + } + } else if (fieldName.equals(WFInputConstants.INPUT_KEY)) { + generator.setParameter(WFInputConstants.INPUT_KEY, value); + q = generator.selectQuery(em); + results = q.getResultList(); + if (results.size() != 0) { + for (Object result : results) { + WorkflowInput workflowInput = (WorkflowInput) result; + wfInputResourceIDs.add(workflowInput.getWfTemplateId()); + } + } + } else if (fieldName.equals(WFInputConstants.DATA_TYPE)) { + generator.setParameter(WFInputConstants.DATA_TYPE, value); + q = generator.selectQuery(em); + results = q.getResultList(); + if (results.size() != 0) { + for (Object result : results) { + WorkflowInput workflowInput = (WorkflowInput) result; + wfInputResourceIDs.add(workflowInput.getWfTemplateId()); + } + } + } else { + em.getTransaction().commit(); + em.close(); + logger.error("Unsupported field name for WFInput resource.", new IllegalArgumentException()); + throw new IllegalArgumentException("Unsupported field name for WFInput Resource."); + } + em.getTransaction().commit(); + em.close(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + return wfInputResourceIDs; + } + + public void save() throws AppCatalogException { + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + WorkflowInput existingWFInput = em.find(WorkflowInput.class, new WorkflowInput_PK(wfTemplateId, inputKey)); + em.close(); + WorkflowInput workflowInput; + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + if (existingWFInput == null) { + workflowInput = new WorkflowInput(); + } else { + workflowInput=existingWFInput; + } + workflowInput.setWfTemplateId(wfTemplateId); + Workflow workflow = em.find(Workflow.class, wfTemplateId); + workflowInput.setWorkflow(workflow); + workflowInput.setDataType(dataType); + workflowInput.setInputKey(inputKey); + if (inputVal != null){ + workflowInput.setInputVal(inputVal.toCharArray()); + } + workflowInput.setMetadata(metadata); + workflowInput.setAppArgument(appArgument); + workflowInput.setUserFriendlyDesc(userFriendlyDesc); + workflowInput.setStandardInput(standareInput); + if (existingWFInput == null) { + em.persist(workflowInput); + } else { + em.merge(workflowInput); + } + em.getTransaction().commit(); + em.close(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + public boolean isExists(Object identifier) throws AppCatalogException { + HashMap<String, String> ids; + if (identifier instanceof Map) { + ids = (HashMap<String, String>) identifier; + } else { + logger.error("Identifier should be a map with the field name and it's value"); + throw new AppCatalogException("Identifier should be a map with the field name and it's value"); + } + + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + WorkflowInput workflowInput = em.find(WorkflowInput.class, new WorkflowInput_PK( + ids.get(WFInputConstants.WF_TEMPLATE_ID), + ids.get(WFInputConstants.INPUT_KEY))); + + em.close(); + return workflowInput != null; + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + public String getWfTemplateId() { + return wfTemplateId; + } + + public void setWfTemplateId(String wfTemplateId) { + this.wfTemplateId = wfTemplateId; + } + + public String getInputKey() { + return inputKey; + } + + public void setInputKey(String inputKey) { + this.inputKey = inputKey; + } + + public String getDataType() { + return dataType; + } + + public void setDataType(String dataType) { + this.dataType = dataType; + } + + public String getInputVal() { + return inputVal; + } + + public void setInputVal(String inputVal) { + this.inputVal = inputVal; + } + + public String getMetadata() { + return metadata; + } + + public void setMetadata(String metadata) { + this.metadata = metadata; + } + + public String getAppArgument() { + return appArgument; + } + + public void setAppArgument(String appArgument) { + this.appArgument = appArgument; + } + + public String getUserFriendlyDesc() { + return userFriendlyDesc; + } + + public void setUserFriendlyDesc(String userFriendlyDesc) { + this.userFriendlyDesc = userFriendlyDesc; + } + + public WorkflowResource getWorkflowResource() { + return workflowResource; + } + + public void setWorkflowResource(WorkflowResource workflowResource) { + this.workflowResource = workflowResource; + } + + public boolean isStandareInput() { + return standareInput; + } + + public void setStandareInput(boolean standareInput) { + this.standareInput = standareInput; + } +}
