Working on Task #7001
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/speciesdiscovery@142466 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
6f0417e86e
commit
4e5b889342
|
@ -115,6 +115,7 @@ public class SearchBorderLayoutPanel extends ContentPanel {
|
|||
|
||||
SearchController.excecuteGetJobs(SearchResultType.TAXONOMY_ITEM, false);
|
||||
SearchController.excecuteGetJobs(SearchResultType.OCCURRENCE_POINT, false);
|
||||
SearchController.excecuteGetJobs(SearchResultType.GIS_LAYER_POINT, false);
|
||||
|
||||
pollSpeciesJobs(ConstantsSpeciesDiscovery.JOBPOLLINGMILLISECONDS);
|
||||
|
||||
|
@ -132,6 +133,7 @@ public class SearchBorderLayoutPanel extends ContentPanel {
|
|||
|
||||
SearchController.excecuteGetJobs(SearchResultType.TAXONOMY_ITEM, false);
|
||||
SearchController.excecuteGetJobs(SearchResultType.OCCURRENCE_POINT, false);
|
||||
SearchController.excecuteGetJobs(SearchResultType.GIS_LAYER_POINT, false);
|
||||
|
||||
}
|
||||
};
|
||||
|
|
|
@ -286,9 +286,9 @@ public class SearchController {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(JobGisLayerModel jobId) {
|
||||
|
||||
Info.display("Gis Layer Occurrence Job", "Generating Gis layer: "+jobId.getJobName()+" submitted");
|
||||
public void onSuccess(JobGisLayerModel gisJob) {
|
||||
GWT.log("Returned gis job: "+gisJob);
|
||||
Info.display("Gis Layer Occurrence Job", "Generating Gis layer: "+gisJob.getJobName()+" submitted");
|
||||
excecuteGetJobs(SearchResultType.GIS_LAYER_POINT, false);
|
||||
searchBorderLayoutPanel.getSpeciesSouthPanel().setIconGisLayerByCounter(1);
|
||||
|
||||
|
@ -297,35 +297,6 @@ public class SearchController {
|
|||
// showMap(layerName);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// SpeciesDiscovery.taxonomySearchService.createOccurrencesJob(listJobOccurrenceModel, createOccurrenceJobEvent.getFileFormat(), createOccurrenceJobEvent.getSaveEnum(), createOccurrenceJobEvent.isByDataSource(), createOccurrenceJobEvent.getExpectedOccurrences(), new AsyncCallback<List<JobOccurrencesModel>>() {
|
||||
//
|
||||
// @Override
|
||||
// public void onFailure(Throwable caught) {
|
||||
// Info.display("Error", "Sorry, An error occurred on create job. Please try again later");
|
||||
// Log.error("Error on loading", "An error occurred on create job, retry." +caught.getMessage());
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onSuccess(List<JobOccurrencesModel> result) {
|
||||
//
|
||||
// if(result!=null){
|
||||
// int jobs = result.size();
|
||||
// if(jobs>0){
|
||||
// String msg = jobs==1? "was":"were";
|
||||
// Info.display("Species Occurrence Job", result.size() + " occurrence job "+msg+" submitted");
|
||||
// excecuteGetJobs(SearchResultType.OCCURRENCE_POINT, false);
|
||||
// searchBorderLayoutPanel.getSpeciesSouthPanel().setIconOccurrenceByCounter(result.size());
|
||||
// }
|
||||
// else{
|
||||
// Info.display("Species Occurrence Job","An error occurred on submit job, retry");
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1719,6 +1690,7 @@ public class SearchController {
|
|||
if(resetStructures)
|
||||
GisLayerJobSpeciesPanel.getInstance(eventBus).getGridJob().mask("Loading", ConstantsSpeciesDiscovery.LOADINGSTYLE);
|
||||
|
||||
//TODO
|
||||
|
||||
SpeciesDiscovery.taxonomySearchService.getListGisLayerJob(new AsyncCallback<List<JobGisLayerModel>>() {
|
||||
|
||||
|
|
|
@ -518,7 +518,7 @@ public class GisLayerGridJob extends ContentPanel{
|
|||
public void handleEvent(BaseEvent be) {
|
||||
|
||||
// resetStore();
|
||||
eventBus.fireEvent(new ReLoadListJobEvent(SearchResultType.OCCURRENCE_POINT));
|
||||
eventBus.fireEvent(new ReLoadListJobEvent(SearchResultType.GIS_LAYER_POINT));
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -36,7 +36,7 @@ public class GisLayerJobSpeciesPanel extends ContentPanel {
|
|||
private static String LASTOPERATION = "Last Operation: ";
|
||||
private Html lastOperation = new Html(LASTOPERATION);
|
||||
private LayoutContainer lc;
|
||||
private static String WINDOWTITLE = "Species Occurrence Jobs";
|
||||
private static String WINDOWTITLE = "Gis Layer Jobs";
|
||||
private static final String FAILED = "failed";
|
||||
private static final String COMPLETED = "completed";
|
||||
private static final String LOADING = "loading";
|
||||
|
|
|
@ -334,7 +334,7 @@ public class ViewDetailsWindow extends Window {
|
|||
|
||||
Button btnShowInGisViewer = new Button(ConstantsSpeciesDiscovery.CREATE_GIS_LAYER);
|
||||
btnShowInGisViewer.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getGisProducts()));
|
||||
btnShowInGisViewer.setToolTip(new ToolTipConfig(ConstantsSpeciesDiscovery.CREATE_GIS_LAYER, "Create a Gis Layer from selected occurences points in a Gis Viewer Map"));
|
||||
btnShowInGisViewer.setToolTip(new ToolTipConfig(ConstantsSpeciesDiscovery.CREATE_GIS_LAYER, "Create a Gis Layer from selected occurences points."));
|
||||
btnShowInGisViewer.setScale(ButtonScale.SMALL);
|
||||
btnShowInGisViewer.setIconAlign(IconAlign.TOP);
|
||||
btnShowInGisViewer.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||
|
@ -342,7 +342,7 @@ public class ViewDetailsWindow extends Window {
|
|||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
SearchController.eventBus.fireEvent(new CreateGisLayerJobEvent(lastSearchEvent.getSearchTerm() +" Occurrences layer", "Gis Layer generated from SPD Portlet by gCube Framework", count));
|
||||
SearchController.eventBus.fireEvent(new CreateGisLayerJobEvent("Gis Layer by: "+lastSearchEvent.getSearchTerm(), "Gis Layer generated from SPD Portlet by gCube Framework", count));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -858,6 +858,7 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
|||
String author = getASLSession().getUsername();
|
||||
String credits = "";
|
||||
GisLayerJobPersistence gisLayerJob = DaoSession.getGisLayersJobDAO(getASLSession());
|
||||
logger.trace("GisLayerJobPersistence found");
|
||||
return GisLayerJobUtil.createGisLayerJobByOccurrenceKeys(occurrenceKeys, taxonomyService, layerTitle, layerDescr, author, credits, totalPoints, gisLayerJob);
|
||||
} catch (Exception e) {
|
||||
logger.error("An error occurred creating the map", e);
|
||||
|
@ -1712,12 +1713,17 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
|||
try {
|
||||
|
||||
GisLayerJobPersistence gisLayerJobDao = DaoSession.getGisLayersJobDAO(getASLSession());
|
||||
|
||||
Iterator<GisLayerJob> iterator = gisLayerJobDao.getList().iterator();
|
||||
SpeciesService taxonomyService = getSpeciesService();
|
||||
|
||||
while (iterator!=null && iterator.hasNext()) {
|
||||
GisLayerJob job = iterator.next();
|
||||
CompleteJobStatus statusResponse = taxonomyService.getOccurrenceJobById(job.getId());
|
||||
|
||||
if(job.getId()==null || job.getId().isEmpty()){
|
||||
logger.warn("Gis job has an id null or empty, skipping");
|
||||
}else{
|
||||
CompleteJobStatus statusResponse = taxonomyService.getGisLayerByJobId(job.getId());
|
||||
logger.info("get occurrence job "+job.getId()+ " from service");
|
||||
|
||||
try{
|
||||
|
@ -1743,6 +1749,7 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
|||
throw new Exception("Error on getListGisLayerJob", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error on get iterator "+e, e);
|
||||
|
|
|
@ -51,7 +51,9 @@ public class GisLayerJobUtil {
|
|||
Date submitTime = DateUtil.getDateFormat(Calendar.getInstance());
|
||||
GisLayerJob gisLJ = new GisLayerJob(jobId, layerTitle, 0, submitTime.getTime(), 0, 0, layerDescr, DownloadState.PENDING.toString(), totalPoints);
|
||||
gisLayerJob.insert(gisLJ);
|
||||
return new JobGisLayerModel(jobId, layerTitle, DownloadState.PENDING,null, submitTime, null, null, layerDescr, 0, totalPoints);
|
||||
JobGisLayerModel jobModel = new JobGisLayerModel(jobId, layerTitle, DownloadState.PENDING,null, submitTime, null, null, layerDescr, 0, totalPoints);
|
||||
logger.info("Returning job: "+jobModel);
|
||||
return jobModel;
|
||||
} catch (Exception e) {
|
||||
logger.error("An error occurred creating the map", e);
|
||||
throw new Exception(e.getMessage());
|
||||
|
|
|
@ -489,10 +489,8 @@ public class SpeciesService {
|
|||
return creator.createLayer(keyStream, details);
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error(
|
||||
"Error calling the Species Service: " + e.getMessage(), e);
|
||||
throw new SearchServiceException(
|
||||
"Error calling the Species Service: " + e.getMessage());
|
||||
logger.error("Error calling the Species Service: " + e.getMessage(), e);
|
||||
throw new SearchServiceException("Error calling the Species Service: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,19 +5,22 @@ package org.gcube.portlets.user.speciesdiscovery.shared;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.MappedSuperclass;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 9, 2017
|
||||
*/
|
||||
@MappedSuperclass
|
||||
public class DefaultJob implements Serializable{
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4448201743475516557L;
|
||||
private static final long serialVersionUID = 5677419614560436596L;
|
||||
|
||||
public final static String ID_FIELD = "id";
|
||||
public final static String NAME = "name";
|
||||
public final static String DESCRIPTION = "description";
|
||||
|
@ -44,8 +47,6 @@ public class DefaultJob implements Serializable{
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param name
|
||||
|
@ -56,11 +57,7 @@ public class DefaultJob implements Serializable{
|
|||
* @param state
|
||||
* @param elapsedTime
|
||||
*/
|
||||
public DefaultJob(
|
||||
String id, String name, long startTime, long submitTime, long endTime,
|
||||
String description, String state, long elapsedTime) {
|
||||
|
||||
super();
|
||||
public DefaultJob(String id, String name, long startTime, long submitTime, long endTime, String description, String state, long elapsedTime) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.startTime = startTime;
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
package org.gcube.portlets.user.speciesdiscovery.shared;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -21,6 +24,9 @@ public class GisLayerJob extends DefaultJob{
|
|||
private static final long serialVersionUID = 2604265579184366453L;
|
||||
private long totalPoints;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
protected int internalId;
|
||||
|
||||
/**
|
||||
* Instantiates a new gis layer job.
|
||||
|
@ -28,8 +34,6 @@ public class GisLayerJob extends DefaultJob{
|
|||
public GisLayerJob() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new gis layer job.
|
||||
*
|
||||
|
@ -41,16 +45,11 @@ public class GisLayerJob extends DefaultJob{
|
|||
* @param description the description
|
||||
* @param state the state
|
||||
*/
|
||||
public GisLayerJob(
|
||||
String id, String name, long startTime, long submitTime, long endTime,
|
||||
long elapsedTime, String description, String state, long totalPoints) {
|
||||
public GisLayerJob(String id, String name, long startTime, long submitTime, long endTime,long elapsedTime, String description, String state, long totalPoints) {
|
||||
super(id, name, startTime, submitTime, endTime, description, state, elapsedTime);
|
||||
this.totalPoints = totalPoints;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the totalPoints
|
||||
*/
|
||||
|
@ -60,8 +59,6 @@ public class GisLayerJob extends DefaultJob{
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param totalPoints the totalPoints to set
|
||||
*/
|
||||
|
@ -72,6 +69,16 @@ public class GisLayerJob extends DefaultJob{
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* @return the internalId
|
||||
*/
|
||||
public int getInternalId() {
|
||||
|
||||
return internalId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
|
@ -81,6 +88,8 @@ public class GisLayerJob extends DefaultJob{
|
|||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GisLayerJob [totalPoints=");
|
||||
builder.append(totalPoints);
|
||||
builder.append(", internalId=");
|
||||
builder.append(internalId);
|
||||
builder.append(", id=");
|
||||
builder.append(id);
|
||||
builder.append(", name=");
|
||||
|
@ -101,6 +110,4 @@ public class GisLayerJob extends DefaultJob{
|
|||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ package org.gcube.portlets.user.speciesdiscovery.shared;
|
|||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -15,7 +17,7 @@ import java.util.Date;
|
|||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 9, 2017
|
||||
*/
|
||||
public class JobGisLayerModel implements Serializable{
|
||||
public class JobGisLayerModel implements Serializable, IsSerializable{
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -92,7 +94,6 @@ public class JobGisLayerModel implements Serializable{
|
|||
String layerDescription, long completedPoints,
|
||||
long totalPoints) {
|
||||
|
||||
super();
|
||||
this.jobIdentifier = jobIdentifier;
|
||||
this.jobName = jobName;
|
||||
this.downloadState = downloadState;
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<entity-mappings version="2.0" xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd">
|
||||
<mapped-superclass class="DefaultJob">
|
||||
</mapped-superclass>
|
||||
</entity-mappings>
|
|
@ -2,8 +2,7 @@
|
|||
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
|
||||
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
|
||||
<persistence-unit name="SPD_PERSISTENCE_FACTORY"
|
||||
transaction-type="RESOURCE_LOCAL">
|
||||
<persistence-unit name="SPD_PERSISTENCE_FACTORY" transaction-type="RESOURCE_LOCAL">
|
||||
<class>org.gcube.portlets.user.speciesdiscovery.shared.CommonName</class>
|
||||
<class>org.gcube.portlets.user.speciesdiscovery.shared.Taxon</class>
|
||||
<class>org.gcube.portlets.user.speciesdiscovery.shared.ResultRow</class>
|
||||
|
@ -12,6 +11,7 @@
|
|||
<class>org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow</class>
|
||||
<class>org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesJob</class>
|
||||
<class>org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyJob</class>
|
||||
<class>org.gcube.portlets.user.speciesdiscovery.shared.GisLayerJob</class>
|
||||
<properties>
|
||||
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
|
||||
<property name="eclipselink.ddl-generation" value="create-tables" />
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.speciesdiscovery.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.data.spd.client.plugins.AbstractPlugin;
|
||||
import org.gcube.data.spd.client.proxies.ExecutorClient;
|
||||
import org.gcube.data.spd.model.service.types.CompleteJobStatus;
|
||||
import org.gcube.data.spd.model.service.types.JobStatus;
|
||||
import org.gcube.data.spd.model.service.types.MetadataDetails;
|
||||
import org.gcube.data.streams.Stream;
|
||||
import org.gcube.data.streams.dsl.Streams;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 10, 2017
|
||||
*/
|
||||
public class GisJob {
|
||||
|
||||
static List<String> keys = new ArrayList<String>();
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
|
||||
ScopeProvider.instance.set("/gcube/devsec");
|
||||
|
||||
keys.add("OBIS:161||666236");
|
||||
ExecutorClient creator = AbstractPlugin.executor().build();
|
||||
Stream<String> keyStream = Streams.convert(keys);
|
||||
System.out.println("keys are: "+keys.toString());
|
||||
|
||||
MetadataDetails details= new MetadataDetails("title", "descr", "tile", "author", "credits");
|
||||
System.out.println("submittings job...");
|
||||
String jobId = creator.createLayer(keyStream, details);
|
||||
System.out.println("The job id is: "+jobId);
|
||||
|
||||
CompleteJobStatus status = creator.getStatus(jobId);
|
||||
|
||||
JobStatus sta = status.getStatus();
|
||||
while(sta!=JobStatus.COMPLETED && sta!=JobStatus.FAILED){
|
||||
Thread.sleep(1000);
|
||||
sta = creator.getStatus(jobId).getStatus();
|
||||
System.out.println("checking status.."+sta);
|
||||
}
|
||||
|
||||
System.out.println("job terminated");
|
||||
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue