58 lines
2.1 KiB
Java
58 lines
2.1 KiB
Java
/**
|
|
*
|
|
*/
|
|
package org.gcube.portlets.user.speciesdiscovery.server.job;
|
|
|
|
import java.util.Calendar;
|
|
import java.util.List;
|
|
|
|
import org.apache.log4j.Logger;
|
|
import org.gcube.portlets.user.speciesdiscovery.server.persistence.dao.GisLayerJobPersistence;
|
|
import org.gcube.portlets.user.speciesdiscovery.server.service.SpeciesService;
|
|
import org.gcube.portlets.user.speciesdiscovery.shared.DownloadState;
|
|
import org.gcube.portlets.user.speciesdiscovery.shared.GisLayerJob;
|
|
import org.gcube.portlets.user.speciesdiscovery.shared.JobGisLayerModel;
|
|
|
|
|
|
/**
|
|
* The Class GisLinkJobUtil.
|
|
*
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
|
* Feb 9, 2017
|
|
*/
|
|
public class GisLinkJobUtil {
|
|
|
|
protected static Logger logger = Logger.getLogger(GisLinkJobUtil.class);
|
|
|
|
|
|
/**
|
|
* Creates the gis layer job by occurrence keys.
|
|
*
|
|
* @param occurrenceKeys the occurrence keys
|
|
* @param taxonomyService the taxonomy service
|
|
* @param layerTitle the layer title
|
|
* @param layerDescr the layer descr
|
|
* @param author the author
|
|
* @param credits the credits
|
|
* @param gisLayerJob the gis layer job
|
|
* @return the job gis layer model
|
|
* @throws Exception the exception
|
|
*/
|
|
public static JobGisLayerModel createGisLayerJobByOccurrenceKeys(List<String> occurrenceKeys, SpeciesService taxonomyService, String layerTitle, String layerDescr, String author, String credits, GisLayerJobPersistence gisLayerJob) throws Exception {
|
|
|
|
try {
|
|
logger.trace("Generating Map form Occurrence Keys selected: "+occurrenceKeys.size());
|
|
String jobId = taxonomyService.generateMapFromOccurrenceKeys(occurrenceKeys,layerTitle,layerDescr,author,credits);
|
|
logger.info("generated gis layer jobID: "+jobId);
|
|
GisLayerJob gisLJ = new GisLayerJob(jobId, layerTitle, 0, Calendar.getInstance().getTimeInMillis(), 0, layerDescr, DownloadState.PENDING.toString());
|
|
gisLayerJob.insert(gisLJ);
|
|
|
|
return new JobGisLayerModel(jobId, layerTitle, 0, Calendar.getInstance().getTimeInMillis(), 0, layerDescr, DownloadState.PENDING.toString());
|
|
} catch (Exception e) {
|
|
logger.error("An error occurred creating the map", e);
|
|
throw new Exception(e.getMessage());
|
|
}
|
|
}
|
|
|
|
}
|