enhancement on Gis Link

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/speciesdiscovery@142552 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2017-02-14 17:20:44 +00:00
parent fb37829f2b
commit 92034592dd
8 changed files with 276 additions and 138 deletions

View File

@ -101,18 +101,22 @@ public class GisLayerGridJob extends ContentPanel{
ColumnConfig progress = new ColumnConfig(JobGisLayerModel.PROGRESS, JobGisLayerModel.PROGRESS, 150);
ColumnConfig startDate = new ColumnConfig(JobGisLayerModel.STARTTIME, JobGisLayerModel.STARTTIME, 140);
ColumnConfig submitDate = new ColumnConfig(JobGisLayerModel.SUBMITTIME, JobGisLayerModel.SUBMITTIME, 140);
//ColumnConfig submitDate = new ColumnConfig(JobGisLayerModel.SUBMITTIME, JobGisLayerModel.SUBMITTIME, 140);
// creationDate.setDateTimeFormat(DateTimeFormat.getFormat(DATE_TIME_FORMAT));
ColumnConfig endTime = new ColumnConfig(JobGisLayerModel.ENDTIME, JobGisLayerModel.ENDTIME, 140);
// endTime.setDateTimeFormat(DateTimeFormat.getFormat(DATE_TIME_FORMAT));
ColumnConfig elapsedTime = new ColumnConfig(JobGisLayerModel.ELAPSEDTIME, JobGisLayerModel.ELAPSEDTIME + " Days, " + ConstantsSpeciesDiscovery.TIMEFORMAT_HH_MM_SS, 100);
//ColumnConfig elapsedTime = new ColumnConfig(JobGisLayerModel.ELAPSEDTIME, JobGisLayerModel.ELAPSEDTIME + " Days, " + ConstantsSpeciesDiscovery.TIMEFORMAT_HH_MM_SS, 100);
// elapsedTime.setHidden(true);
ColumnConfig layerUUID = new ColumnConfig(JobGisLayerModel.LAYERUUID, JobGisLayerModel.LAYERUUID, 140);
ColumnConfig gisViewerAppLink = new ColumnConfig(JobGisLayerModel.GISVIEWERAPPLINK, JobGisLayerModel.GISVIEWERAPPLINK, 140);
ColumnConfig status = new ColumnConfig(JobGisLayerModel.STATUS, JobGisLayerModel.STATUS, 80);
final ColumnModel cm = new ColumnModel(Arrays.asList(name, progress, submitDate, startDate, endTime, elapsedTime, status));
final ColumnModel cm = new ColumnModel(Arrays.asList(name, progress, status, layerUUID, gisViewerAppLink, startDate, endTime));
setBodyBorder(false);
setHeaderVisible(false);
@ -232,6 +236,8 @@ public class GisLayerGridJob extends ContentPanel{
baseModelData.set(JobGisLayerModel.ENDTIME, jobModel.getEndTime());
baseModelData.set(JobGisLayerModel.STARTTIME, jobModel.getStartTime());
baseModelData.set(JobGisLayerModel.ELAPSEDTIME, jobModel.getElapsedTime());
baseModelData.set(JobGisLayerModel.GISVIEWERAPPLINK, jobModel.getGisViewerAppLink());
baseModelData.set(JobGisLayerModel.LAYERUUID, jobModel.getLayerUUID());
baseModelData.set(jobModel.getJobIdentifier(), jobModel); //store object JobOccurrencesModel
store.add(baseModelData);
@ -275,6 +281,8 @@ public class GisLayerGridJob extends ContentPanel{
job.set(JobGisLayerModel.ENDTIME, jobModel.getEndTime());
job.set(JobGisLayerModel.ELAPSEDTIME, jobModel.getElapsedTime());
job.set(JobGisLayerModel.STARTTIME, jobModel.getStartTime());
job.set(JobGisLayerModel.GISVIEWERAPPLINK, jobModel.getGisViewerAppLink());
job.set(JobGisLayerModel.LAYERUUID, jobModel.getLayerUUID());
updateJobInfo(jobModel);

View File

@ -34,11 +34,14 @@ public class GisLayerWindowInfoJobsSpecies extends Window{
String description = "\nName: \n" + jobModel.getJobName() + "\n";
if(jobModel.getLayerUUID()!=null)
description += "\n\nLayer UUID\n" + jobModel.getLayerUUID();
description += "\n\nOccurence Points (in total): \n" + jobModel.getTotalPoints();
description += "\n\nOccurence Points (used to generate the layer):\n" + jobModel.getCompletedPoints();
description += "\nStart Time: \n" + jobModel.getSubmitTime();
description += "\n\nLayer UUID:\n" + jobModel.getLayerUUID();
if(jobModel.getGisViewerAppLink()!=null)
description += "\n\nGis Viewer App Link:\n" + jobModel.getGisViewerAppLink();
description += "\n\nOccurrence Points (in total): \n" + jobModel.getTotalPoints();
description += "\n\nOccurrence Points (used to generate the layer): \n" + jobModel.getCompletedPoints();
description += "\n\nStart Time: \n" + jobModel.getStartTime();
description += "\n\nEnd Time: \n" + jobModel.getEndTime();
description += "\n\nElapsed Time: \n" + jobModel.getElapsedTime();
this.jobInfo.updateDescription(description);
}

View File

@ -342,7 +342,7 @@ public class ViewDetailsWindow extends Window {
@Override
public void componentSelected(ButtonEvent ce) {
SearchController.eventBus.fireEvent(new CreateGisLayerJobEvent("Occurences Layer by search: "+lastSearchEvent.getSearchTerm(), "Gis Layer generated from SPD Portlet by gCube Framework", count));
SearchController.eventBus.fireEvent(new CreateGisLayerJobEvent(lastSearchEvent.getSearchTerm() + " occurrences Layer", "Gis Layer generated from SPD Portlet by gCube Framework", count));
}
});

View File

@ -46,6 +46,17 @@ public class GisInfoServiceImpl extends RemoteServiceServlet implements GISInfoS
}
}
public static String getPublicLinkByUUID(String uuid) throws UriResolverMapException, IllegalArgumentException{
try{
logger.debug("Received get gis ilnk for layer uuid : "+uuid);
String publicLink=getPublicLink(uuid);
logger.debug("public link is "+publicLink);
return publicLink;
}catch (Exception e){
throw e;
}
}
private static String getPublicLink(String uuid) throws UriResolverMapException, IllegalArgumentException{
UriResolverManager resolver = new UriResolverManager("GIS");
@ -57,7 +68,7 @@ public class GisInfoServiceImpl extends RemoteServiceServlet implements GISInfoS
}
private static String getUUIDbyGSId(String gsID) throws Exception{
private String getUUIDbyGSId(String gsID) throws Exception{
GeoNetworkReader reader=GeoNetwork.get();
reader.login(LoginLevel.ADMIN);

View File

@ -1730,7 +1730,7 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
if(statusResponse!=null){
logger.info("statusResponse of gis layer job is not null..." + job.getId());
JobGisLayerModel convertJob = GisLayerJobUtil.convertJob(job, statusResponse, gisLayerJobDao, taxonomyService);
JobGisLayerModel convertJob = GisLayerJobUtil.convertJob(job, statusResponse, gisLayerJobDao, taxonomyService, getASLSession());
if(convertJob!=null){
logger.info("added list jobOccurrenceId: "+convertJob.getJobIdentifier() + " status "+convertJob.getDownloadState());

View File

@ -8,8 +8,10 @@ import java.util.Date;
import java.util.List;
import org.apache.log4j.Logger;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.data.spd.model.service.types.CompleteJobStatus;
import org.gcube.data.spd.model.service.types.JobStatus;
import org.gcube.portlets.user.speciesdiscovery.server.GisInfoServiceImpl;
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.server.util.DateUtil;
@ -49,9 +51,9 @@ public class GisLayerJobUtil {
String jobId = taxonomyService.generateGisLayerFromOccurrenceKeys(occurrenceKeys,layerTitle,layerDescr,author,credits);
logger.info("generated gis layer jobID: "+jobId);
Date submitTime = DateUtil.getDateFormat(Calendar.getInstance());
GisLayerJob gisLJ = new GisLayerJob(jobId, layerTitle, 0, submitTime.getTime(), 0, 0, layerDescr, DownloadState.PENDING.toString(), totalPoints);
GisLayerJob gisLJ = new GisLayerJob(jobId, layerTitle, 0, submitTime.getTime(), 0, 0, layerDescr, DownloadState.PENDING.toString(), null, totalPoints);
gisLayerJob.insert(gisLJ);
JobGisLayerModel jobModel = 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, null, null);
logger.info("Returning job: "+jobModel);
return jobModel;
} catch (Exception e) {
@ -68,9 +70,10 @@ public class GisLayerJobUtil {
* @param job the job
* @param statusResponse the status response
* @param gisLayerJobP the gis layer job p
* @param aslSession
* @return the job gis layer model
*/
public static JobGisLayerModel convertJob(GisLayerJob job, CompleteJobStatus statusResponse, GisLayerJobPersistence gisLayerJobP, SpeciesService taxonomyService){
public static JobGisLayerModel convertJob(GisLayerJob job, CompleteJobStatus statusResponse, GisLayerJobPersistence gisLayerJobP, SpeciesService taxonomyService, ASLSession aslSession){
//TODO SET END TIME
JobGisLayerModel jobGisModel;
@ -108,7 +111,8 @@ public class GisLayerJobUtil {
//TODO
jobGisModel = new JobGisLayerModel(job.getId(), job.getName(), downloadState, completedEntry, job.getTotalPoints());
jobGisModel.setSubmitTime(submit);
jobGisModel.setLayerUUID(job.getLayerUUID());
jobGisModel.setGisViewerAppLink(job.getGisViewerAppLink());
try{
boolean changeEndTime = false;
@ -123,6 +127,13 @@ public class GisLayerJobUtil {
jobGisModel.setLayerUUID(layerUUID);
job.setEndTime(endTime);
changeEndTime = true;
if(downloadState.equals(DownloadState.COMPLETED)){
logger.debug("UUID is "+layerUUID);
String gisLink=GisInfoServiceImpl.getPublicLinkByUUID(layerUUID);
logger.debug("public link is "+gisLink);
job.setGisViewerAppLink(gisLink);
jobGisModel.setGisViewerAppLink(gisLink);
}
}
}

View File

@ -24,11 +24,13 @@ public class GisLayerJob extends DefaultJob{
private static final long serialVersionUID = 2604265579184366453L;
private long totalPoints;
private String layerUUID;
private String gisViewerAppLink;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
protected int internalId;
/**
* Instantiates a new gis layer job.
*/
@ -46,9 +48,10 @@ 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, String gisViewerAppLink, long totalPoints) {
super(id, name, startTime, submitTime, endTime, description, state, elapsedTime);
this.totalPoints = totalPoints;
this.gisViewerAppLink = gisViewerAppLink;
}
/**
@ -84,7 +87,22 @@ public class GisLayerJob extends DefaultJob{
this.totalPoints = totalPoints;
}
/**
* @return the gisViewerAppLink
*/
public String getGisViewerAppLink() {
return gisViewerAppLink;
}
/**
* @param gisViewerAppLink the gisViewerAppLink to set
*/
public void setGisViewerAppLink(String gisViewerAppLink) {
this.gisViewerAppLink = gisViewerAppLink;
}
/**
* @return the internalId
@ -105,6 +123,8 @@ public class GisLayerJob extends DefaultJob{
builder.append(totalPoints);
builder.append(", layerUUID=");
builder.append(layerUUID);
builder.append(", gisViewerAppLink=");
builder.append(gisViewerAppLink);
builder.append(", internalId=");
builder.append(internalId);
builder.append(", id=");
@ -127,5 +147,4 @@ public class GisLayerJob extends DefaultJob{
return builder.toString();
}
}

View File

@ -31,6 +31,8 @@ public class JobGisLayerModel implements Serializable, IsSerializable{
public static final String PROGRESS = "Progress";
public static final String ENDTIME = "End Time";
public static final String ELAPSEDTIME = "Elapsed Time";
public static final String GISVIEWERAPPLINK = "GisViewerApp Link";
public static final String LAYERUUID = "Layer UUID";
public static final String PERCENTAGE = "Percentage";
public static final String DESCRIPTION = "Description";
@ -49,6 +51,8 @@ public class JobGisLayerModel implements Serializable, IsSerializable{
private long completedPoints;
private String layerUUID; //This is the result
private String gisViewerAppLink;
/**
* Instantiates a new job gis layer model.
*/
@ -75,25 +79,27 @@ public class JobGisLayerModel implements Serializable, IsSerializable{
/**
* @param jobIdentifier
* @param jobName
* @param downloadState
* @param startTime
* @param submitTime
* @param endTime
* @param elapsedTime
* @param layerDescription
* @param percentage
* @param totalPoints
* @param completedPoints
* Instantiates a new job gis layer model.
*
* @param jobIdentifier the job identifier
* @param jobName the job name
* @param downloadState the download state
* @param startTime the start time
* @param submitTime the submit time
* @param endTime the end time
* @param elapsedTime the elapsed time
* @param layerDescription the layer description
* @param completedPoints the completed points
* @param totalPoints the total points
* @param gisViewerAppLink the gis viewer app link
* @param layerUUID the layer uuid
*/
public JobGisLayerModel(
String jobIdentifier, String jobName, DownloadState downloadState,
Date startTime, Date submitTime, Date endTime, String elapsedTime,
String layerDescription, long completedPoints,
long totalPoints) {
long totalPoints, String gisViewerAppLink, String layerUUID) {
this.jobIdentifier = jobIdentifier;
this.jobName = jobName;
@ -105,11 +111,16 @@ public class JobGisLayerModel implements Serializable, IsSerializable{
this.layerDescription = layerDescription;
this.totalPoints = totalPoints;
this.completedPoints = completedPoints;
this.gisViewerAppLink = gisViewerAppLink;
this.layerUUID = layerUUID;
this.percentage = completedPoints!=0?completedPoints*100/totalPoints:0;
}
/**
* Gets the job identifier.
*
* @return the jobIdentifier
*/
public String getJobIdentifier() {
@ -120,6 +131,8 @@ public class JobGisLayerModel implements Serializable, IsSerializable{
/**
* Gets the job name.
*
* @return the jobName
*/
public String getJobName() {
@ -130,6 +143,8 @@ public class JobGisLayerModel implements Serializable, IsSerializable{
/**
* Gets the download state.
*
* @return the downloadState
*/
public DownloadState getDownloadState() {
@ -140,6 +155,8 @@ public class JobGisLayerModel implements Serializable, IsSerializable{
/**
* Gets the start time.
*
* @return the startTime
*/
public Date getStartTime() {
@ -150,6 +167,8 @@ public class JobGisLayerModel implements Serializable, IsSerializable{
/**
* Gets the submit time.
*
* @return the submitTime
*/
public Date getSubmitTime() {
@ -160,6 +179,8 @@ public class JobGisLayerModel implements Serializable, IsSerializable{
/**
* Gets the end time.
*
* @return the endTime
*/
public Date getEndTime() {
@ -170,6 +191,8 @@ public class JobGisLayerModel implements Serializable, IsSerializable{
/**
* Gets the elapsed time.
*
* @return the elapsedTime
*/
public String getElapsedTime() {
@ -180,6 +203,8 @@ public class JobGisLayerModel implements Serializable, IsSerializable{
/**
* Gets the layer description.
*
* @return the layerDescription
*/
public String getLayerDescription() {
@ -190,6 +215,8 @@ public class JobGisLayerModel implements Serializable, IsSerializable{
/**
* Gets the percentage.
*
* @return the percentage
*/
public float getPercentage() {
@ -200,6 +227,8 @@ public class JobGisLayerModel implements Serializable, IsSerializable{
/**
* Gets the total points.
*
* @return the totalPoints
*/
public long getTotalPoints() {
@ -210,6 +239,8 @@ public class JobGisLayerModel implements Serializable, IsSerializable{
/**
* Gets the completed points.
*
* @return the completedPoints
*/
public long getCompletedPoints() {
@ -220,115 +251,8 @@ public class JobGisLayerModel implements Serializable, IsSerializable{
/**
* @param jobIdentifier the jobIdentifier to set
*/
public void setJobIdentifier(String jobIdentifier) {
this.jobIdentifier = jobIdentifier;
}
/**
* @param jobName the jobName to set
*/
public void setJobName(String jobName) {
this.jobName = jobName;
}
/**
* @param downloadState the downloadState to set
*/
public void setDownloadState(DownloadState downloadState) {
this.downloadState = downloadState;
}
/**
* @param startTime the startTime to set
*/
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
/**
* @param submitTime the submitTime to set
*/
public void setSubmitTime(Date submitTime) {
this.submitTime = submitTime;
}
/**
* @param endTime the endTime to set
*/
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
/**
* @param elapsedTime the elapsedTime to set
*/
public void setElapsedTime(String elapsedTime) {
this.elapsedTime = elapsedTime;
}
/**
* @param layerDescription the layerDescription to set
*/
public void setLayerDescription(String layerDescription) {
this.layerDescription = layerDescription;
}
/**
* @param percentage the percentage to set
*/
public void setPercentage(float percentage) {
this.percentage = percentage;
}
/**
* @param totalPoints the totalPoints to set
*/
public void setTotalPoints(int totalPoints) {
this.totalPoints = totalPoints;
}
/**
* @param completedPoints the completedPoints to set
*/
public void setCompletedPoints(int completedPoints) {
this.completedPoints = completedPoints;
}
/**
* Gets the layer uuid.
*
* @return the layerUUID
*/
public String getLayerUUID() {
@ -339,6 +263,152 @@ public class JobGisLayerModel implements Serializable, IsSerializable{
/**
* Gets the gis viewer app link.
*
* @return the gisViewerAppLink
*/
public String getGisViewerAppLink() {
return gisViewerAppLink;
}
/**
* Sets the job identifier.
*
* @param jobIdentifier the jobIdentifier to set
*/
public void setJobIdentifier(String jobIdentifier) {
this.jobIdentifier = jobIdentifier;
}
/**
* Sets the job name.
*
* @param jobName the jobName to set
*/
public void setJobName(String jobName) {
this.jobName = jobName;
}
/**
* Sets the download state.
*
* @param downloadState the downloadState to set
*/
public void setDownloadState(DownloadState downloadState) {
this.downloadState = downloadState;
}
/**
* Sets the start time.
*
* @param startTime the startTime to set
*/
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
/**
* Sets the submit time.
*
* @param submitTime the submitTime to set
*/
public void setSubmitTime(Date submitTime) {
this.submitTime = submitTime;
}
/**
* Sets the end time.
*
* @param endTime the endTime to set
*/
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
/**
* Sets the elapsed time.
*
* @param elapsedTime the elapsedTime to set
*/
public void setElapsedTime(String elapsedTime) {
this.elapsedTime = elapsedTime;
}
/**
* Sets the layer description.
*
* @param layerDescription the layerDescription to set
*/
public void setLayerDescription(String layerDescription) {
this.layerDescription = layerDescription;
}
/**
* Sets the percentage.
*
* @param percentage the percentage to set
*/
public void setPercentage(float percentage) {
this.percentage = percentage;
}
/**
* Sets the total points.
*
* @param totalPoints the totalPoints to set
*/
public void setTotalPoints(long totalPoints) {
this.totalPoints = totalPoints;
}
/**
* Sets the completed points.
*
* @param completedPoints the completedPoints to set
*/
public void setCompletedPoints(long completedPoints) {
this.completedPoints = completedPoints;
}
/**
* Sets the layer uuid.
*
* @param layerUUID the layerUUID to set
*/
public void setLayerUUID(String layerUUID) {
@ -347,6 +417,18 @@ public class JobGisLayerModel implements Serializable, IsSerializable{
}
/**
* Sets the gis viewer app link.
*
* @param gisViewerAppLink the gisViewerAppLink to set
*/
public void setGisViewerAppLink(String gisViewerAppLink) {
this.gisViewerAppLink = gisViewerAppLink;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@ -378,8 +460,12 @@ public class JobGisLayerModel implements Serializable, IsSerializable{
builder.append(completedPoints);
builder.append(", layerUUID=");
builder.append(layerUUID);
builder.append(", gisViewerAppLink=");
builder.append(gisViewerAppLink);
builder.append("]");
return builder.toString();
}
}