fixed percentage during creation of Gis Layer

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/speciesdiscovery@142713 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2017-02-17 15:57:00 +00:00
parent c70c4ac44a
commit e6b15618ff
5 changed files with 102 additions and 55 deletions

View File

@ -57,7 +57,7 @@ public class GisLayerJobUtil {
String jobId = taxonomyService.generateGisLayerFromOccurrenceKeys(occurrenceKeys,layerTitle,layerDescr,author,credits); String jobId = taxonomyService.generateGisLayerFromOccurrenceKeys(occurrenceKeys,layerTitle,layerDescr,author,credits);
logger.info("generated gis layer jobID: "+jobId); logger.info("generated gis layer jobID: "+jobId);
Date submitTime = DateUtil.getDateFormat(Calendar.getInstance()); Date submitTime = DateUtil.getDateFormat(Calendar.getInstance());
GisLayerJob gisLJ = new GisLayerJob(jobId, layerTitle, 0, submitTime.getTime(), 0, 0, layerDescr, DownloadState.PENDING.toString(), null, totalPoints); GisLayerJob gisLJ = new GisLayerJob(jobId, layerTitle, 0, submitTime.getTime(), 0, 0, layerDescr, DownloadState.PENDING.toString(), null, totalPoints, 0);
gisLayerJob.insert(gisLJ); gisLayerJob.insert(gisLJ);
JobGisLayerModel jobModel = new JobGisLayerModel(jobId, layerTitle, DownloadState.PENDING,null, submitTime, null, null, layerDescr, 0, totalPoints, null, null); JobGisLayerModel jobModel = new JobGisLayerModel(jobId, layerTitle, DownloadState.PENDING,null, submitTime, null, null, layerDescr, 0, totalPoints, null, null);
logger.info("Returning job: "+jobModel); logger.info("Returning job: "+jobModel);
@ -111,14 +111,19 @@ public class GisLayerJobUtil {
} }
//TODO //TODO
int completedEntry = 0; int completedEntries = 0;
if(statusResponse.getCompletedEntries()>0) boolean completedEntriesChanged = false;
completedEntry = statusResponse.getCompletedEntries(); if(statusResponse.getCompletedEntries()>0){
completedEntries = statusResponse.getCompletedEntries();
job.setCompletedEntries(completedEntries);
completedEntriesChanged = true;
}
jobGisModel = new JobGisLayerModel(job.getId(), job.getName(), downloadState, completedEntry, job.getTotalPoints()); jobGisModel = new JobGisLayerModel(job.getId(), job.getName(), downloadState, completedEntries, job.getTotalPoints());
jobGisModel.setSubmitTime(submit); jobGisModel.setSubmitTime(submit);
jobGisModel.setLayerUUID(job.getLayerUUID()); jobGisModel.setLayerUUID(job.getLayerUUID());
jobGisModel.setGisViewerAppLink(job.getGisViewerAppLink()); jobGisModel.setGisViewerAppLink(job.getGisViewerAppLink());
jobGisModel.setCompletedPoints(completedEntries);
try{ try{
boolean changeEndTime = false; boolean changeEndTime = false;
@ -156,7 +161,7 @@ public class GisLayerJobUtil {
} }
//UPDATE DAO //UPDATE DAO
if(changeStatus || changeEndTime || changeStartTime || filledAppLink){ if(completedEntriesChanged || changeStatus || changeEndTime || changeStartTime || filledAppLink){
job.setState(downloadState.toString()); job.setState(downloadState.toString());
gisLayerJobP.update(job); gisLayerJobP.update(job);
} }

View File

@ -433,7 +433,10 @@ public class SpeciesService {
try { try {
logger.trace("Calling occurrencesCall passing keys: "+keys); logger.trace("Calling occurrencesCall passing keys: "+keys);
logger.trace("occurrencesCall != null? "+(occurrencesCall==null)); if(occurrencesCall==null){
logger.warn("occurrencesCall is null, instancing again...");
this.occurrencesCall = occurrences().withTimeout(3, TimeUnit.MINUTES).build();
}
Stream<OccurrencePoint> stream = occurrencesCall.getByKeys(keys); Stream<OccurrencePoint> stream = occurrencesCall.getByKeys(keys);
return new StreamIterator<OccurrencePoint>(stream); return new StreamIterator<OccurrencePoint>(stream);
} }

View File

@ -25,18 +25,21 @@ public class GisLayerJob extends DefaultJob{
private long totalPoints; private long totalPoints;
private String layerUUID; private String layerUUID;
private String gisViewerAppLink; private String gisViewerAppLink;
private long completedEntries;
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
protected int internalId; protected int internalId;
/** /**
* Instantiates a new gis layer job. * Instantiates a new gis layer job.
*/ */
public GisLayerJob() { public GisLayerJob() {
} }
/** /**
* Instantiates a new gis layer job. * Instantiates a new gis layer job.
* *
@ -45,16 +48,45 @@ public class GisLayerJob extends DefaultJob{
* @param startTime the start time * @param startTime the start time
* @param submitTime the submit time * @param submitTime the submit time
* @param endTime the end time * @param endTime the end time
* @param elapsedTime the elapsed time
* @param description the description * @param description the description
* @param state the state * @param state the state
* @param gisViewerAppLink the gis viewer app link
* @param totalPoints the total points
* @param completedEntries the completed entries
*/ */
public GisLayerJob(String id, String name, long startTime, long submitTime, long endTime,long elapsedTime, String description, String state, String gisViewerAppLink, long totalPoints) { public GisLayerJob(String id, String name, long startTime, long submitTime, long endTime,long elapsedTime, String description, String state, String gisViewerAppLink, long totalPoints, long completedEntries) {
super(id, name, startTime, submitTime, endTime, description, state, elapsedTime); super(id, name, startTime, submitTime, endTime, description, state, elapsedTime);
this.totalPoints = totalPoints; this.totalPoints = totalPoints;
this.gisViewerAppLink = gisViewerAppLink; this.gisViewerAppLink = gisViewerAppLink;
this.completedEntries = completedEntries;
}
/**
* Gets the completed entries.
*
* @return the completedEntries
*/
public long getCompletedEntries() {
return completedEntries;
}
/**
* Sets the completed entries.
*
* @param completedEntries the completedEntries to set
*/
public void setCompletedEntries(long completedEntries) {
this.completedEntries = completedEntries;
} }
/** /**
* Gets the total points.
*
* @return the totalPoints * @return the totalPoints
*/ */
public long getTotalPoints() { public long getTotalPoints() {
@ -63,6 +95,8 @@ public class GisLayerJob extends DefaultJob{
} }
/** /**
* Gets the layer uuid.
*
* @return the layerUUID * @return the layerUUID
*/ */
public String getLayerUUID() { public String getLayerUUID() {
@ -72,6 +106,8 @@ public class GisLayerJob extends DefaultJob{
/** /**
* Sets the layer uuid.
*
* @param layerUUID the layerUUID to set * @param layerUUID the layerUUID to set
*/ */
public void setLayerUUID(String layerUUID) { public void setLayerUUID(String layerUUID) {
@ -80,6 +116,8 @@ public class GisLayerJob extends DefaultJob{
} }
/** /**
* Sets the total points.
*
* @param totalPoints the totalPoints to set * @param totalPoints the totalPoints to set
*/ */
public void setTotalPoints(long totalPoints) { public void setTotalPoints(long totalPoints) {
@ -88,6 +126,8 @@ public class GisLayerJob extends DefaultJob{
} }
/** /**
* Gets the gis viewer app link.
*
* @return the gisViewerAppLink * @return the gisViewerAppLink
*/ */
public String getGisViewerAppLink() { public String getGisViewerAppLink() {
@ -97,6 +137,8 @@ public class GisLayerJob extends DefaultJob{
/** /**
* Sets the gis viewer app link.
*
* @param gisViewerAppLink the gisViewerAppLink to set * @param gisViewerAppLink the gisViewerAppLink to set
*/ */
public void setGisViewerAppLink(String gisViewerAppLink) { public void setGisViewerAppLink(String gisViewerAppLink) {
@ -105,6 +147,8 @@ public class GisLayerJob extends DefaultJob{
} }
/** /**
* Gets the internal id.
*
* @return the internalId * @return the internalId
*/ */
public int getInternalId() { public int getInternalId() {
@ -125,6 +169,8 @@ public class GisLayerJob extends DefaultJob{
builder.append(layerUUID); builder.append(layerUUID);
builder.append(", gisViewerAppLink="); builder.append(", gisViewerAppLink=");
builder.append(gisViewerAppLink); builder.append(gisViewerAppLink);
builder.append(", completedEntries=");
builder.append(completedEntries);
builder.append(", internalId="); builder.append(", internalId=");
builder.append(internalId); builder.append(internalId);
builder.append(", id="); builder.append(", id=");
@ -146,5 +192,4 @@ public class GisLayerJob extends DefaultJob{
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }
} }

View File

@ -113,10 +113,16 @@ public class JobGisLayerModel implements Serializable, IsSerializable{
this.completedPoints = completedPoints; this.completedPoints = completedPoints;
this.gisViewerAppLink = gisViewerAppLink; this.gisViewerAppLink = gisViewerAppLink;
this.layerUUID = layerUUID; this.layerUUID = layerUUID;
this.percentage = completedPoints!=0?completedPoints*100/totalPoints:0; updatePercentage();
} }
/**
* Update percentage.
*/
private void updatePercentage(){
this.percentage = completedPoints!=0 && totalPoints!=0?completedPoints*100/totalPoints:0;
}
/** /**
* Gets the job identifier. * Gets the job identifier.
@ -369,19 +375,6 @@ public class JobGisLayerModel implements Serializable, IsSerializable{
} }
/**
* Sets the percentage.
*
* @param percentage the percentage to set
*/
public void setPercentage(float percentage) {
this.percentage = percentage;
}
/** /**
* Sets the total points. * Sets the total points.
* *
@ -402,6 +395,7 @@ public class JobGisLayerModel implements Serializable, IsSerializable{
public void setCompletedPoints(long completedPoints) { public void setCompletedPoints(long completedPoints) {
this.completedPoints = completedPoints; this.completedPoints = completedPoints;
updatePercentage();
} }