Compare commits
3 Commits
633cf8ee5c
...
cdff7547a5
Author | SHA1 | Date |
---|---|---|
Fabio Sinibaldi | cdff7547a5 | |
Fabio Sinibaldi | 9954a653f7 | |
Fabio Sinibaldi | e58c3009e9 |
|
@ -266,6 +266,7 @@ public class ConcessioniLifeCycleManager extends Default3PhaseManager implements
|
|||
private static void scanRelation(ArrayList chain,RelationshipNavigationObject obj, boolean putBefore){
|
||||
if(putBefore)chain.add(0,obj.getTarget());
|
||||
else chain.add(obj.getTarget());
|
||||
if(obj.getChildren()!=null && !obj.getChildren().isEmpty())scanRelation(chain,obj,putBefore);
|
||||
if(obj.getChildren()!=null)
|
||||
obj.getChildren().forEach(r-> scanRelation(chain,r,putBefore));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ public class GCubeTest {
|
|||
// InterfaceConstants.SERVICE_CLASS="Application";
|
||||
// InterfaceConstants.SERVICE_NAME="GeoPortal";
|
||||
|
||||
// testContext = "/pred4s/preprod/preVRE";
|
||||
testContext= "/gcube/devsec/devVRE";
|
||||
testContext = "/pred4s/preprod/preVRE";
|
||||
// testContext= "/gcube/devsec/devVRE";
|
||||
|
||||
System.out.println("TEST CONTEXT = "+testContext);
|
||||
return testContext;
|
||||
|
|
|
@ -561,6 +561,16 @@
|
|||
"sortable": false,
|
||||
"asResult": true
|
||||
},
|
||||
{
|
||||
"label": "Project Start",
|
||||
"paths": [
|
||||
"_theDocument.dataInizioProgetto"
|
||||
],
|
||||
"operator": "$and",
|
||||
"searchable": false,
|
||||
"sortable": false,
|
||||
"asResult": true
|
||||
},
|
||||
{
|
||||
"label": "Director/Staff",
|
||||
"paths": [
|
||||
|
@ -588,8 +598,20 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
,
|
||||
{
|
||||
"_id": "org.gcube.portlets.user.geoportal-timeline-json-template",
|
||||
"_type": "TIMELINE_JSON_TEMPLATE",
|
||||
"_configuration": {
|
||||
"tjt_document": {
|
||||
"content": "$.nome",
|
||||
"title": "$.nome",
|
||||
"start": "$.dataInizioProgetto",
|
||||
"end": "$.dataFineProgetto"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"_id": "org.gcube.portlets.user.geoportal-workflow-action-list",
|
||||
"_type": "WORKFLOW_ACTION_LIST_GUI",
|
||||
|
|
|
@ -90,36 +90,37 @@ public class ExportConcessioniAsProjects {
|
|||
AtomicLong warnCount = new AtomicLong(0);
|
||||
AtomicLong errCount = new AtomicLong(0);
|
||||
|
||||
ExecutorService service = Executors.newFixedThreadPool(3);
|
||||
ExecutorService service = Executors.newFixedThreadPool(1);
|
||||
|
||||
long startProcess = System.currentTimeMillis();
|
||||
|
||||
importFolder.getRelationshipMap().forEach((s,l)->{
|
||||
|
||||
AtomicReference<Boolean> isSetOk = new AtomicReference<>(true);
|
||||
AtomicReference<Boolean> publish = new AtomicReference<>(true);
|
||||
AtomicReference<Boolean> delete = new AtomicReference<>(false);
|
||||
// Check if exists
|
||||
Concessione c = l.get(0);
|
||||
try {
|
||||
List<Project> existing= getExisting(c,client);
|
||||
if(existing.isEmpty()) {
|
||||
log.info("Not Found");
|
||||
}else {
|
||||
if(existing.isEmpty()) log.info("Not Found {}",c.getNome());
|
||||
else {
|
||||
// found projects, check status
|
||||
existing.forEach(project -> {
|
||||
if (!project.getLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK))
|
||||
isSetOk.set(false);
|
||||
delete.set(true);
|
||||
});
|
||||
if(!isSetOk.get()){
|
||||
if(delete.get()){
|
||||
log.debug("Deleting error set for {}",c.getNome());
|
||||
for (Project project : existing) {
|
||||
client.deleteById(project.getId());
|
||||
}
|
||||
}
|
||||
}else publish.set(false);
|
||||
}
|
||||
}catch(NullPointerException e){}
|
||||
catch (Throwable t){throw new RuntimeException("Unexpected Exception while checking for "+c.getNome());}
|
||||
|
||||
|
||||
if(!isSetOk.get()) {
|
||||
log.info("Project name {} publish : {}",s,publish);
|
||||
if(publish.get()) {
|
||||
String relationshipTarget = null;
|
||||
for (Concessione concessione : l) {
|
||||
|
||||
|
@ -426,7 +427,7 @@ public class ExportConcessioniAsProjects {
|
|||
private static List<Project> getExisting(Concessione c,Projects client) throws RemoteException, JsonProcessingException, NullPointerException {
|
||||
try {
|
||||
QueryRequest req = new QueryRequest();
|
||||
String queryString = String.format("{\"_theDocument.nome\" :{\"$eq\" : \"%1$s\"}}", c.getNome());
|
||||
String queryString = String.format("{\"_theDocument.nome\" :{\"$eq\" : %1$s}}", quote(c.getNome()));
|
||||
log.debug("Query String is {}", queryString);
|
||||
req.setFilter(Document.parse(queryString));
|
||||
AtomicInteger count = new AtomicInteger(0);
|
||||
|
@ -446,4 +447,59 @@ public class ExportConcessioniAsProjects {
|
|||
throw t;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String quote(String string) {
|
||||
if (string == null || string.length() == 0) {
|
||||
return "\"\"";
|
||||
}
|
||||
|
||||
char c = 0;
|
||||
int i;
|
||||
int len = string.length();
|
||||
StringBuilder sb = new StringBuilder(len + 4);
|
||||
String t;
|
||||
|
||||
sb.append('"');
|
||||
for (i = 0; i < len; i += 1) {
|
||||
c = string.charAt(i);
|
||||
switch (c) {
|
||||
case '\\':
|
||||
case '"':
|
||||
sb.append('\\');
|
||||
sb.append(c);
|
||||
break;
|
||||
case '/':
|
||||
// if (b == '<') {
|
||||
sb.append('\\');
|
||||
// }
|
||||
sb.append(c);
|
||||
break;
|
||||
case '\b':
|
||||
sb.append("\\b");
|
||||
break;
|
||||
case '\t':
|
||||
sb.append("\\t");
|
||||
break;
|
||||
case '\n':
|
||||
sb.append("\\n");
|
||||
break;
|
||||
case '\f':
|
||||
sb.append("\\f");
|
||||
break;
|
||||
case '\r':
|
||||
sb.append("\\r");
|
||||
break;
|
||||
default:
|
||||
if (c < ' ') {
|
||||
t = "000" + Integer.toHexString(c);
|
||||
sb.append("\\u" + t.substring(t.length() - 4));
|
||||
} else {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
sb.append('"');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue