improved the monitoring..
This commit is contained in:
parent
39efa4b27c
commit
6617655492
|
@ -905,7 +905,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
||||||
break;
|
break;
|
||||||
case FAILED:
|
case FAILED:
|
||||||
icon = new Icon(IconType.WARNING_SIGN);
|
icon = new Icon(IconType.WARNING_SIGN);
|
||||||
icon.getElement().getStyle().setColor("#800000");
|
icon.getElement().getStyle().setColor("#FF0000");
|
||||||
icon.setSize(IconSize.TWO_TIMES);
|
icon.setSize(IconSize.TWO_TIMES);
|
||||||
icon.setTitle(action.getStatus().getLabel());
|
icon.setTitle(action.getStatus().getLabel());
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -172,18 +172,18 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
MongoServiceUtil mongoService = new MongoServiceUtil();
|
MongoServiceUtil mongoService = new MongoServiceUtil();
|
||||||
String theDocumentString = null;
|
String theDocumentString = null;
|
||||||
try {
|
try {
|
||||||
// 1. Action to Monitoring
|
// // 1. Action to Monitoring
|
||||||
MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS,
|
// MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS,
|
||||||
"Converting project metadata to Geoportal data model");
|
// "Converting project metadata to Geoportal data model");
|
||||||
action = monitoringActionsOnServer.pushAction(action);
|
// action = monitoringActionsOnServer.pushAction(action);
|
||||||
|
|
||||||
FormDataObjectToJSON metadataConverter = new FormDataObjectToJSON();
|
FormDataObjectToJSON metadataConverter = new FormDataObjectToJSON();
|
||||||
JSONObject theDocument = metadataConverter.convert(tree_Node, null);
|
JSONObject theDocument = metadataConverter.convert(tree_Node, null);
|
||||||
|
|
||||||
// 1. Action completed
|
// // 1. Action completed
|
||||||
action.setMsg("Converted project metadata to Geoportal data model");
|
// action.setMsg("Converted project metadata to Geoportal data model");
|
||||||
action.setStatus(STATUS.DONE);
|
// action.setStatus(STATUS.DONE);
|
||||||
monitoringActionsOnServer.overrideAction(action);
|
// monitoringActionsOnServer.overrideAction(action);
|
||||||
|
|
||||||
theDocumentString = theDocument.toString();
|
theDocumentString = theDocument.toString();
|
||||||
LOG.info("Got Document: " + theDocumentString);
|
LOG.info("Got Document: " + theDocumentString);
|
||||||
|
@ -199,13 +199,13 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
LOG.debug("Going to create the project...");
|
LOG.debug("Going to create the project...");
|
||||||
// 2. Action to Monitoring
|
// 2. Action to Monitoring
|
||||||
MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS,
|
MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS,
|
||||||
"Creating project on Geoportal Storage service");
|
"Creating the project on the Geoportal storage service");
|
||||||
action = monitoringActionsOnServer.pushAction(action);
|
action = monitoringActionsOnServer.pushAction(action);
|
||||||
|
|
||||||
theProject = mongoService.createNew(profileID, theDocumentString);
|
theProject = mongoService.createNew(profileID, theDocumentString);
|
||||||
|
|
||||||
// 2. Action completed
|
// 2. Action completed
|
||||||
action.setMsg("Created project on Geoportal Storage service");
|
action.setMsg("Created the project on the Geoportal storage service");
|
||||||
action.setStatus(STATUS.DONE);
|
action.setStatus(STATUS.DONE);
|
||||||
monitoringActionsOnServer.overrideAction(action);
|
monitoringActionsOnServer.overrideAction(action);
|
||||||
|
|
||||||
|
@ -494,7 +494,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.info("Project with id " + currentProject.getId() + " updated correclty");
|
LOG.info("Project with id " + currentProject.getId() + " updated correctly");
|
||||||
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
||||||
// Reading again the project to be sure
|
// Reading again the project to be sure
|
||||||
updatedProject = client.getProjectByID(profileID, projectID);
|
updatedProject = client.getProjectByID(profileID, projectID);
|
||||||
|
@ -591,7 +591,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
Map<String, FileSetDataObject> collectFilesetPerFieldDef = new HashMap<String, FileSetDataObject>();
|
Map<String, FileSetDataObject> collectFilesetPerFieldDef = new HashMap<String, FileSetDataObject>();
|
||||||
List<FileUploaded> files = gdb.getFilesUploaded();
|
List<FileUploaded> files = gdb.getFilesUploaded();
|
||||||
if (files.size() > 0) {
|
if (files.size() > 0) {
|
||||||
List<String> fileNames = files.stream().map(fl -> fl.getFileName()).collect(Collectors.toList());
|
// List<String> fileNames = files.stream().map(fl ->
|
||||||
|
// fl.getFileName()).collect(Collectors.toList());
|
||||||
// 1..N Monitoring Copying files
|
// 1..N Monitoring Copying files
|
||||||
// MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS,
|
// MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS,
|
||||||
// "Copying file/s: " + fileNames);
|
// "Copying file/s: " + fileNames);
|
||||||
|
@ -647,7 +648,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1..N Monitoring Fileset copied action completed
|
// 1..N Monitoring Fileset copied action completed
|
||||||
// action.setMsg("File/s " + fileNames + " copied correclty");
|
// action.setMsg("File/s " + fileNames + " copied correctly");
|
||||||
// action.setStatus(STATUS.DONE);
|
// action.setStatus(STATUS.DONE);
|
||||||
// monitorActions.overrideAction(action);
|
// monitorActions.overrideAction(action);
|
||||||
|
|
||||||
|
@ -665,8 +666,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
// Getting fileNames for the monitoring
|
// Getting fileNames for the monitoring
|
||||||
List<String> fileNames = new ArrayList<String>();
|
List<String> fileNames = new ArrayList<String>();
|
||||||
if (fileset != null)
|
if (fileset != null)
|
||||||
fileNames = Arrays.asList(fileset).stream().map(f -> f.getName())
|
fileNames = Arrays.asList(fileset).stream().map(f -> f.getName()).collect(Collectors.toList());
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
Access access;
|
Access access;
|
||||||
// If the maxOccurs is not 1
|
// If the maxOccurs is not 1
|
||||||
|
@ -674,24 +674,17 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
LOG.info("The gCube Profile with the section " + sectionJSONPath
|
LOG.info("The gCube Profile with the section " + sectionJSONPath
|
||||||
+ " has maxOccurs > 1 need to manage it as array, going to add the array index");
|
+ " has maxOccurs > 1 need to manage it as array, going to add the array index");
|
||||||
String arraySectionJSONPAth = String.format("%s[%d]", sectionJSONPath, jpcV);
|
String arraySectionJSONPAth = String.format("%s[%d]", sectionJSONPath, jpcV);
|
||||||
LOG.debug("registering the fileset in the array section: " + sectionJSONPath);
|
LOG.debug("registering the fileset in the array section: " + arraySectionJSONPAth);
|
||||||
|
|
||||||
|
|
||||||
access = ConvertToDataServiceModel.getAccessFromDocumentSection(theJSONDocument,
|
access = ConvertToDataServiceModel.getAccessFromDocumentSection(theJSONDocument,
|
||||||
arraySectionJSONPAth);
|
arraySectionJSONPAth);
|
||||||
|
|
||||||
// 1..N Monitoring Registering Fileset
|
monitoredRegisteredFileset(mongoService, monitorActions, profileID, theProject,
|
||||||
MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS,
|
arraySectionJSONPAth, filePath.getFieldName(), filePath.getFieldDefinition(), access,
|
||||||
"Registering and indexing the fileset: " + fileNames);
|
fileset);
|
||||||
monitorActions.pushAction(action);
|
|
||||||
|
|
||||||
mongoService.registerFileSet(profileID, theProject, arraySectionJSONPAth,
|
// mongoService.registerFileSet(profileID, theProject, arraySectionJSONPAth,
|
||||||
filePath.getFieldName(), filePath.getFieldDefinition(), access, fileset);
|
// filePath.getFieldName(), filePath.getFieldDefinition(), access, fileset);
|
||||||
|
|
||||||
// 1..N Monitoring Fileset uploaded action completed
|
|
||||||
action.setMsg("Fileset " + fileNames + " registered correclty");
|
|
||||||
action.setStatus(STATUS.DONE);
|
|
||||||
monitorActions.overrideAction(action);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
LOG.info("The gCube Profile with the section " + sectionJSONPath + " has maxOccurs = 1");
|
LOG.info("The gCube Profile with the section " + sectionJSONPath + " has maxOccurs = 1");
|
||||||
|
@ -699,18 +692,12 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
access = ConvertToDataServiceModel.getAccessFromDocumentSection(theJSONDocument,
|
access = ConvertToDataServiceModel.getAccessFromDocumentSection(theJSONDocument,
|
||||||
sectionJSONPath);
|
sectionJSONPath);
|
||||||
|
|
||||||
// 1..N Monitoring Registering Fileset
|
monitoredRegisteredFileset(mongoService, monitorActions, profileID, theProject, sectionJSONPath,
|
||||||
MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS,
|
filePath.getFieldName(), filePath.getFieldDefinition(), access, fileset);
|
||||||
"Registering and indexing the fileset: " + fileNames);
|
|
||||||
monitorActions.pushAction(action);
|
|
||||||
|
|
||||||
mongoService.registerFileSet(profileID, theProject, sectionJSONPath, filePath.getFieldName(),
|
// mongoService.registerFileSet(profileID, theProject, sectionJSONPath, filePath.getFieldName(),
|
||||||
filePath.getFieldDefinition(), access, fileset);
|
// filePath.getFieldDefinition(), access, fileset);
|
||||||
|
|
||||||
// 1..N Monitoring Fileset uploaded action completed
|
|
||||||
action.setMsg("Fileset " + fileNames + " registered correclty");
|
|
||||||
action.setStatus(STATUS.DONE);
|
|
||||||
monitorActions.overrideAction(action);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -725,6 +712,44 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void monitoredRegisteredFileset(final MongoServiceUtil mongoService,
|
||||||
|
final MonitoringActionsOnServer monitorActions, String profileID, Project theProject,
|
||||||
|
String sectionJSONPath, String fieldName, String fieldDefinition, Access access, File... fileset) {
|
||||||
|
|
||||||
|
// Getting fileNames for the monitoring
|
||||||
|
List<String> fileNames = new ArrayList<String>();
|
||||||
|
if (fileset != null)
|
||||||
|
fileNames = Arrays.asList(fileset).stream().map(f -> f.getName()).collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 1..N Monitoring Registering Fileset
|
||||||
|
MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS,
|
||||||
|
"Registering and indexing the fileset: " + fileNames);
|
||||||
|
monitorActions.pushAction(action);
|
||||||
|
|
||||||
|
boolean error = false;
|
||||||
|
try {
|
||||||
|
|
||||||
|
mongoService.registerFileSet(profileID, theProject, sectionJSONPath, fieldName, fieldDefinition, access,
|
||||||
|
fileset);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
error = true;
|
||||||
|
LOG.error("Error on registering fileset: ", e);
|
||||||
|
// 1..N Monitoring Fileset not registered
|
||||||
|
action.setMsg("Fileset " + fileNames + " not registered. Error: "+e.getMessage());
|
||||||
|
action.setStatus(STATUS.FAILED);
|
||||||
|
monitorActions.overrideAction(action);
|
||||||
|
} finally {
|
||||||
|
if (!error) {
|
||||||
|
// 1..N Monitoring Fileset registered correctly completed
|
||||||
|
action.setMsg("Fileset " + fileNames + " registered correctly");
|
||||||
|
action.setStatus(STATUS.DONE);
|
||||||
|
monitorActions.overrideAction(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collect files.
|
* Collect files.
|
||||||
*
|
*
|
||||||
|
@ -1183,7 +1208,6 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
throw new Exception(error);
|
throw new Exception(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updating count of Documents in session per profileID
|
// Updating count of Documents in session per profileID
|
||||||
Integer totalProjectForProfile = client.getTotalDocument(profileID);
|
Integer totalProjectForProfile = client.getTotalDocument(profileID);
|
||||||
SessionUtil.setTotalDocumentForProfileID(getThreadLocalRequest(), profileID, totalProjectForProfile);
|
SessionUtil.setTotalDocumentForProfileID(getThreadLocalRequest(), profileID, totalProjectForProfile);
|
||||||
|
@ -1218,7 +1242,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
Document updatedDocument = Serialization.read(jsonUpdate, Document.class);
|
Document updatedDocument = Serialization.read(jsonUpdate, Document.class);
|
||||||
LOG.info("updatedDocument is {}", updatedDocument);
|
LOG.info("updatedDocument is {}", updatedDocument);
|
||||||
Project project = client.updateProject(profileID, projectID, updatedDocument);
|
Project project = client.updateProject(profileID, projectID, updatedDocument);
|
||||||
LOG.info("Project with id " + project.getId() + " updated correclty");
|
LOG.info("Project with id " + project.getId() + " updated correctly");
|
||||||
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
||||||
return ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder);
|
return ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
Loading…
Reference in New Issue