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){
|
private static void scanRelation(ArrayList chain,RelationshipNavigationObject obj, boolean putBefore){
|
||||||
if(putBefore)chain.add(0,obj.getTarget());
|
if(putBefore)chain.add(0,obj.getTarget());
|
||||||
else chain.add(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_CLASS="Application";
|
||||||
// InterfaceConstants.SERVICE_NAME="GeoPortal";
|
// InterfaceConstants.SERVICE_NAME="GeoPortal";
|
||||||
|
|
||||||
// testContext = "/pred4s/preprod/preVRE";
|
testContext = "/pred4s/preprod/preVRE";
|
||||||
testContext= "/gcube/devsec/devVRE";
|
// testContext= "/gcube/devsec/devVRE";
|
||||||
|
|
||||||
System.out.println("TEST CONTEXT = "+testContext);
|
System.out.println("TEST CONTEXT = "+testContext);
|
||||||
return testContext;
|
return testContext;
|
||||||
|
|
|
@ -518,78 +518,100 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id": "org.gcube.portlets.user.geoportal-basic-data-list",
|
"_id": "org.gcube.portlets.user.geoportal-basic-data-list",
|
||||||
"_type": "BASIC_DATA_LIST_GUI",
|
"_type": "BASIC_DATA_LIST_GUI",
|
||||||
"_configuration": {
|
"_configuration": {
|
||||||
"itemFields": [
|
"itemFields": [
|
||||||
{
|
{
|
||||||
"label": "Any Field",
|
"label": "Any Field",
|
||||||
"paths": [
|
"paths": [
|
||||||
"_theDocument.nome",
|
"_theDocument.nome",
|
||||||
"_theDocument.introduzione",
|
"_theDocument.introduzione",
|
||||||
"_theDocument.authors",
|
"_theDocument.authors",
|
||||||
"_theDocument.contributore",
|
"_theDocument.contributore",
|
||||||
"_theDocument.titolari",
|
"_theDocument.titolari",
|
||||||
"_theDocument.editore",
|
"_theDocument.editore",
|
||||||
"_theDocument.responsabile",
|
"_theDocument.responsabile",
|
||||||
"_theDocument.paroleChiaveLibere",
|
"_theDocument.paroleChiaveLibere",
|
||||||
"_theDocument.paroleChiaveICCD"
|
"_theDocument.paroleChiaveICCD"
|
||||||
],
|
],
|
||||||
"operator": "$or",
|
"operator": "$or",
|
||||||
"searchable": true,
|
"searchable": true,
|
||||||
"sortable": false,
|
"sortable": false,
|
||||||
"asResult": false
|
"asResult": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Name",
|
"label": "Name",
|
||||||
"paths": [
|
"paths": [
|
||||||
"_theDocument.nome"
|
"_theDocument.nome"
|
||||||
],
|
],
|
||||||
"operator": "$and",
|
"operator": "$and",
|
||||||
"searchable": true,
|
"searchable": true,
|
||||||
"sortable": true,
|
"sortable": true,
|
||||||
"asResult": true
|
"asResult": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Introduction",
|
"label": "Introduction",
|
||||||
"paths": [
|
"paths": [
|
||||||
"_theDocument.introduzione"
|
"_theDocument.introduzione"
|
||||||
],
|
],
|
||||||
"operator": "$and",
|
"operator": "$and",
|
||||||
"searchable": true,
|
"searchable": true,
|
||||||
"sortable": false,
|
"sortable": false,
|
||||||
"asResult": true
|
"asResult": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Director/Staff",
|
"label": "Project Start",
|
||||||
"paths": [
|
"paths": [
|
||||||
"_theDocument.authors",
|
"_theDocument.dataInizioProgetto"
|
||||||
"_theDocument.contributore",
|
],
|
||||||
"_theDocument.titolari",
|
"operator": "$and",
|
||||||
"_theDocument.editore",
|
"searchable": false,
|
||||||
"_theDocument.responsabile"
|
"sortable": false,
|
||||||
],
|
"asResult": true
|
||||||
"operator": "$or",
|
},
|
||||||
"searchable": true,
|
{
|
||||||
"sortable": false,
|
"label": "Director/Staff",
|
||||||
"asResult": true
|
"paths": [
|
||||||
},
|
"_theDocument.authors",
|
||||||
{
|
"_theDocument.contributore",
|
||||||
"label": "Keywords",
|
"_theDocument.titolari",
|
||||||
"paths": [
|
"_theDocument.editore",
|
||||||
"_theDocument.paroleChiaveLibere",
|
"_theDocument.responsabile"
|
||||||
"_theDocument.paroleChiaveICCD"
|
],
|
||||||
],
|
"operator": "$or",
|
||||||
"operator": "$or",
|
"searchable": true,
|
||||||
"searchable": true,
|
"sortable": false,
|
||||||
"sortable": false,
|
"asResult": true
|
||||||
"asResult": true
|
},
|
||||||
|
{
|
||||||
|
"label": "Keywords",
|
||||||
|
"paths": [
|
||||||
|
"_theDocument.paroleChiaveLibere",
|
||||||
|
"_theDocument.paroleChiaveICCD"
|
||||||
|
],
|
||||||
|
"operator": "$or",
|
||||||
|
"searchable": true,
|
||||||
|
"sortable": false,
|
||||||
|
"asResult": true
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
}
|
,
|
||||||
},
|
{
|
||||||
|
"_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",
|
"_id": "org.gcube.portlets.user.geoportal-workflow-action-list",
|
||||||
"_type": "WORKFLOW_ACTION_LIST_GUI",
|
"_type": "WORKFLOW_ACTION_LIST_GUI",
|
||||||
|
|
|
@ -90,36 +90,37 @@ public class ExportConcessioniAsProjects {
|
||||||
AtomicLong warnCount = new AtomicLong(0);
|
AtomicLong warnCount = new AtomicLong(0);
|
||||||
AtomicLong errCount = new AtomicLong(0);
|
AtomicLong errCount = new AtomicLong(0);
|
||||||
|
|
||||||
ExecutorService service = Executors.newFixedThreadPool(3);
|
ExecutorService service = Executors.newFixedThreadPool(1);
|
||||||
|
|
||||||
long startProcess = System.currentTimeMillis();
|
long startProcess = System.currentTimeMillis();
|
||||||
|
|
||||||
importFolder.getRelationshipMap().forEach((s,l)->{
|
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
|
// Check if exists
|
||||||
Concessione c = l.get(0);
|
Concessione c = l.get(0);
|
||||||
try {
|
try {
|
||||||
List<Project> existing= getExisting(c,client);
|
List<Project> existing= getExisting(c,client);
|
||||||
if(existing.isEmpty()) {
|
if(existing.isEmpty()) log.info("Not Found {}",c.getNome());
|
||||||
log.info("Not Found");
|
else {
|
||||||
}else {
|
// found projects, check status
|
||||||
existing.forEach(project -> {
|
existing.forEach(project -> {
|
||||||
if (!project.getLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK))
|
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());
|
log.debug("Deleting error set for {}",c.getNome());
|
||||||
for (Project project : existing) {
|
for (Project project : existing) {
|
||||||
client.deleteById(project.getId());
|
client.deleteById(project.getId());
|
||||||
}
|
}
|
||||||
}
|
}else publish.set(false);
|
||||||
}
|
}
|
||||||
}catch(NullPointerException e){}
|
}catch(NullPointerException e){}
|
||||||
catch (Throwable t){throw new RuntimeException("Unexpected Exception while checking for "+c.getNome());}
|
catch (Throwable t){throw new RuntimeException("Unexpected Exception while checking for "+c.getNome());}
|
||||||
|
|
||||||
|
log.info("Project name {} publish : {}",s,publish);
|
||||||
if(!isSetOk.get()) {
|
if(publish.get()) {
|
||||||
String relationshipTarget = null;
|
String relationshipTarget = null;
|
||||||
for (Concessione concessione : l) {
|
for (Concessione concessione : l) {
|
||||||
|
|
||||||
|
@ -426,7 +427,7 @@ public class ExportConcessioniAsProjects {
|
||||||
private static List<Project> getExisting(Concessione c,Projects client) throws RemoteException, JsonProcessingException, NullPointerException {
|
private static List<Project> getExisting(Concessione c,Projects client) throws RemoteException, JsonProcessingException, NullPointerException {
|
||||||
try {
|
try {
|
||||||
QueryRequest req = new QueryRequest();
|
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);
|
log.debug("Query String is {}", queryString);
|
||||||
req.setFilter(Document.parse(queryString));
|
req.setFilter(Document.parse(queryString));
|
||||||
AtomicInteger count = new AtomicInteger(0);
|
AtomicInteger count = new AtomicInteger(0);
|
||||||
|
@ -446,4 +447,59 @@ public class ExportConcessioniAsProjects {
|
||||||
throw t;
|
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