Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/proseo-1.0.1-HOTFIX2' into dev-d…
Browse files Browse the repository at this point in the history
…enys
  • Loading branch information
DenChaykovskiy committed Sep 16, 2024
2 parents 135542b + 807ec0e commit ca61aba
Show file tree
Hide file tree
Showing 12 changed files with 491 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -408,13 +408,13 @@ private RestProduct findLocalProductAtFacility(List<Product> modelProducts, Rest

// Get sensing start and stop times and generation time to check against
Instant sensingStartTime = OrbitTimeFormatter.parseDateTime(restProduct.getSensingStartTime());
Instant sensingStopTime = OrbitTimeFormatter.parseDateTime(restProduct.getSensingStopTime());
// Instant sensingStopTime = OrbitTimeFormatter.parseDateTime(restProduct.getSensingStopTime());
Instant generationTime = OrbitTimeFormatter.parseDateTime(restProduct.getGenerationTime());

// Travel through the list of products
for (Product modelProduct: modelProducts) {
if (sensingStartTime.equals(modelProduct.getSensingStartTime())
&& sensingStopTime.equals(modelProduct.getSensingStopTime())
// && sensingStopTime.equals(modelProduct.getSensingStopTime())
&& generationTime.equals(modelProduct.getGenerationTime())) {

// Candidate product found, check product files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1210,13 +1210,15 @@ public List<Product> findProductsByClassAndStartStop(String productType, Instant

try {
@SuppressWarnings("unchecked")
List<RestProduct> restProducts = (List<RestProduct>) serviceConnection.getFromService(config.getAipUrl(),
List<Map<String, Object>> restProductList = (List<Map<String, Object>>) serviceConnection.getFromService(config.getAipUrl(),
URI_PATH_DOWNLOAD_ALLBYTIME + "?productType=" + productType + "&startTime=" + OrbitTimeFormatter.format(start)
+ "&stopTime=" + OrbitTimeFormatter.format(stop) + "&facility=" + config.getFacility(),
RestProduct.class, securityConfig.getMission() + "-" + securityConfig.getUser(), securityConfig.getPassword());
if (restProducts != null) {
for (RestProduct restProduct : restProducts) {
products.add(ProductUtil.toModelProduct(restProduct));
List.class, securityConfig.getMission() + "-" + securityConfig.getUser(), securityConfig.getPassword());
if (logger.isTraceEnabled())
logger.trace(">>> restProductList: ", restProductList);
if (restProductList != null) {
for (Map<String, Object> restProductMap : restProductList) {
products.add(ProductUtil.toModelProduct(restProductMap));
}
}
} catch (HttpClientErrorException e) {
Expand Down
159 changes: 159 additions & 0 deletions api/odip/src/main/java/de/dlr/proseo/api/odip/util/ProductUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import java.time.DateTimeException;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import de.dlr.proseo.logging.logger.ProseoLogger;
Expand Down Expand Up @@ -174,4 +176,161 @@ public static Product toModelProduct(RestProduct restProduct) throws IllegalArgu
return modelProduct;
}

/**
* Convert a REST product represented as map into a prosEO model product (scalar and embedded attributes only, no object references); does not
* create or update the download history.
*
* @param restProductMap the REST product map
* @return a (roughly) equivalent model product or null, if no REST product map was given
* @throws IllegalArgumentException if the REST product map violates syntax rules for date, enum or numeric values
*/
@SuppressWarnings("unchecked")
public static Product toModelProduct(Map<String, Object> restProductMap) throws IllegalArgumentException {
if (logger.isTraceEnabled())
logger.trace(">>> restProductMap({})", (null == restProductMap ? "MISSING" : restProductMap));

if (logger.isTraceEnabled())
logger.trace(">>> toModelProduct({})", (null == restProductMap ? "MISSING" : restProductMap.get("productClass")));

if (null == restProductMap)
return null;

Product modelProduct = new Product();
Long id = 0L;
if (null != restProductMap.get("id")) {
id = ((Integer)(restProductMap.get("id"))).longValue();
}
if (0 != id) {
modelProduct.setId(id);
while (modelProduct.getVersion() < (Integer)(restProductMap.get("version"))) {
modelProduct.incrementVersion();
}
}

if (null != restProductMap.get("uuid")) {
try {
modelProduct.setUuid(UUID.fromString((String)(restProductMap.get("uuid"))));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(logger.log(IngestorMessage.PRODUCT_UUID_INVALID, (String)(restProductMap.get("uuid"))));
}
}

modelProduct.setFileClass((String)(restProductMap.get("fileClass")));
modelProduct.setMode((String)(restProductMap.get("mode")));

if (null != restProductMap.get("productQuality")) {
modelProduct.setProductQuality(ProductQuality.valueOf((String)(restProductMap.get("productQuality"))));
}

try {
modelProduct.setSensingStartTime(Instant.from(OrbitTimeFormatter.parse((String)(restProductMap.get("sensingStartTime")))));
} catch (DateTimeException e) {
throw new IllegalArgumentException(
logger.log(IngestorMessage.INVALID_SENSING_START_TIME, (String)(restProductMap.get("sensingStartTime"))));
}

try {
modelProduct.setSensingStopTime(Instant.from(OrbitTimeFormatter.parse((String)(restProductMap.get("sensingStopTime")))));
} catch (DateTimeException e) {
throw new IllegalArgumentException(
logger.log(IngestorMessage.INVALID_SENSING_STOP_TIME, (String)(restProductMap.get("sensingStopTime"))));
}

if (null == restProductMap.get("rawDataAvailabilityTime")) {
modelProduct.setRawDataAvailabilityTime(null);
} else {
try {
modelProduct
.setRawDataAvailabilityTime(Instant.from(OrbitTimeFormatter.parse((String)(restProductMap.get("rawDataAvailabilityTime")))));
} catch (DateTimeException e) {
throw new IllegalArgumentException(
logger.log(IngestorMessage.INVALID_RAW_DATA_AVAILABILITY_TIME, (String)(restProductMap.get("rawDataAvailabilityTime"))));
}
}

try {
modelProduct.setGenerationTime(Instant.from(OrbitTimeFormatter.parse((String)(restProductMap.get("generationTime")))));
} catch (DateTimeException e) {
throw new IllegalArgumentException(
logger.log(IngestorMessage.INVALID_PRODUCT_GENERATION_TIME, (String)(restProductMap.get("generationTime"))));
}

if (null == restProductMap.get("publicationTime")) {
modelProduct.setPublicationTime(null);
} else {
try {
modelProduct.setPublicationTime(Instant.from(OrbitTimeFormatter.parse((String)(restProductMap.get("publicationTime")))));
} catch (DateTimeException e) {
throw new IllegalArgumentException(
logger.log(IngestorMessage.INVALID_PUBLICATION_TIME, (String)(restProductMap.get("publicationTime"))));
}
}

if (null == restProductMap.get("evictionTime")) {
modelProduct.setEvictionTime(null);
} else {
try {
modelProduct.setEvictionTime(Instant.from(OrbitTimeFormatter.parse((String)(restProductMap.get("evictionTime")))));
} catch (DateTimeException e) {
throw new IllegalArgumentException(
logger.log(IngestorMessage.INVALID_EVICTION_TIME, (String)(restProductMap.get("evictionTime"))));
}
}

if (null == restProductMap.get("productionType")) {
modelProduct.setProductionType(null);
} else {
try {
modelProduct.setProductionType(ProductionType.valueOf((String)(restProductMap.get("productionType"))));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(
logger.log(IngestorMessage.INVALID_PRODUCTION_TYPE, (String)(restProductMap.get("productionType"))));
}
}
List<Map<String, String>> restParameterMapList = null;
if (restProductMap.get("parameters") != null) {
restParameterMapList = (List<Map<String, String>>)(restProductMap.get("parameters"));
}
if (restParameterMapList != null) {
for (Map<String, String> restParameterMap : restParameterMapList) {
de.dlr.proseo.model.Parameter modelParameter = new de.dlr.proseo.model.Parameter();
if (restParameterMap.get("parameterType") != null && !((String)(restParameterMap.get("parameterType"))).equals("null")) {
try {
modelParameter.setParameterType(ParameterType.valueOf(((String)(restParameterMap.get("parameterType")))));
} catch (Exception e) {
throw new IllegalArgumentException(
logger.log(IngestorMessage.INVALID_PARAMETER_TYPE, ((String)(restParameterMap.get("parameterType")))));
}
} else {
modelParameter.setParameterType(ParameterType.STRING);
}
try {
switch (modelParameter.getParameterType()) {
case INTEGER:
modelParameter.setIntegerValue(Integer.parseInt((String)(restParameterMap.get("parameterValue"))));
break;
case STRING:
modelParameter.setStringValue((String)(restParameterMap.get("parameterValue")));
break;
case BOOLEAN:
modelParameter.setBooleanValue(Boolean.parseBoolean((String)(restParameterMap.get("parameterValue"))));
break;
case DOUBLE:
modelParameter.setDoubleValue(Double.parseDouble((String)(restParameterMap.get("parameterValue"))));
break;
case INSTANT:
modelParameter.setInstantValue(OrbitTimeFormatter.parseDateTime((String)(restParameterMap.get("parameterValue"))));
break;
}
} catch (Exception e) {
throw new IllegalArgumentException(logger.log(IngestorMessage.INVALID_PARAMETER_VALUE,
(String)(restParameterMap.get("parameterValue")), (String)(restParameterMap.get("parameterType"))));
}
modelProduct.getParameters().put((String)(restParameterMap.get("key")), modelParameter);
}
}

return modelProduct;
}

}
2 changes: 1 addition & 1 deletion logging/src/site/resources/logging.html

Large diffs are not rendered by default.

187 changes: 187 additions & 0 deletions model/src/main/java/de/dlr/proseo/model/ProcessingOrderHistory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
/**
* ProcessingOrderHistory.java
*
* (C) 2024 Dr. Bassler & Co. Managementberatung GmbH
*/
package de.dlr.proseo.model;

import java.time.Instant;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Index;
import javax.persistence.Table;

import de.dlr.proseo.model.enums.OrderState;

/**
* A history entry for logging the processing times of a production order
*
* @author Ernst Melchinger
*
*/
@Entity
@Table(indexes = {
@Index(unique = true, columnList = "mission_code, identifier")
})
public class ProcessingOrderHistory extends PersistentObject {

/** Mission, to which this order belongs */
@Column(name = "mission_code")
private String missionCode;

/** User-defined order identifier (unique within the mission) */
@Column(nullable = false)
private String identifier;

/**
* Date and time at which the ProcessingOrder was created
*/
@Column(name = "creation_time", columnDefinition = "TIMESTAMP")
private Instant creationTime;

/**
* Date and time at which the ProcessingOrder was released
*/
@Column(name = "release_time", columnDefinition = "TIMESTAMP")
private Instant releaseTime;

/**
* Date and time at which the ProcessingOrder was completed
*/
@Column(name = "completion_time", columnDefinition = "TIMESTAMP")
private Instant completionTime;

/**
* Date and time at which the ProcessingOrder was deleted
*/
@Column(name = "deletion_time", columnDefinition = "TIMESTAMP")
private Instant deletionTime;

/** State of the processing order */
@Enumerated(EnumType.STRING)
private OrderState orderState;

/** The product types produced */
@Column(name = "product_types")
@ElementCollection
private Set<String> productTypes = new HashSet<>();

/**
* @return the missionCode
*/
public String getMissionCode() {
return missionCode;
}

/**
* @return the identifier
*/
public String getIdentifier() {
return identifier;
}

/**
* @return the creationTime
*/
public Instant getCreationTime() {
return creationTime;
}

/**
* @return the releaseTime
*/
public Instant getReleaseTime() {
return releaseTime;
}

/**
* @return the completionTime
*/
public Instant getCompletionTime() {
return completionTime;
}

/**
* @return the deletionTime
*/
public Instant getDeletionTime() {
return deletionTime;
}

/**
* @return the orderState
*/
public OrderState getOrderState() {
return orderState;
}

/**
* @return the productTypes
*/
public Set<String> getProductTypes() {
return productTypes;
}

/**
* @param missionCode the missionCode to set
*/
public void setMissionCode(String missionCode) {
this.missionCode = missionCode;
}

/**
* @param identifier the identifier to set
*/
public void setIdentifier(String identifier) {
this.identifier = identifier;
}

/**
* @param creationTime the creationTime to set
*/
public void setCreationTime(Instant creationTime) {
this.creationTime = creationTime;
}

/**
* @param releaseTime the releaseTime to set
*/
public void setReleaseTime(Instant releaseTime) {
this.releaseTime = releaseTime;
}

/**
* @param completionTime the completionTime to set
*/
public void setCompletionTime(Instant completionTime) {
this.completionTime = completionTime;
}

/**
* @param deletionTime the deletionTime to set
*/
public void setDeletionTime(Instant deletionTime) {
this.deletionTime = deletionTime;
}

/**
* @param orderState the orderState to set
*/
public void setOrderState(OrderState orderState) {
this.orderState = orderState;
}

/**
* @param productType the productType to set
*/
public void setProductTypes(Set<String> productTypes) {
this.productTypes = productTypes;
}

}
Loading

0 comments on commit ca61aba

Please sign in to comment.