fixing child data products JPA issue
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/18cd83c3 Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/18cd83c3 Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/18cd83c3 Branch: refs/heads/develop Commit: 18cd83c37845b8f66ace551eebebfa2fcad0b523 Parents: b2740e7 Author: scnakandala <[email protected]> Authored: Thu Mar 24 14:02:58 2016 -0400 Committer: scnakandala <[email protected]> Committed: Thu Mar 24 14:02:58 2016 -0400 ---------------------------------------------------------------------- .../api/server/handler/utils/DataCatInit.java | 315 ------- .../server/handler/utils/ReplicaCatInit.java | 315 +++++++ .../lib/Airavata/Model/Data/Replica/Types.php | 879 +++++++++++++++++++ .../airavata/model/data/replica/__init__.py | 1 + .../airavata/model/data/replica/constants.py | 11 + .../airavata/model/data/replica/ttypes.py | 549 ++++++++++++ .../main/resources/airavata-server.properties | 14 +- .../test/resources/airavata-server.properties | 14 +- .../catalog/impl/ReplicaCatalogImpl.java | 10 +- .../core/replica/catalog/model/DataProduct.java | 2 +- .../catalog/utils/ReplicaCatalogJPAUtils.java | 26 +- .../utils/ThriftDataModelConversion.java | 2 +- .../src/main/resources/META-INF/persistence.xml | 2 +- .../replica/catalog/ReplicaCatalogTest.java | 16 +- .../replica/catalog/util/Initialize.java | 8 +- 15 files changed, 1805 insertions(+), 359 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/18cd83c3/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/DataCatInit.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/DataCatInit.java b/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/DataCatInit.java deleted file mode 100644 index b63d9c4..0000000 --- a/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/DataCatInit.java +++ /dev/null @@ -1,315 +0,0 @@ -/* - * - * 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.api.server.handler.utils; - -import org.apache.airavata.common.exception.ApplicationSettingsException; -import org.apache.airavata.common.utils.ServerSettings; -import org.apache.airavata.registry.core.replica.catalog.utils.ReplicaCatalogConstants; -import org.apache.derby.drda.NetworkServerControl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.InetAddress; -import java.net.URI; -import java.sql.*; -import java.util.StringTokenizer; - -public class DataCatInit { - private static final Logger logger = LoggerFactory.getLogger(DataCatInit.class); - public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer"; - public String scriptName = "replicacatalog-derby.sql"; - private NetworkServerControl server; - private static final String delimiter = ";"; - private String jdbcUrl = null; - private String jdbcDriver = null; - private String jdbcUser = null; - private String jdbcPassword = null; - - public DataCatInit(String scriptName) { - this.scriptName = scriptName; - } - - public static boolean checkStringBufferEndsWith(StringBuffer buffer, String suffix) { - if (suffix.length() > buffer.length()) { - return false; - } - // this loop is done on purpose to avoid memory allocation performance - // problems on various JDKs - // StringBuffer.lastIndexOf() was introduced in jdk 1.4 and - // implementation is ok though does allocation/copying - // StringBuffer.toString().endsWith() does massive memory - // allocation/copying on JDK 1.5 - // See http://issues.apache.org/bugzilla/show_bug.cgi?id=37169 - int endIndex = suffix.length() - 1; - int bufferIndex = buffer.length() - 1; - while (endIndex >= 0) { - if (buffer.charAt(bufferIndex) != suffix.charAt(endIndex)) { - return false; - } - bufferIndex--; - endIndex--; - } - return true; - } - - private static boolean isServerStarted(NetworkServerControl server, int ntries) - { - for (int i = 1; i <= ntries; i ++) - { - try { - Thread.sleep(500); - server.ping(); - return true; - } - catch (Exception e) { - if (i == ntries) - return false; - } - } - return false; - } - - public void initializeDB() { - try{ - jdbcDriver = ServerSettings.getSetting("datacatalog.jdbc.driver"); - jdbcUrl = ServerSettings.getSetting("datacatalog.jdbc.url"); - jdbcUser = ServerSettings.getSetting("datacatalog.jdbc.user"); - jdbcPassword = ServerSettings.getSetting("datacatalog.jdbc.password"); - jdbcUrl = jdbcUrl + "?" + "user=" + jdbcUser + "&" + "password=" + jdbcPassword; - } catch (ApplicationSettingsException e) { - logger.error("Unable to read properties", e); - } - - startDerbyInServerMode(); - if(!isServerStarted(server, 20)){ - throw new RuntimeException("Derby server could not started within five seconds..."); - } - Connection conn = null; - try { - Class.forName(jdbcDriver).newInstance(); - conn = DriverManager.getConnection(jdbcUrl, jdbcUser, jdbcPassword); - if (!isDatabaseStructureCreated(ReplicaCatalogConstants.CONFIGURATION, conn)) { - executeSQLScript(conn); - logger.info("New Database created for Data Catalog !!!"); - } else { - logger.debug("Database already created for Data Catalog!"); - } - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new RuntimeException("Database failure", e); - } finally { - try { - if (conn != null){ - if (!conn.getAutoCommit()) { - conn.commit(); - } - conn.close(); - } - } catch (SQLException e) { - logger.error(e.getMessage(), e); - } - } - } - - public static boolean isDatabaseStructureCreated(String tableName, Connection conn) { - try { - System.out.println("Running a query to test the database tables existence."); - // check whether the tables are already created with a query - Statement statement = null; - try { - statement = conn.createStatement(); - ResultSet rs = statement.executeQuery("select * from " + tableName); - if (rs != null) { - rs.close(); - } - } finally { - try { - if (statement != null) { - statement.close(); - } - } catch (SQLException e) { - return false; - } - } - } catch (SQLException e) { - return false; - } - - return true; - } - - private void executeSQLScript(Connection conn) throws Exception { - StringBuffer sql = new StringBuffer(); - BufferedReader reader = null; - try{ - - InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(scriptName); - reader = new BufferedReader(new InputStreamReader(inputStream)); - String line; - while ((line = reader.readLine()) != null) { - line = line.trim(); - if (line.startsWith("//")) { - continue; - } - if (line.startsWith("--")) { - continue; - } - StringTokenizer st = new StringTokenizer(line); - if (st.hasMoreTokens()) { - String token = st.nextToken(); - if ("REM".equalsIgnoreCase(token)) { - continue; - } - } - sql.append(" ").append(line); - - // SQL defines "--" as a comment to EOL - // and in Oracle it may contain a hint - // so we cannot just remove it, instead we must end it - if (line.indexOf("--") >= 0) { - sql.append("\n"); - } - if ((checkStringBufferEndsWith(sql, delimiter))) { - executeSQL(sql.substring(0, sql.length() - delimiter.length()), conn); - sql.replace(0, sql.length(), ""); - } - } - // Catch any statements not followed by ; - if (sql.length() > 0) { - executeSQL(sql.toString(), conn); - } - }catch (IOException e){ - logger.error("Error occurred while executing SQL script for creating Airavata Data Catalog database", e); - throw new Exception("Error occurred while executing SQL script for creating Airavata Data Catalog database", e); - }finally { - if (reader != null) { - reader.close(); - } - } - } - - private static void executeSQL(String sql, Connection conn) throws Exception { - // Check and ignore empty statements - if ("".equals(sql.trim())) { - return; - } - - Statement statement = null; - try { - logger.debug("SQL : " + sql); - - boolean ret; - int updateCount = 0, updateCountTotal = 0; - statement = conn.createStatement(); - ret = statement.execute(sql); - updateCount = statement.getUpdateCount(); - do { - if (!ret) { - if (updateCount != -1) { - updateCountTotal += updateCount; - } - } - ret = statement.getMoreResults(); - if (ret) { - updateCount = statement.getUpdateCount(); - } - } while (ret); - - logger.debug(sql + " : " + updateCountTotal + " rows affected"); - - SQLWarning warning = conn.getWarnings(); - while (warning != null) { - logger.warn(warning + " sql warning"); - warning = warning.getNextWarning(); - } - conn.clearWarnings(); - } catch (SQLException e) { - if (e.getSQLState().equals("X0Y32")) { - // eliminating the table already exception for the derby - // database - logger.info("Table Already Exists", e); - } else { - throw new Exception("Error occurred while executing : " + sql, e); - } - } finally { - if (statement != null) { - try { - statement.close(); - } catch (SQLException e) { - logger.error("Error occurred while closing result set.", e); - } - } - } - } - - private void startDerbyInServerMode() { - try { - System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "true"); - server = new NetworkServerControl(InetAddress.getByName("0.0.0.0"), - 20000, - jdbcUser, jdbcPassword); - java.io.PrintWriter consoleWriter = new java.io.PrintWriter(System.out, true); - server.start(consoleWriter); - } catch (IOException e) { - logger.error("Unable to start Apache derby in the server mode! Check whether " + - "specified port is available"); - } catch (Exception e) { - logger.error("Unable to start Apache derby in the server mode! Check whether " + - "specified port is available"); - } - - } - - public static int getPort(String jdbcURL){ - try{ - String cleanURI = jdbcURL.substring(5); - URI uri = URI.create(cleanURI); - return uri.getPort(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - return -1; - } - } - - private void startDerbyInEmbeddedMode(){ - try { - Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); - DriverManager.getConnection("jdbc:derby:memory:unit-testing-jpa;create=true").close(); - } catch (ClassNotFoundException e) { - logger.error(e.getMessage(), e); - } catch (SQLException e) { - logger.error(e.getMessage(), e); - } - } - - public void stopDerbyServer() { - try { - server.shutdown(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - } - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/18cd83c3/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ReplicaCatInit.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ReplicaCatInit.java b/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ReplicaCatInit.java new file mode 100644 index 0000000..977454a --- /dev/null +++ b/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ReplicaCatInit.java @@ -0,0 +1,315 @@ +/* + * + * 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.api.server.handler.utils; + +import org.apache.airavata.common.exception.ApplicationSettingsException; +import org.apache.airavata.common.utils.ServerSettings; +import org.apache.airavata.registry.core.replica.catalog.utils.ReplicaCatalogConstants; +import org.apache.derby.drda.NetworkServerControl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.InetAddress; +import java.net.URI; +import java.sql.*; +import java.util.StringTokenizer; + +public class ReplicaCatInit { + private static final Logger logger = LoggerFactory.getLogger(ReplicaCatInit.class); + public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer"; + public String scriptName = "replicacatalog-derby.sql"; + private NetworkServerControl server; + private static final String delimiter = ";"; + private String jdbcUrl = null; + private String jdbcDriver = null; + private String jdbcUser = null; + private String jdbcPassword = null; + + public ReplicaCatInit(String scriptName) { + this.scriptName = scriptName; + } + + public static boolean checkStringBufferEndsWith(StringBuffer buffer, String suffix) { + if (suffix.length() > buffer.length()) { + return false; + } + // this loop is done on purpose to avoid memory allocation performance + // problems on various JDKs + // StringBuffer.lastIndexOf() was introduced in jdk 1.4 and + // implementation is ok though does allocation/copying + // StringBuffer.toString().endsWith() does massive memory + // allocation/copying on JDK 1.5 + // See http://issues.apache.org/bugzilla/show_bug.cgi?id=37169 + int endIndex = suffix.length() - 1; + int bufferIndex = buffer.length() - 1; + while (endIndex >= 0) { + if (buffer.charAt(bufferIndex) != suffix.charAt(endIndex)) { + return false; + } + bufferIndex--; + endIndex--; + } + return true; + } + + private static boolean isServerStarted(NetworkServerControl server, int ntries) + { + for (int i = 1; i <= ntries; i ++) + { + try { + Thread.sleep(500); + server.ping(); + return true; + } + catch (Exception e) { + if (i == ntries) + return false; + } + } + return false; + } + + public void initializeDB() { + try{ + jdbcDriver = ServerSettings.getSetting("replicacatalog.jdbc.driver"); + jdbcUrl = ServerSettings.getSetting("replicacatalog.jdbc.url"); + jdbcUser = ServerSettings.getSetting("replicacatalog.jdbc.user"); + jdbcPassword = ServerSettings.getSetting("replicacatalog.jdbc.password"); + jdbcUrl = jdbcUrl + "?" + "user=" + jdbcUser + "&" + "password=" + jdbcPassword; + } catch (ApplicationSettingsException e) { + logger.error("Unable to read properties", e); + } + + startDerbyInServerMode(); + if(!isServerStarted(server, 20)){ + throw new RuntimeException("Derby server could not started within five seconds..."); + } + Connection conn = null; + try { + Class.forName(jdbcDriver).newInstance(); + conn = DriverManager.getConnection(jdbcUrl, jdbcUser, jdbcPassword); + if (!isDatabaseStructureCreated(ReplicaCatalogConstants.CONFIGURATION, conn)) { + executeSQLScript(conn); + logger.info("New Database created for Data Catalog !!!"); + } else { + logger.debug("Database already created for Data Catalog!"); + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new RuntimeException("Database failure", e); + } finally { + try { + if (conn != null){ + if (!conn.getAutoCommit()) { + conn.commit(); + } + conn.close(); + } + } catch (SQLException e) { + logger.error(e.getMessage(), e); + } + } + } + + public static boolean isDatabaseStructureCreated(String tableName, Connection conn) { + try { + System.out.println("Running a query to test the database tables existence."); + // check whether the tables are already created with a query + Statement statement = null; + try { + statement = conn.createStatement(); + ResultSet rs = statement.executeQuery("select * from " + tableName); + if (rs != null) { + rs.close(); + } + } finally { + try { + if (statement != null) { + statement.close(); + } + } catch (SQLException e) { + return false; + } + } + } catch (SQLException e) { + return false; + } + + return true; + } + + private void executeSQLScript(Connection conn) throws Exception { + StringBuffer sql = new StringBuffer(); + BufferedReader reader = null; + try{ + + InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(scriptName); + reader = new BufferedReader(new InputStreamReader(inputStream)); + String line; + while ((line = reader.readLine()) != null) { + line = line.trim(); + if (line.startsWith("//")) { + continue; + } + if (line.startsWith("--")) { + continue; + } + StringTokenizer st = new StringTokenizer(line); + if (st.hasMoreTokens()) { + String token = st.nextToken(); + if ("REM".equalsIgnoreCase(token)) { + continue; + } + } + sql.append(" ").append(line); + + // SQL defines "--" as a comment to EOL + // and in Oracle it may contain a hint + // so we cannot just remove it, instead we must end it + if (line.indexOf("--") >= 0) { + sql.append("\n"); + } + if ((checkStringBufferEndsWith(sql, delimiter))) { + executeSQL(sql.substring(0, sql.length() - delimiter.length()), conn); + sql.replace(0, sql.length(), ""); + } + } + // Catch any statements not followed by ; + if (sql.length() > 0) { + executeSQL(sql.toString(), conn); + } + }catch (IOException e){ + logger.error("Error occurred while executing SQL script for creating Airavata Data Catalog database", e); + throw new Exception("Error occurred while executing SQL script for creating Airavata Data Catalog database", e); + }finally { + if (reader != null) { + reader.close(); + } + } + } + + private static void executeSQL(String sql, Connection conn) throws Exception { + // Check and ignore empty statements + if ("".equals(sql.trim())) { + return; + } + + Statement statement = null; + try { + logger.debug("SQL : " + sql); + + boolean ret; + int updateCount = 0, updateCountTotal = 0; + statement = conn.createStatement(); + ret = statement.execute(sql); + updateCount = statement.getUpdateCount(); + do { + if (!ret) { + if (updateCount != -1) { + updateCountTotal += updateCount; + } + } + ret = statement.getMoreResults(); + if (ret) { + updateCount = statement.getUpdateCount(); + } + } while (ret); + + logger.debug(sql + " : " + updateCountTotal + " rows affected"); + + SQLWarning warning = conn.getWarnings(); + while (warning != null) { + logger.warn(warning + " sql warning"); + warning = warning.getNextWarning(); + } + conn.clearWarnings(); + } catch (SQLException e) { + if (e.getSQLState().equals("X0Y32")) { + // eliminating the table already exception for the derby + // database + logger.info("Table Already Exists", e); + } else { + throw new Exception("Error occurred while executing : " + sql, e); + } + } finally { + if (statement != null) { + try { + statement.close(); + } catch (SQLException e) { + logger.error("Error occurred while closing result set.", e); + } + } + } + } + + private void startDerbyInServerMode() { + try { + System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "true"); + server = new NetworkServerControl(InetAddress.getByName("0.0.0.0"), + 20000, + jdbcUser, jdbcPassword); + java.io.PrintWriter consoleWriter = new java.io.PrintWriter(System.out, true); + server.start(consoleWriter); + } catch (IOException e) { + logger.error("Unable to start Apache derby in the server mode! Check whether " + + "specified port is available"); + } catch (Exception e) { + logger.error("Unable to start Apache derby in the server mode! Check whether " + + "specified port is available"); + } + + } + + public static int getPort(String jdbcURL){ + try{ + String cleanURI = jdbcURL.substring(5); + URI uri = URI.create(cleanURI); + return uri.getPort(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + return -1; + } + } + + private void startDerbyInEmbeddedMode(){ + try { + Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); + DriverManager.getConnection("jdbc:derby:memory:unit-testing-jpa;create=true").close(); + } catch (ClassNotFoundException e) { + logger.error(e.getMessage(), e); + } catch (SQLException e) { + logger.error(e.getMessage(), e); + } + } + + public void stopDerbyServer() { + try { + server.shutdown(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/18cd83c3/airavata-api/airavata-client-sdks/airavata-php-sdk/src/main/resources/lib/Airavata/Model/Data/Replica/Types.php ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-client-sdks/airavata-php-sdk/src/main/resources/lib/Airavata/Model/Data/Replica/Types.php b/airavata-api/airavata-client-sdks/airavata-php-sdk/src/main/resources/lib/Airavata/Model/Data/Replica/Types.php new file mode 100644 index 0000000..a2970ee --- /dev/null +++ b/airavata-api/airavata-client-sdks/airavata-php-sdk/src/main/resources/lib/Airavata/Model/Data/Replica/Types.php @@ -0,0 +1,879 @@ +<?php +namespace Airavata\Model\Data\Replica; + +/** + * Autogenerated by Thrift Compiler (0.9.3) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +use Thrift\Base\TBase; +use Thrift\Type\TType; +use Thrift\Type\TMessageType; +use Thrift\Exception\TException; +use Thrift\Exception\TProtocolException; +use Thrift\Protocol\TProtocol; +use Thrift\Protocol\TBinaryProtocolAccelerated; +use Thrift\Exception\TApplicationException; + + +final class ReplicaLocationCategory { + const GATEWAY_DATA_STORE = 0; + const COMPUTE_RESOURCE = 1; + const LONG_TERM_STORAGE_RESOURCE = 2; + const OTHER = 3; + static public $__names = array( + 0 => 'GATEWAY_DATA_STORE', + 1 => 'COMPUTE_RESOURCE', + 2 => 'LONG_TERM_STORAGE_RESOURCE', + 3 => 'OTHER', + ); +} + +final class ReplicaPersistentType { + const TRANSIENT = 0; + const PERSISTENT = 1; + static public $__names = array( + 0 => 'TRANSIENT', + 1 => 'PERSISTENT', + ); +} + +final class DataProductType { + const DIR = 0; + const FILE = 1; + const COLLECTION = 2; + static public $__names = array( + 0 => 'DIR', + 1 => 'FILE', + 2 => 'COLLECTION', + ); +} + +class DataProductModel { + static $_TSPEC; + + /** + * @var string + */ + public $productUri = null; + /** + * @var string + */ + public $gatewayId = null; + /** + * @var string + */ + public $parentProductUri = null; + /** + * @var string + */ + public $logicalPath = null; + /** + * @var string + */ + public $productName = null; + /** + * @var string + */ + public $productDescription = null; + /** + * @var string + */ + public $ownerName = null; + /** + * @var int + */ + public $dataProductType = null; + /** + * @var int + */ + public $productSize = null; + /** + * @var int + */ + public $creationTime = null; + /** + * @var int + */ + public $lastModifiedTime = null; + /** + * @var array + */ + public $productMetadata = null; + /** + * @var \Airavata\Model\Data\Replica\DataReplicaLocationModel[] + */ + public $replicaLocations = null; + /** + * @var \Airavata\Model\Data\Replica\DataProductModel[] + */ + public $childProducts = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'productUri', + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'gatewayId', + 'type' => TType::STRING, + ), + 3 => array( + 'var' => 'parentProductUri', + 'type' => TType::STRING, + ), + 4 => array( + 'var' => 'logicalPath', + 'type' => TType::STRING, + ), + 5 => array( + 'var' => 'productName', + 'type' => TType::STRING, + ), + 6 => array( + 'var' => 'productDescription', + 'type' => TType::STRING, + ), + 7 => array( + 'var' => 'ownerName', + 'type' => TType::STRING, + ), + 8 => array( + 'var' => 'dataProductType', + 'type' => TType::I32, + ), + 9 => array( + 'var' => 'productSize', + 'type' => TType::I32, + ), + 10 => array( + 'var' => 'creationTime', + 'type' => TType::I64, + ), + 11 => array( + 'var' => 'lastModifiedTime', + 'type' => TType::I64, + ), + 12 => array( + 'var' => 'productMetadata', + 'type' => TType::MAP, + 'ktype' => TType::STRING, + 'vtype' => TType::STRING, + 'key' => array( + 'type' => TType::STRING, + ), + 'val' => array( + 'type' => TType::STRING, + ), + ), + 13 => array( + 'var' => 'replicaLocations', + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\Airavata\Model\Data\Replica\DataReplicaLocationModel', + ), + ), + 14 => array( + 'var' => 'childProducts', + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\Airavata\Model\Data\Replica\DataProductModel', + ), + ), + ); + } + if (is_array($vals)) { + if (isset($vals['productUri'])) { + $this->productUri = $vals['productUri']; + } + if (isset($vals['gatewayId'])) { + $this->gatewayId = $vals['gatewayId']; + } + if (isset($vals['parentProductUri'])) { + $this->parentProductUri = $vals['parentProductUri']; + } + if (isset($vals['logicalPath'])) { + $this->logicalPath = $vals['logicalPath']; + } + if (isset($vals['productName'])) { + $this->productName = $vals['productName']; + } + if (isset($vals['productDescription'])) { + $this->productDescription = $vals['productDescription']; + } + if (isset($vals['ownerName'])) { + $this->ownerName = $vals['ownerName']; + } + if (isset($vals['dataProductType'])) { + $this->dataProductType = $vals['dataProductType']; + } + if (isset($vals['productSize'])) { + $this->productSize = $vals['productSize']; + } + if (isset($vals['creationTime'])) { + $this->creationTime = $vals['creationTime']; + } + if (isset($vals['lastModifiedTime'])) { + $this->lastModifiedTime = $vals['lastModifiedTime']; + } + if (isset($vals['productMetadata'])) { + $this->productMetadata = $vals['productMetadata']; + } + if (isset($vals['replicaLocations'])) { + $this->replicaLocations = $vals['replicaLocations']; + } + if (isset($vals['childProducts'])) { + $this->childProducts = $vals['childProducts']; + } + } + } + + public function getName() { + return 'DataProductModel'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->productUri); + } else { + $xfer += $input->skip($ftype); + } + break; + case 2: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->gatewayId); + } else { + $xfer += $input->skip($ftype); + } + break; + case 3: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->parentProductUri); + } else { + $xfer += $input->skip($ftype); + } + break; + case 4: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->logicalPath); + } else { + $xfer += $input->skip($ftype); + } + break; + case 5: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->productName); + } else { + $xfer += $input->skip($ftype); + } + break; + case 6: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->productDescription); + } else { + $xfer += $input->skip($ftype); + } + break; + case 7: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->ownerName); + } else { + $xfer += $input->skip($ftype); + } + break; + case 8: + if ($ftype == TType::I32) { + $xfer += $input->readI32($this->dataProductType); + } else { + $xfer += $input->skip($ftype); + } + break; + case 9: + if ($ftype == TType::I32) { + $xfer += $input->readI32($this->productSize); + } else { + $xfer += $input->skip($ftype); + } + break; + case 10: + if ($ftype == TType::I64) { + $xfer += $input->readI64($this->creationTime); + } else { + $xfer += $input->skip($ftype); + } + break; + case 11: + if ($ftype == TType::I64) { + $xfer += $input->readI64($this->lastModifiedTime); + } else { + $xfer += $input->skip($ftype); + } + break; + case 12: + if ($ftype == TType::MAP) { + $this->productMetadata = array(); + $_size0 = 0; + $_ktype1 = 0; + $_vtype2 = 0; + $xfer += $input->readMapBegin($_ktype1, $_vtype2, $_size0); + for ($_i4 = 0; $_i4 < $_size0; ++$_i4) + { + $key5 = ''; + $val6 = ''; + $xfer += $input->readString($key5); + $xfer += $input->readString($val6); + $this->productMetadata[$key5] = $val6; + } + $xfer += $input->readMapEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; + case 13: + if ($ftype == TType::LST) { + $this->replicaLocations = array(); + $_size7 = 0; + $_etype10 = 0; + $xfer += $input->readListBegin($_etype10, $_size7); + for ($_i11 = 0; $_i11 < $_size7; ++$_i11) + { + $elem12 = null; + $elem12 = new \Airavata\Model\Data\Replica\DataReplicaLocationModel(); + $xfer += $elem12->read($input); + $this->replicaLocations []= $elem12; + } + $xfer += $input->readListEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; + case 14: + if ($ftype == TType::LST) { + $this->childProducts = array(); + $_size13 = 0; + $_etype16 = 0; + $xfer += $input->readListBegin($_etype16, $_size13); + for ($_i17 = 0; $_i17 < $_size13; ++$_i17) + { + $elem18 = null; + $elem18 = new \Airavata\Model\Data\Replica\DataProductModel(); + $xfer += $elem18->read($input); + $this->childProducts []= $elem18; + } + $xfer += $input->readListEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('DataProductModel'); + if ($this->productUri !== null) { + $xfer += $output->writeFieldBegin('productUri', TType::STRING, 1); + $xfer += $output->writeString($this->productUri); + $xfer += $output->writeFieldEnd(); + } + if ($this->gatewayId !== null) { + $xfer += $output->writeFieldBegin('gatewayId', TType::STRING, 2); + $xfer += $output->writeString($this->gatewayId); + $xfer += $output->writeFieldEnd(); + } + if ($this->parentProductUri !== null) { + $xfer += $output->writeFieldBegin('parentProductUri', TType::STRING, 3); + $xfer += $output->writeString($this->parentProductUri); + $xfer += $output->writeFieldEnd(); + } + if ($this->logicalPath !== null) { + $xfer += $output->writeFieldBegin('logicalPath', TType::STRING, 4); + $xfer += $output->writeString($this->logicalPath); + $xfer += $output->writeFieldEnd(); + } + if ($this->productName !== null) { + $xfer += $output->writeFieldBegin('productName', TType::STRING, 5); + $xfer += $output->writeString($this->productName); + $xfer += $output->writeFieldEnd(); + } + if ($this->productDescription !== null) { + $xfer += $output->writeFieldBegin('productDescription', TType::STRING, 6); + $xfer += $output->writeString($this->productDescription); + $xfer += $output->writeFieldEnd(); + } + if ($this->ownerName !== null) { + $xfer += $output->writeFieldBegin('ownerName', TType::STRING, 7); + $xfer += $output->writeString($this->ownerName); + $xfer += $output->writeFieldEnd(); + } + if ($this->dataProductType !== null) { + $xfer += $output->writeFieldBegin('dataProductType', TType::I32, 8); + $xfer += $output->writeI32($this->dataProductType); + $xfer += $output->writeFieldEnd(); + } + if ($this->productSize !== null) { + $xfer += $output->writeFieldBegin('productSize', TType::I32, 9); + $xfer += $output->writeI32($this->productSize); + $xfer += $output->writeFieldEnd(); + } + if ($this->creationTime !== null) { + $xfer += $output->writeFieldBegin('creationTime', TType::I64, 10); + $xfer += $output->writeI64($this->creationTime); + $xfer += $output->writeFieldEnd(); + } + if ($this->lastModifiedTime !== null) { + $xfer += $output->writeFieldBegin('lastModifiedTime', TType::I64, 11); + $xfer += $output->writeI64($this->lastModifiedTime); + $xfer += $output->writeFieldEnd(); + } + if ($this->productMetadata !== null) { + if (!is_array($this->productMetadata)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('productMetadata', TType::MAP, 12); + { + $output->writeMapBegin(TType::STRING, TType::STRING, count($this->productMetadata)); + { + foreach ($this->productMetadata as $kiter19 => $viter20) + { + $xfer += $output->writeString($kiter19); + $xfer += $output->writeString($viter20); + } + } + $output->writeMapEnd(); + } + $xfer += $output->writeFieldEnd(); + } + if ($this->replicaLocations !== null) { + if (!is_array($this->replicaLocations)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('replicaLocations', TType::LST, 13); + { + $output->writeListBegin(TType::STRUCT, count($this->replicaLocations)); + { + foreach ($this->replicaLocations as $iter21) + { + $xfer += $iter21->write($output); + } + } + $output->writeListEnd(); + } + $xfer += $output->writeFieldEnd(); + } + if ($this->childProducts !== null) { + if (!is_array($this->childProducts)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('childProducts', TType::LST, 14); + { + $output->writeListBegin(TType::STRUCT, count($this->childProducts)); + { + foreach ($this->childProducts as $iter22) + { + $xfer += $iter22->write($output); + } + } + $output->writeListEnd(); + } + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class DataReplicaLocationModel { + static $_TSPEC; + + /** + * @var string + */ + public $replicaId = null; + /** + * @var string + */ + public $productUri = null; + /** + * @var string + */ + public $replicaName = null; + /** + * @var string + */ + public $replicaDescription = null; + /** + * @var int + */ + public $creationTime = null; + /** + * @var int + */ + public $lastModifiedTime = null; + /** + * @var int + */ + public $validUntilTime = null; + /** + * @var int + */ + public $replicaLocationCategory = null; + /** + * @var int + */ + public $replicaPersistentType = null; + /** + * @var string + */ + public $storageResourceId = null; + /** + * @var string + */ + public $filePath = null; + /** + * @var array + */ + public $replicaMetadata = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'replicaId', + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'productUri', + 'type' => TType::STRING, + ), + 3 => array( + 'var' => 'replicaName', + 'type' => TType::STRING, + ), + 4 => array( + 'var' => 'replicaDescription', + 'type' => TType::STRING, + ), + 5 => array( + 'var' => 'creationTime', + 'type' => TType::I64, + ), + 6 => array( + 'var' => 'lastModifiedTime', + 'type' => TType::I64, + ), + 7 => array( + 'var' => 'validUntilTime', + 'type' => TType::I64, + ), + 8 => array( + 'var' => 'replicaLocationCategory', + 'type' => TType::I32, + ), + 9 => array( + 'var' => 'replicaPersistentType', + 'type' => TType::I32, + ), + 10 => array( + 'var' => 'storageResourceId', + 'type' => TType::STRING, + ), + 11 => array( + 'var' => 'filePath', + 'type' => TType::STRING, + ), + 12 => array( + 'var' => 'replicaMetadata', + 'type' => TType::MAP, + 'ktype' => TType::STRING, + 'vtype' => TType::STRING, + 'key' => array( + 'type' => TType::STRING, + ), + 'val' => array( + 'type' => TType::STRING, + ), + ), + ); + } + if (is_array($vals)) { + if (isset($vals['replicaId'])) { + $this->replicaId = $vals['replicaId']; + } + if (isset($vals['productUri'])) { + $this->productUri = $vals['productUri']; + } + if (isset($vals['replicaName'])) { + $this->replicaName = $vals['replicaName']; + } + if (isset($vals['replicaDescription'])) { + $this->replicaDescription = $vals['replicaDescription']; + } + if (isset($vals['creationTime'])) { + $this->creationTime = $vals['creationTime']; + } + if (isset($vals['lastModifiedTime'])) { + $this->lastModifiedTime = $vals['lastModifiedTime']; + } + if (isset($vals['validUntilTime'])) { + $this->validUntilTime = $vals['validUntilTime']; + } + if (isset($vals['replicaLocationCategory'])) { + $this->replicaLocationCategory = $vals['replicaLocationCategory']; + } + if (isset($vals['replicaPersistentType'])) { + $this->replicaPersistentType = $vals['replicaPersistentType']; + } + if (isset($vals['storageResourceId'])) { + $this->storageResourceId = $vals['storageResourceId']; + } + if (isset($vals['filePath'])) { + $this->filePath = $vals['filePath']; + } + if (isset($vals['replicaMetadata'])) { + $this->replicaMetadata = $vals['replicaMetadata']; + } + } + } + + public function getName() { + return 'DataReplicaLocationModel'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->replicaId); + } else { + $xfer += $input->skip($ftype); + } + break; + case 2: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->productUri); + } else { + $xfer += $input->skip($ftype); + } + break; + case 3: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->replicaName); + } else { + $xfer += $input->skip($ftype); + } + break; + case 4: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->replicaDescription); + } else { + $xfer += $input->skip($ftype); + } + break; + case 5: + if ($ftype == TType::I64) { + $xfer += $input->readI64($this->creationTime); + } else { + $xfer += $input->skip($ftype); + } + break; + case 6: + if ($ftype == TType::I64) { + $xfer += $input->readI64($this->lastModifiedTime); + } else { + $xfer += $input->skip($ftype); + } + break; + case 7: + if ($ftype == TType::I64) { + $xfer += $input->readI64($this->validUntilTime); + } else { + $xfer += $input->skip($ftype); + } + break; + case 8: + if ($ftype == TType::I32) { + $xfer += $input->readI32($this->replicaLocationCategory); + } else { + $xfer += $input->skip($ftype); + } + break; + case 9: + if ($ftype == TType::I32) { + $xfer += $input->readI32($this->replicaPersistentType); + } else { + $xfer += $input->skip($ftype); + } + break; + case 10: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->storageResourceId); + } else { + $xfer += $input->skip($ftype); + } + break; + case 11: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->filePath); + } else { + $xfer += $input->skip($ftype); + } + break; + case 12: + if ($ftype == TType::MAP) { + $this->replicaMetadata = array(); + $_size23 = 0; + $_ktype24 = 0; + $_vtype25 = 0; + $xfer += $input->readMapBegin($_ktype24, $_vtype25, $_size23); + for ($_i27 = 0; $_i27 < $_size23; ++$_i27) + { + $key28 = ''; + $val29 = ''; + $xfer += $input->readString($key28); + $xfer += $input->readString($val29); + $this->replicaMetadata[$key28] = $val29; + } + $xfer += $input->readMapEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('DataReplicaLocationModel'); + if ($this->replicaId !== null) { + $xfer += $output->writeFieldBegin('replicaId', TType::STRING, 1); + $xfer += $output->writeString($this->replicaId); + $xfer += $output->writeFieldEnd(); + } + if ($this->productUri !== null) { + $xfer += $output->writeFieldBegin('productUri', TType::STRING, 2); + $xfer += $output->writeString($this->productUri); + $xfer += $output->writeFieldEnd(); + } + if ($this->replicaName !== null) { + $xfer += $output->writeFieldBegin('replicaName', TType::STRING, 3); + $xfer += $output->writeString($this->replicaName); + $xfer += $output->writeFieldEnd(); + } + if ($this->replicaDescription !== null) { + $xfer += $output->writeFieldBegin('replicaDescription', TType::STRING, 4); + $xfer += $output->writeString($this->replicaDescription); + $xfer += $output->writeFieldEnd(); + } + if ($this->creationTime !== null) { + $xfer += $output->writeFieldBegin('creationTime', TType::I64, 5); + $xfer += $output->writeI64($this->creationTime); + $xfer += $output->writeFieldEnd(); + } + if ($this->lastModifiedTime !== null) { + $xfer += $output->writeFieldBegin('lastModifiedTime', TType::I64, 6); + $xfer += $output->writeI64($this->lastModifiedTime); + $xfer += $output->writeFieldEnd(); + } + if ($this->validUntilTime !== null) { + $xfer += $output->writeFieldBegin('validUntilTime', TType::I64, 7); + $xfer += $output->writeI64($this->validUntilTime); + $xfer += $output->writeFieldEnd(); + } + if ($this->replicaLocationCategory !== null) { + $xfer += $output->writeFieldBegin('replicaLocationCategory', TType::I32, 8); + $xfer += $output->writeI32($this->replicaLocationCategory); + $xfer += $output->writeFieldEnd(); + } + if ($this->replicaPersistentType !== null) { + $xfer += $output->writeFieldBegin('replicaPersistentType', TType::I32, 9); + $xfer += $output->writeI32($this->replicaPersistentType); + $xfer += $output->writeFieldEnd(); + } + if ($this->storageResourceId !== null) { + $xfer += $output->writeFieldBegin('storageResourceId', TType::STRING, 10); + $xfer += $output->writeString($this->storageResourceId); + $xfer += $output->writeFieldEnd(); + } + if ($this->filePath !== null) { + $xfer += $output->writeFieldBegin('filePath', TType::STRING, 11); + $xfer += $output->writeString($this->filePath); + $xfer += $output->writeFieldEnd(); + } + if ($this->replicaMetadata !== null) { + if (!is_array($this->replicaMetadata)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('replicaMetadata', TType::MAP, 12); + { + $output->writeMapBegin(TType::STRING, TType::STRING, count($this->replicaMetadata)); + { + foreach ($this->replicaMetadata as $kiter30 => $viter31) + { + $xfer += $output->writeString($kiter30); + $xfer += $output->writeString($viter31); + } + } + $output->writeMapEnd(); + } + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + + http://git-wip-us.apache.org/repos/asf/airavata/blob/18cd83c3/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/data/replica/__init__.py ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/data/replica/__init__.py b/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/data/replica/__init__.py new file mode 100644 index 0000000..adefd8e --- /dev/null +++ b/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/data/replica/__init__.py @@ -0,0 +1 @@ +__all__ = ['ttypes', 'constants'] http://git-wip-us.apache.org/repos/asf/airavata/blob/18cd83c3/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/data/replica/constants.py ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/data/replica/constants.py b/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/data/replica/constants.py new file mode 100644 index 0000000..4a6492b --- /dev/null +++ b/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/data/replica/constants.py @@ -0,0 +1,11 @@ +# +# Autogenerated by Thrift Compiler (0.9.3) +# +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +# +# options string: py +# + +from thrift.Thrift import TType, TMessageType, TException, TApplicationException +from ttypes import * + http://git-wip-us.apache.org/repos/asf/airavata/blob/18cd83c3/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/data/replica/ttypes.py ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/data/replica/ttypes.py b/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/data/replica/ttypes.py new file mode 100644 index 0000000..271b9c0 --- /dev/null +++ b/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/data/replica/ttypes.py @@ -0,0 +1,549 @@ +# +# Autogenerated by Thrift Compiler (0.9.3) +# +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +# +# options string: py +# + +from thrift.Thrift import TType, TMessageType, TException, TApplicationException + +from thrift.transport import TTransport +from thrift.protocol import TBinaryProtocol, TProtocol +try: + from thrift.protocol import fastbinary +except: + fastbinary = None + + +class ReplicaLocationCategory: + GATEWAY_DATA_STORE = 0 + COMPUTE_RESOURCE = 1 + LONG_TERM_STORAGE_RESOURCE = 2 + OTHER = 3 + + _VALUES_TO_NAMES = { + 0: "GATEWAY_DATA_STORE", + 1: "COMPUTE_RESOURCE", + 2: "LONG_TERM_STORAGE_RESOURCE", + 3: "OTHER", + } + + _NAMES_TO_VALUES = { + "GATEWAY_DATA_STORE": 0, + "COMPUTE_RESOURCE": 1, + "LONG_TERM_STORAGE_RESOURCE": 2, + "OTHER": 3, + } + +class ReplicaPersistentType: + TRANSIENT = 0 + PERSISTENT = 1 + + _VALUES_TO_NAMES = { + 0: "TRANSIENT", + 1: "PERSISTENT", + } + + _NAMES_TO_VALUES = { + "TRANSIENT": 0, + "PERSISTENT": 1, + } + +class DataProductType: + DIR = 0 + FILE = 1 + COLLECTION = 2 + + _VALUES_TO_NAMES = { + 0: "DIR", + 1: "FILE", + 2: "COLLECTION", + } + + _NAMES_TO_VALUES = { + "DIR": 0, + "FILE": 1, + "COLLECTION": 2, + } + + +class DataProductModel: + """ + Attributes: + - productUri + - gatewayId + - parentProductUri + - logicalPath + - productName + - productDescription + - ownerName + - dataProductType + - productSize + - creationTime + - lastModifiedTime + - productMetadata + - replicaLocations + - childProducts + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'productUri', None, None, ), # 1 + (2, TType.STRING, 'gatewayId', None, None, ), # 2 + (3, TType.STRING, 'parentProductUri', None, None, ), # 3 + (4, TType.STRING, 'logicalPath', None, None, ), # 4 + (5, TType.STRING, 'productName', None, None, ), # 5 + (6, TType.STRING, 'productDescription', None, None, ), # 6 + (7, TType.STRING, 'ownerName', None, None, ), # 7 + (8, TType.I32, 'dataProductType', None, None, ), # 8 + (9, TType.I32, 'productSize', None, None, ), # 9 + (10, TType.I64, 'creationTime', None, None, ), # 10 + (11, TType.I64, 'lastModifiedTime', None, None, ), # 11 + (12, TType.MAP, 'productMetadata', (TType.STRING,None,TType.STRING,None), None, ), # 12 + (13, TType.LIST, 'replicaLocations', (TType.STRUCT,(DataReplicaLocationModel, DataReplicaLocationModel.thrift_spec)), None, ), # 13 + (14, TType.LIST, 'childProducts', (TType.STRUCT,(DataProductModel, DataProductModel.thrift_spec)), None, ), # 14 + ) + + def __init__(self, productUri=None, gatewayId=None, parentProductUri=None, logicalPath=None, productName=None, productDescription=None, ownerName=None, dataProductType=None, productSize=None, creationTime=None, lastModifiedTime=None, productMetadata=None, replicaLocations=None, childProducts=None,): + self.productUri = productUri + self.gatewayId = gatewayId + self.parentProductUri = parentProductUri + self.logicalPath = logicalPath + self.productName = productName + self.productDescription = productDescription + self.ownerName = ownerName + self.dataProductType = dataProductType + self.productSize = productSize + self.creationTime = creationTime + self.lastModifiedTime = lastModifiedTime + self.productMetadata = productMetadata + self.replicaLocations = replicaLocations + self.childProducts = childProducts + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.productUri = iprot.readString() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.gatewayId = iprot.readString() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRING: + self.parentProductUri = iprot.readString() + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.STRING: + self.logicalPath = iprot.readString() + else: + iprot.skip(ftype) + elif fid == 5: + if ftype == TType.STRING: + self.productName = iprot.readString() + else: + iprot.skip(ftype) + elif fid == 6: + if ftype == TType.STRING: + self.productDescription = iprot.readString() + else: + iprot.skip(ftype) + elif fid == 7: + if ftype == TType.STRING: + self.ownerName = iprot.readString() + else: + iprot.skip(ftype) + elif fid == 8: + if ftype == TType.I32: + self.dataProductType = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 9: + if ftype == TType.I32: + self.productSize = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 10: + if ftype == TType.I64: + self.creationTime = iprot.readI64() + else: + iprot.skip(ftype) + elif fid == 11: + if ftype == TType.I64: + self.lastModifiedTime = iprot.readI64() + else: + iprot.skip(ftype) + elif fid == 12: + if ftype == TType.MAP: + self.productMetadata = {} + (_ktype1, _vtype2, _size0 ) = iprot.readMapBegin() + for _i4 in xrange(_size0): + _key5 = iprot.readString() + _val6 = iprot.readString() + self.productMetadata[_key5] = _val6 + iprot.readMapEnd() + else: + iprot.skip(ftype) + elif fid == 13: + if ftype == TType.LIST: + self.replicaLocations = [] + (_etype10, _size7) = iprot.readListBegin() + for _i11 in xrange(_size7): + _elem12 = DataReplicaLocationModel() + _elem12.read(iprot) + self.replicaLocations.append(_elem12) + iprot.readListEnd() + else: + iprot.skip(ftype) + elif fid == 14: + if ftype == TType.LIST: + self.childProducts = [] + (_etype16, _size13) = iprot.readListBegin() + for _i17 in xrange(_size13): + _elem18 = DataProductModel() + _elem18.read(iprot) + self.childProducts.append(_elem18) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('DataProductModel') + if self.productUri is not None: + oprot.writeFieldBegin('productUri', TType.STRING, 1) + oprot.writeString(self.productUri) + oprot.writeFieldEnd() + if self.gatewayId is not None: + oprot.writeFieldBegin('gatewayId', TType.STRING, 2) + oprot.writeString(self.gatewayId) + oprot.writeFieldEnd() + if self.parentProductUri is not None: + oprot.writeFieldBegin('parentProductUri', TType.STRING, 3) + oprot.writeString(self.parentProductUri) + oprot.writeFieldEnd() + if self.logicalPath is not None: + oprot.writeFieldBegin('logicalPath', TType.STRING, 4) + oprot.writeString(self.logicalPath) + oprot.writeFieldEnd() + if self.productName is not None: + oprot.writeFieldBegin('productName', TType.STRING, 5) + oprot.writeString(self.productName) + oprot.writeFieldEnd() + if self.productDescription is not None: + oprot.writeFieldBegin('productDescription', TType.STRING, 6) + oprot.writeString(self.productDescription) + oprot.writeFieldEnd() + if self.ownerName is not None: + oprot.writeFieldBegin('ownerName', TType.STRING, 7) + oprot.writeString(self.ownerName) + oprot.writeFieldEnd() + if self.dataProductType is not None: + oprot.writeFieldBegin('dataProductType', TType.I32, 8) + oprot.writeI32(self.dataProductType) + oprot.writeFieldEnd() + if self.productSize is not None: + oprot.writeFieldBegin('productSize', TType.I32, 9) + oprot.writeI32(self.productSize) + oprot.writeFieldEnd() + if self.creationTime is not None: + oprot.writeFieldBegin('creationTime', TType.I64, 10) + oprot.writeI64(self.creationTime) + oprot.writeFieldEnd() + if self.lastModifiedTime is not None: + oprot.writeFieldBegin('lastModifiedTime', TType.I64, 11) + oprot.writeI64(self.lastModifiedTime) + oprot.writeFieldEnd() + if self.productMetadata is not None: + oprot.writeFieldBegin('productMetadata', TType.MAP, 12) + oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.productMetadata)) + for kiter19,viter20 in self.productMetadata.items(): + oprot.writeString(kiter19) + oprot.writeString(viter20) + oprot.writeMapEnd() + oprot.writeFieldEnd() + if self.replicaLocations is not None: + oprot.writeFieldBegin('replicaLocations', TType.LIST, 13) + oprot.writeListBegin(TType.STRUCT, len(self.replicaLocations)) + for iter21 in self.replicaLocations: + iter21.write(oprot) + oprot.writeListEnd() + oprot.writeFieldEnd() + if self.childProducts is not None: + oprot.writeFieldBegin('childProducts', TType.LIST, 14) + oprot.writeListBegin(TType.STRUCT, len(self.childProducts)) + for iter22 in self.childProducts: + iter22.write(oprot) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __hash__(self): + value = 17 + value = (value * 31) ^ hash(self.productUri) + value = (value * 31) ^ hash(self.gatewayId) + value = (value * 31) ^ hash(self.parentProductUri) + value = (value * 31) ^ hash(self.logicalPath) + value = (value * 31) ^ hash(self.productName) + value = (value * 31) ^ hash(self.productDescription) + value = (value * 31) ^ hash(self.ownerName) + value = (value * 31) ^ hash(self.dataProductType) + value = (value * 31) ^ hash(self.productSize) + value = (value * 31) ^ hash(self.creationTime) + value = (value * 31) ^ hash(self.lastModifiedTime) + value = (value * 31) ^ hash(self.productMetadata) + value = (value * 31) ^ hash(self.replicaLocations) + value = (value * 31) ^ hash(self.childProducts) + return value + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class DataReplicaLocationModel: + """ + Attributes: + - replicaId + - productUri + - replicaName + - replicaDescription + - creationTime + - lastModifiedTime + - validUntilTime + - replicaLocationCategory + - replicaPersistentType + - storageResourceId + - filePath + - replicaMetadata + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'replicaId', None, None, ), # 1 + (2, TType.STRING, 'productUri', None, None, ), # 2 + (3, TType.STRING, 'replicaName', None, None, ), # 3 + (4, TType.STRING, 'replicaDescription', None, None, ), # 4 + (5, TType.I64, 'creationTime', None, None, ), # 5 + (6, TType.I64, 'lastModifiedTime', None, None, ), # 6 + (7, TType.I64, 'validUntilTime', None, None, ), # 7 + (8, TType.I32, 'replicaLocationCategory', None, None, ), # 8 + (9, TType.I32, 'replicaPersistentType', None, None, ), # 9 + (10, TType.STRING, 'storageResourceId', None, None, ), # 10 + (11, TType.STRING, 'filePath', None, None, ), # 11 + (12, TType.MAP, 'replicaMetadata', (TType.STRING,None,TType.STRING,None), None, ), # 12 + ) + + def __init__(self, replicaId=None, productUri=None, replicaName=None, replicaDescription=None, creationTime=None, lastModifiedTime=None, validUntilTime=None, replicaLocationCategory=None, replicaPersistentType=None, storageResourceId=None, filePath=None, replicaMetadata=None,): + self.replicaId = replicaId + self.productUri = productUri + self.replicaName = replicaName + self.replicaDescription = replicaDescription + self.creationTime = creationTime + self.lastModifiedTime = lastModifiedTime + self.validUntilTime = validUntilTime + self.replicaLocationCategory = replicaLocationCategory + self.replicaPersistentType = replicaPersistentType + self.storageResourceId = storageResourceId + self.filePath = filePath + self.replicaMetadata = replicaMetadata + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.replicaId = iprot.readString() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.productUri = iprot.readString() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRING: + self.replicaName = iprot.readString() + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.STRING: + self.replicaDescription = iprot.readString() + else: + iprot.skip(ftype) + elif fid == 5: + if ftype == TType.I64: + self.creationTime = iprot.readI64() + else: + iprot.skip(ftype) + elif fid == 6: + if ftype == TType.I64: + self.lastModifiedTime = iprot.readI64() + else: + iprot.skip(ftype) + elif fid == 7: + if ftype == TType.I64: + self.validUntilTime = iprot.readI64() + else: + iprot.skip(ftype) + elif fid == 8: + if ftype == TType.I32: + self.replicaLocationCategory = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 9: + if ftype == TType.I32: + self.replicaPersistentType = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 10: + if ftype == TType.STRING: + self.storageResourceId = iprot.readString() + else: + iprot.skip(ftype) + elif fid == 11: + if ftype == TType.STRING: + self.filePath = iprot.readString() + else: + iprot.skip(ftype) + elif fid == 12: + if ftype == TType.MAP: + self.replicaMetadata = {} + (_ktype24, _vtype25, _size23 ) = iprot.readMapBegin() + for _i27 in xrange(_size23): + _key28 = iprot.readString() + _val29 = iprot.readString() + self.replicaMetadata[_key28] = _val29 + iprot.readMapEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('DataReplicaLocationModel') + if self.replicaId is not None: + oprot.writeFieldBegin('replicaId', TType.STRING, 1) + oprot.writeString(self.replicaId) + oprot.writeFieldEnd() + if self.productUri is not None: + oprot.writeFieldBegin('productUri', TType.STRING, 2) + oprot.writeString(self.productUri) + oprot.writeFieldEnd() + if self.replicaName is not None: + oprot.writeFieldBegin('replicaName', TType.STRING, 3) + oprot.writeString(self.replicaName) + oprot.writeFieldEnd() + if self.replicaDescription is not None: + oprot.writeFieldBegin('replicaDescription', TType.STRING, 4) + oprot.writeString(self.replicaDescription) + oprot.writeFieldEnd() + if self.creationTime is not None: + oprot.writeFieldBegin('creationTime', TType.I64, 5) + oprot.writeI64(self.creationTime) + oprot.writeFieldEnd() + if self.lastModifiedTime is not None: + oprot.writeFieldBegin('lastModifiedTime', TType.I64, 6) + oprot.writeI64(self.lastModifiedTime) + oprot.writeFieldEnd() + if self.validUntilTime is not None: + oprot.writeFieldBegin('validUntilTime', TType.I64, 7) + oprot.writeI64(self.validUntilTime) + oprot.writeFieldEnd() + if self.replicaLocationCategory is not None: + oprot.writeFieldBegin('replicaLocationCategory', TType.I32, 8) + oprot.writeI32(self.replicaLocationCategory) + oprot.writeFieldEnd() + if self.replicaPersistentType is not None: + oprot.writeFieldBegin('replicaPersistentType', TType.I32, 9) + oprot.writeI32(self.replicaPersistentType) + oprot.writeFieldEnd() + if self.storageResourceId is not None: + oprot.writeFieldBegin('storageResourceId', TType.STRING, 10) + oprot.writeString(self.storageResourceId) + oprot.writeFieldEnd() + if self.filePath is not None: + oprot.writeFieldBegin('filePath', TType.STRING, 11) + oprot.writeString(self.filePath) + oprot.writeFieldEnd() + if self.replicaMetadata is not None: + oprot.writeFieldBegin('replicaMetadata', TType.MAP, 12) + oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.replicaMetadata)) + for kiter30,viter31 in self.replicaMetadata.items(): + oprot.writeString(kiter30) + oprot.writeString(viter31) + oprot.writeMapEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __hash__(self): + value = 17 + value = (value * 31) ^ hash(self.replicaId) + value = (value * 31) ^ hash(self.productUri) + value = (value * 31) ^ hash(self.replicaName) + value = (value * 31) ^ hash(self.replicaDescription) + value = (value * 31) ^ hash(self.creationTime) + value = (value * 31) ^ hash(self.lastModifiedTime) + value = (value * 31) ^ hash(self.validUntilTime) + value = (value * 31) ^ hash(self.replicaLocationCategory) + value = (value * 31) ^ hash(self.replicaPersistentType) + value = (value * 31) ^ hash(self.storageResourceId) + value = (value * 31) ^ hash(self.filePath) + value = (value * 31) ^ hash(self.replicaMetadata) + return value + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) http://git-wip-us.apache.org/repos/asf/airavata/blob/18cd83c3/modules/configuration/server/src/main/resources/airavata-server.properties ---------------------------------------------------------------------- diff --git a/modules/configuration/server/src/main/resources/airavata-server.properties b/modules/configuration/server/src/main/resources/airavata-server.properties index e915c64..22769dc 100644 --- a/modules/configuration/server/src/main/resources/airavata-server.properties +++ b/modules/configuration/server/src/main/resources/airavata-server.properties @@ -67,14 +67,14 @@ appcatalog.validationQuery=SELECT 1 from CONFIGURATION # Data Catalog DB Configuration ########################################################################### #for derby [AiravataJPARegistry] -datacatalog.jdbc.driver=org.apache.derby.jdbc.ClientDriver -datacatalog.jdbc.url=jdbc:derby://localhost:1527/data_catalog;create=true;user=airavata;password=airavata +replicacatalog.jdbc.driver=org.apache.derby.jdbc.ClientDriver +replicacatalog.jdbc.url=jdbc:derby://localhost:1527/data_catalog;create=true;user=airavata;password=airavata # MySql database configuration -#datacatalog.jdbc.driver=com.mysql.jdbc.Driver -#datacatalog.jdbc.url=jdbc:mysql://localhost:3306/data_catalog -datacatalog.jdbc.user=airavata -datacatalog.jdbc.password=airavata -datacatalog.validationQuery=SELECT 1 from CONFIGURATION +#replicacatalog.jdbc.driver=com.mysql.jdbc.Driver +#replicacatalog.jdbc.url=jdbc:mysql://localhost:3306/data_catalog +replicacatalog.jdbc.user=airavata +replicacatalog.jdbc.password=airavata +replicacatalog.validationQuery=SELECT 1 from CONFIGURATION ########################################################################### # Workflow Catalog DB Configuration http://git-wip-us.apache.org/repos/asf/airavata/blob/18cd83c3/modules/credential-store/credential-store-service/src/test/resources/airavata-server.properties ---------------------------------------------------------------------- diff --git a/modules/credential-store/credential-store-service/src/test/resources/airavata-server.properties b/modules/credential-store/credential-store-service/src/test/resources/airavata-server.properties index b783542..b9a4ea4 100644 --- a/modules/credential-store/credential-store-service/src/test/resources/airavata-server.properties +++ b/modules/credential-store/credential-store-service/src/test/resources/airavata-server.properties @@ -69,14 +69,14 @@ appcatalog.validationQuery=SELECT 1 from CONFIGURATION # Replica Catalog DB Configuration ########################################################################### #for derby [AiravataJPARegistry] -datacatalog.jdbc.driver=org.apache.derby.jdbc.ClientDriver -datacatalog.jdbc.url=jdbc:derby://localhost:1527/replica_catalog;create=true;user=airavata;password=airavata +replicacatalog.jdbc.driver=org.apache.derby.jdbc.ClientDriver +replicacatalog.jdbc.url=jdbc:derby://localhost:1527/replica_catalog;create=true;user=airavata;password=airavata # MySql database configuration -#datacatalog.jdbc.driver=com.mysql.jdbc.Driver -#datacatalog.jdbc.url=jdbc:mysql://localhost:3306/data_catalog -datacatalog.jdbc.user=airavata -datacatalog.jdbc.password=airavata -datacatalog.validationQuery=SELECT 1 from CONFIGURATION +#replicacatalog.jdbc.driver=com.mysql.jdbc.Driver +#replicacatalog.jdbc.url=jdbc:mysql://localhost:3306/data_catalog +replicacatalog.jdbc.user=airavata +replicacatalog.jdbc.password=airavata +replicacatalog.validationQuery=SELECT 1 from CONFIGURATION ########################################################################### # Server module Configuration http://git-wip-us.apache.org/repos/asf/airavata/blob/18cd83c3/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/impl/ReplicaCatalogImpl.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/impl/ReplicaCatalogImpl.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/impl/ReplicaCatalogImpl.java index 6a9a4fd..3e4c835 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/impl/ReplicaCatalogImpl.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/impl/ReplicaCatalogImpl.java @@ -59,12 +59,16 @@ public class ReplicaCatalogImpl implements ReplicaCatalog { //Creating parent logical dir if not exist too String parentUri = ReplicaCatalog.schema + "://" + productModel.getOwnerName() + "@" + productModel.getGatewayId() + ":/" ; DataProductModel tempDp; + final long currentTime = System.currentTimeMillis(); if(!isExists(parentUri)){ tempDp = new DataProductModel(); tempDp.setProductUri(parentUri); tempDp.setLogicalPath("/"); tempDp.setOwnerName(productModel.getOwnerName()); tempDp.setGatewayId(productModel.getGatewayId()); + tempDp.setProductName("/"); + tempDp.setCreationTime(currentTime); + tempDp.setLastModifiedTime(currentTime); tempDp.setDataProductType(DataProductType.DIR); createDataProduct(tempDp); } @@ -73,8 +77,8 @@ public class ReplicaCatalogImpl implements ReplicaCatalog { String dir = bits[i]; if(!isExists(parentUri + dir)){ tempDp = new DataProductModel(); - if(!parentUri.endsWith("/")) parentUri += "/"; try { + if(!parentUri.endsWith("/")) dir = "/" + dir; tempDp.setLogicalPath((new URI(parentUri + dir)).getPath()); } catch (URISyntaxException e) { throw new ReplicaCatalogException(e); @@ -82,6 +86,9 @@ public class ReplicaCatalogImpl implements ReplicaCatalog { tempDp.setProductUri(parentUri + dir); tempDp.setOwnerName(productModel.getOwnerName()); tempDp.setGatewayId(productModel.getGatewayId()); + tempDp.setProductName(dir.substring(1)); + tempDp.setCreationTime(currentTime); + tempDp.setLastModifiedTime(currentTime); tempDp.setDataProductType(DataProductType.DIR); tempDp.setParentProductUri(parentUri); parentUri = createDataProduct(tempDp); @@ -92,7 +99,6 @@ public class ReplicaCatalogImpl implements ReplicaCatalog { String productUri = ReplicaCatalog.schema + "://" + productModel.getOwnerName() + "@" + productModel.getGatewayId() + ":" + productModel.getLogicalPath(); productModel.setProductUri(productUri); - long currentTime = System.currentTimeMillis(); productModel.setCreationTime(currentTime); productModel.setLastModifiedTime(currentTime); if(productModel.getReplicaLocations() != null){ http://git-wip-us.apache.org/repos/asf/airavata/blob/18cd83c3/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/model/DataProduct.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/model/DataProduct.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/model/DataProduct.java index 7a48f87..8052c2b 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/model/DataProduct.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/model/DataProduct.java @@ -166,7 +166,7 @@ public class DataProduct { this.dataProductMetaData = dataProductMetaData; } - @ManyToOne + @ManyToOne(optional = true) @JoinColumn(name = "PARENT_PRODUCT_URI", referencedColumnName = "PRODUCT_URI") public DataProduct getParentDataProduct() { return parentDataProduct; http://git-wip-us.apache.org/repos/asf/airavata/blob/18cd83c3/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/utils/ReplicaCatalogJPAUtils.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/utils/ReplicaCatalogJPAUtils.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/utils/ReplicaCatalogJPAUtils.java index 21b3e17..d269ccc 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/utils/ReplicaCatalogJPAUtils.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/utils/ReplicaCatalogJPAUtils.java @@ -33,26 +33,26 @@ import java.util.Map; public class ReplicaCatalogJPAUtils { private final static Logger logger = LoggerFactory.getLogger(ReplicaCatalogJPAUtils.class); - private static final String PERSISTENCE_UNIT_NAME = "datacatalog_data"; - private static final String DATACATALOG_JDBC_DRIVER = "datacatalog.jdbc.driver"; - private static final String DATACATALOG_JDBC_URL = "datacatalog.jdbc.url"; - private static final String DATACATALOG_JDBC_USER = "datacatalog.jdbc.user"; - private static final String DATACATALOG_JDBC_PWD = "datacatalog.jdbc.password"; - private static final String DATACATALOG_VALIDATION_QUERY = "datacatalog.validationQuery"; + private static final String PERSISTENCE_UNIT_NAME = "replicacatalog_data"; + private static final String REPLICACATALOG_JDBC_DRIVER = "replicacatalog.jdbc.driver"; + private static final String REPLICACATALOG_JDBC_URL = "replicacatalog.jdbc.url"; + private static final String REPLICACATALOG_JDBC_USER = "replicacatalog.jdbc.user"; + private static final String REPLICACATALOG_JDBC_PWD = "replicacatalog.jdbc.password"; + private static final String REPLICACATALOG_VALIDATION_QUERY = "replicacatalog.validationQuery"; - @PersistenceUnit(unitName="datacatalog_data") + @PersistenceUnit(unitName="replicacatalog_data") protected static EntityManagerFactory factory; - @PersistenceContext(unitName="datacatalog_data") + @PersistenceContext(unitName="replicacatalog_data") private static EntityManager dataCatEntityManager; public static EntityManager getEntityManager() throws ApplicationSettingsException { if (factory == null) { - String connectionProperties = "DriverClassName=" + readServerProperties(DATACATALOG_JDBC_DRIVER) + "," + - "Url=" + readServerProperties(DATACATALOG_JDBC_URL) + "?autoReconnect=true," + - "Username=" + readServerProperties(DATACATALOG_JDBC_USER) + "," + - "Password=" + readServerProperties(DATACATALOG_JDBC_PWD) + - ",validationQuery=" + readServerProperties(DATACATALOG_VALIDATION_QUERY); + String connectionProperties = "DriverClassName=" + readServerProperties(REPLICACATALOG_JDBC_DRIVER) + "," + + "Url=" + readServerProperties(REPLICACATALOG_JDBC_URL) + "?autoReconnect=true," + + "Username=" + readServerProperties(REPLICACATALOG_JDBC_USER) + "," + + "Password=" + readServerProperties(REPLICACATALOG_JDBC_PWD) + + ",validationQuery=" + readServerProperties(REPLICACATALOG_VALIDATION_QUERY); System.out.println(connectionProperties); Map<String, String> properties = new HashMap<String, String>(); properties.put("openjpa.ConnectionDriverName", "org.apache.commons.dbcp.BasicDataSource"); http://git-wip-us.apache.org/repos/asf/airavata/blob/18cd83c3/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/utils/ThriftDataModelConversion.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/utils/ThriftDataModelConversion.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/utils/ThriftDataModelConversion.java index ece579c..676f84b 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/utils/ThriftDataModelConversion.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/utils/ThriftDataModelConversion.java @@ -65,7 +65,7 @@ public class ThriftDataModelConversion { .add(getDataReplicaLocationModel(r))); dataProductModel.setReplicaLocations(dataReplicaLocationModels); } - if(dataProductModel.getDataProductType().equals(DataProductType.COLLECTION) && dataProduct.getChildDataProducts() != null){ + if(!dataProductModel.getDataProductType().equals(DataProductType.FILE) && dataProduct.getChildDataProducts() != null){ ArrayList<DataProductModel> childDataProducts = new ArrayList<>(); dataProduct.getChildDataProducts().stream().forEach(r->childDataProducts.add(getDataProductModel(r))); dataProductModel.setChildProducts(childDataProducts);
