Search in sources :

Example 1 with DataProductMetaData

use of org.apache.airavata.registry.core.replica.catalog.model.DataProductMetaData in project airavata by apache.

the class ThriftDataModelConversion method getUpdatedDataProduct.

public static DataProduct getUpdatedDataProduct(DataProductModel dataProductModel, DataProduct dataProduct) {
    dataProduct.setProductUri(dataProductModel.getProductUri());
    dataProduct.setGatewayId(dataProductModel.getGatewayId());
    dataProduct.setProductName(dataProductModel.getProductName());
    dataProduct.setParentProductUri(dataProductModel.getParentProductUri());
    if (dataProductModel.getDataProductType() != null)
        dataProduct.setDataProductType(dataProductModel.getDataProductType().toString());
    else
        dataProduct.setDataProductType(DataProductType.FILE.toString());
    dataProduct.setProductDescription(dataProductModel.getProductDescription());
    dataProduct.setOwnerName(dataProductModel.getOwnerName());
    dataProduct.setProductSize(dataProductModel.getProductSize());
    if (dataProductModel.getCreationTime() > 0)
        dataProduct.setCreationTime(new Timestamp(dataProductModel.getCreationTime()));
    if (dataProductModel.getLastModifiedTime() > 0)
        dataProduct.setLastModifiedTime(new Timestamp(dataProductModel.getLastModifiedTime()));
    ArrayList<DataProductMetaData> dataProductMetaData = new ArrayList<>();
    if (dataProductModel.getProductMetadata() != null) {
        dataProductModel.getProductMetadata().keySet().stream().forEach(k -> {
            String v = dataProductModel.getProductMetadata().get(k);
            DataProductMetaData temp = new DataProductMetaData();
            temp.setProductUri(dataProduct.getProductUri());
            temp.setKey(k);
            temp.setValue(v);
            dataProductMetaData.add(temp);
        });
        dataProduct.setDataProductMetaData(dataProductMetaData);
    }
    if (dataProductModel.getReplicaLocations() != null) {
        ArrayList<DataReplicaLocation> dataReplicaLocations = new ArrayList<>();
        dataProductModel.getReplicaLocations().stream().forEach(r -> {
            DataReplicaLocation dataReplicaLocationModel = getDataReplicaLocation(r);
            dataReplicaLocationModel.setProductUri(dataProductModel.getProductUri());
            dataReplicaLocations.add(dataReplicaLocationModel);
        });
        dataProduct.setDataReplicaLocations(dataReplicaLocations);
    }
    return dataProduct;
}
Also used : DataProductMetaData(org.apache.airavata.registry.core.replica.catalog.model.DataProductMetaData) ArrayList(java.util.ArrayList) DataReplicaLocation(org.apache.airavata.registry.core.replica.catalog.model.DataReplicaLocation) Timestamp(java.sql.Timestamp)

Aggregations

Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1 DataProductMetaData (org.apache.airavata.registry.core.replica.catalog.model.DataProductMetaData)1 DataReplicaLocation (org.apache.airavata.registry.core.replica.catalog.model.DataReplicaLocation)1