improved the monitoring..

This commit is contained in:
Francesco Mangiacrapa 2024-10-15 12:41:11 +02:00
parent 39efa4b27c
commit 6617655492
2 changed files with 76 additions and 52 deletions

View File

@ -905,7 +905,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
break;
case FAILED:
icon = new Icon(IconType.WARNING_SIGN);
icon.getElement().getStyle().setColor("#800000");
icon.getElement().getStyle().setColor("#FF0000");
icon.setSize(IconSize.TWO_TIMES);
icon.setTitle(action.getStatus().getLabel());
break;

View File

@ -172,18 +172,18 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
MongoServiceUtil mongoService = new MongoServiceUtil();
String theDocumentString = null;
try {
// 1. Action to Monitoring
MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS,
"Converting project metadata to Geoportal data model");
action = monitoringActionsOnServer.pushAction(action);
// // 1. Action to Monitoring
// MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS,
// "Converting project metadata to Geoportal data model");
// action = monitoringActionsOnServer.pushAction(action);
FormDataObjectToJSON metadataConverter = new FormDataObjectToJSON();
JSONObject theDocument = metadataConverter.convert(tree_Node, null);
// 1. Action completed
action.setMsg("Converted project metadata to Geoportal data model");
action.setStatus(STATUS.DONE);
monitoringActionsOnServer.overrideAction(action);
// // 1. Action completed
// action.setMsg("Converted project metadata to Geoportal data model");
// action.setStatus(STATUS.DONE);
// monitoringActionsOnServer.overrideAction(action);
theDocumentString = theDocument.toString();
LOG.info("Got Document: " + theDocumentString);
@ -199,13 +199,13 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
LOG.debug("Going to create the project...");
// 2. Action to Monitoring
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);
theProject = mongoService.createNew(profileID, theDocumentString);
// 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);
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);
// Reading again the project to be sure
updatedProject = client.getProjectByID(profileID, projectID);
@ -591,7 +591,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
Map<String, FileSetDataObject> collectFilesetPerFieldDef = new HashMap<String, FileSetDataObject>();
List<FileUploaded> files = gdb.getFilesUploaded();
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
// MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS,
// "Copying file/s: " + fileNames);
@ -647,7 +648,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
}
// 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);
// monitorActions.overrideAction(action);
@ -665,8 +666,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
// 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());
fileNames = Arrays.asList(fileset).stream().map(f -> f.getName()).collect(Collectors.toList());
Access access;
// 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
+ " has maxOccurs > 1 need to manage it as array, going to add the array index");
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,
arraySectionJSONPAth);
// 1..N Monitoring Registering Fileset
MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS,
"Registering and indexing the fileset: " + fileNames);
monitorActions.pushAction(action);
monitoredRegisteredFileset(mongoService, monitorActions, profileID, theProject,
arraySectionJSONPAth, filePath.getFieldName(), filePath.getFieldDefinition(), access,
fileset);
mongoService.registerFileSet(profileID, theProject, arraySectionJSONPAth,
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);
// mongoService.registerFileSet(profileID, theProject, arraySectionJSONPAth,
// filePath.getFieldName(), filePath.getFieldDefinition(), access, fileset);
} else {
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,
sectionJSONPath);
// 1..N Monitoring Registering Fileset
MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS,
"Registering and indexing the fileset: " + fileNames);
monitorActions.pushAction(action);
monitoredRegisteredFileset(mongoService, monitorActions, profileID, theProject, sectionJSONPath,
filePath.getFieldName(), filePath.getFieldDefinition(), access, fileset);
mongoService.registerFileSet(profileID, theProject, sectionJSONPath, filePath.getFieldName(),
filePath.getFieldDefinition(), access, fileset);
// mongoService.registerFileSet(profileID, theProject, sectionJSONPath, 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);
}
}
@ -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.
*
@ -1183,7 +1208,6 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
throw new Exception(error);
}
// Updating count of Documents in session per profileID
Integer totalProjectForProfile = client.getTotalDocument(profileID);
SessionUtil.setTotalDocumentForProfileID(getThreadLocalRequest(), profileID, totalProjectForProfile);
@ -1218,7 +1242,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
Document updatedDocument = Serialization.read(jsonUpdate, Document.class);
LOG.info("updatedDocument is {}", 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);
return ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder);
} catch (Exception e) {