Fixed issue on create external link
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/speciesdiscovery@142611 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
5b68060b5f
commit
7dea8a1424
|
@ -1819,17 +1819,6 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
|||
try {
|
||||
|
||||
SpeciesService taxonomyService = getSpeciesService();
|
||||
|
||||
// String mimeType = null;
|
||||
// switch (jobModel.getFileFormat()) {
|
||||
// case CSV: {
|
||||
// mimeType = "text/csv";
|
||||
// } break;
|
||||
// case DARWIN_CORE:{
|
||||
// mimeType = "application/xhtml+xml";
|
||||
// } break;
|
||||
// }
|
||||
|
||||
String mimeType = "text/plain";
|
||||
|
||||
InputStream inputStream = taxonomyService.getOccurrenceJobErrorFileById(jobModel.getJobIdentifier());
|
||||
|
@ -2136,8 +2125,24 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
|||
logger.info("input stream is not null");
|
||||
WorkspaceFolder folder = (WorkspaceFolder) workspace.getItem(destinationFolderId);
|
||||
fileName = WorkspaceUtil.getUniqueName(fileName, folder);
|
||||
|
||||
if(jobGisLayer.getGisViewerAppLink()==null){
|
||||
SpeciesService speciesService = getSpeciesService();
|
||||
CompleteJobStatus statusResponse = speciesService.getGisLayerByJobId(jobGisLayer.getJobIdentifier());
|
||||
GisLayerJobPersistence gisLayerJobDao = DaoSession.getGisLayersJobDAO(getASLSession());
|
||||
|
||||
try{
|
||||
GisLayerJob gLJ = gisLayerJobDao.getItemByIdField(jobGisLayer.getJobIdentifier());
|
||||
if(gLJ!=null){
|
||||
jobGisLayer = GisLayerJobUtil.convertJob(gLJ, statusResponse, gisLayerJobDao, speciesService, getASLSession());
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.error("Error on retrieving gis link from DB for job id: "+jobGisLayer.getJobIdentifier(), e);
|
||||
throw new Exception(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
workspace.createExternalUrl(fileName, jobGisLayer.getLayerDescription() + "- Layer UUID: "+jobGisLayer.getLayerUUID(), jobGisLayer.getGisViewerAppLink(), destinationFolderId);
|
||||
// System.out.println("input stream is not null");
|
||||
logger.info("Saving External link "+fileName +" completed");
|
||||
return true;
|
||||
|
||||
|
@ -2155,10 +2160,9 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
|||
|
||||
GisLayerJobPersistence gisLayerDAO;
|
||||
try {
|
||||
|
||||
gisLayerDAO = DaoSession.getGisLayersJobDAO(getASLSession());
|
||||
|
||||
int count = GisLayerJobUtil.changetStatusGisLayerJob(jobId, state, gisLayerDAO);
|
||||
|
||||
if(count==1)
|
||||
return true;
|
||||
|
||||
|
|
|
@ -110,11 +110,11 @@ public class GisLayerJobUtil {
|
|||
}
|
||||
}
|
||||
|
||||
//TODO
|
||||
int completedEntry = 0;
|
||||
if(statusResponse.getCompletedEntries()>0)
|
||||
completedEntry = statusResponse.getCompletedEntries();
|
||||
|
||||
//TODO
|
||||
jobGisModel = new JobGisLayerModel(job.getId(), job.getName(), downloadState, completedEntry, job.getTotalPoints());
|
||||
jobGisModel.setSubmitTime(submit);
|
||||
jobGisModel.setLayerUUID(job.getLayerUUID());
|
||||
|
@ -122,24 +122,27 @@ public class GisLayerJobUtil {
|
|||
try{
|
||||
|
||||
boolean changeEndTime = false;
|
||||
boolean filledAppLink = false;
|
||||
|
||||
//UPDATE END TIME
|
||||
if(downloadState.equals(DownloadState.FAILED) || downloadState.equals(DownloadState.COMPLETED)){
|
||||
String layerUUID = taxonomyService.getGisLayerResultLinkByJobId(job.getId());
|
||||
if(statusResponse.getEndDate()!=null && job.getEndTime()==0){ //UPDATE end time first time only
|
||||
logger.trace("UPDATE end time first time only - " + downloadState);
|
||||
endTime = statusResponse.getEndDate().getTimeInMillis();
|
||||
String layerUUID = taxonomyService.getGisLayerResultLinkByJobId(job.getId());
|
||||
job.setLayerUUID(layerUUID);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if(downloadState.equals(DownloadState.COMPLETED) && jobGisModel.getGisViewerAppLink()==null){
|
||||
logger.debug("UUID is "+layerUUID);
|
||||
String gisLink=GisInfoServiceImpl.getPublicLinkByUUID(layerUUID);
|
||||
logger.debug("public link is "+gisLink);
|
||||
job.setGisViewerAppLink(gisLink);
|
||||
jobGisModel.setGisViewerAppLink(gisLink);
|
||||
filledAppLink = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,7 +156,7 @@ public class GisLayerJobUtil {
|
|||
}
|
||||
|
||||
//UPDATE DAO
|
||||
if(changeStatus || changeEndTime || changeStartTime){
|
||||
if(changeStatus || changeEndTime || changeStartTime || filledAppLink){
|
||||
job.setState(downloadState.toString());
|
||||
gisLayerJobP.update(job);
|
||||
}
|
||||
|
|
|
@ -254,4 +254,34 @@ public class GisLayerJobPersistence extends AbstractPersistence<GisLayerJob>{
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the item by id field.
|
||||
*
|
||||
* @param idField the id field
|
||||
* @return the item by id field
|
||||
* @throws DatabaseServiceException the database service exception
|
||||
*/
|
||||
public GisLayerJob getItemByIdField(String idField) throws DatabaseServiceException{
|
||||
EntityManager em = super.createNewManager();
|
||||
try {
|
||||
Query query = em.createQuery("Select t FROM "+GisLayerJob.class.getSimpleName()+" t WHERE t."+GisLayerJob.ID_FIELD+"='"+idField+"'");
|
||||
List<GisLayerJob> listOJ = query.getResultList();
|
||||
|
||||
if(listOJ!=null && listOJ.get(0)!=null)
|
||||
return listOJ.get(0);
|
||||
|
||||
return null;
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error in OccurrencesJob deleteItemByIdField: " + e.getMessage(), e);
|
||||
throw new DatabaseServiceException();
|
||||
|
||||
} finally {
|
||||
if(em!=null)
|
||||
em.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue