Bulk reupload concessione
This commit is contained in:
parent
2bd5336eee
commit
e0daa09d6f
|
@ -19,9 +19,9 @@ import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPl
|
|||
public class ClearConcessioni {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// String context="/gcube/devsec/devVRE";
|
||||
String context="/gcube/devsec/devVRE";
|
||||
|
||||
String context="/pred4s/preprod/preVRE";
|
||||
//String context="/pred4s/preprod/preVRE";
|
||||
|
||||
TokenSetter.set(context);
|
||||
|
||||
|
@ -38,8 +38,8 @@ public class ClearConcessioni {
|
|||
AtomicLong found=new AtomicLong(0);
|
||||
|
||||
Iterator<Concessione> it=null;
|
||||
// it=manager.getList();
|
||||
it=manager.search("{\"nome\" : {$regex : \"Mock .*\"}, \"creationTime\" :{$gt : \"2021-10-18T13:58:53.326\"}}");
|
||||
it=manager.getList();
|
||||
// it=manager.search("{\"nome\" : {$regex : \"Mock .*\"}, \"creationTime\" :{$gt : \"2021-10-18T13:58:53.326\"}}");
|
||||
|
||||
ExecutorService service = Executors.newFixedThreadPool(3);
|
||||
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
package org.gcube.application.cms.usecases;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.gcube.application.cms.tests.TokenSetter;
|
||||
import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.common.rest.Projects;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.projects;
|
||||
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.statefulMongoConcessioni;
|
||||
|
||||
@Slf4j
|
||||
public class ClearProjects {
|
||||
|
||||
public static void main(String[] args) throws RemoteException, InterruptedException {
|
||||
String context="/gcube/devsec/devVRE";
|
||||
|
||||
//String context="/pred4s/preprod/preVRE";
|
||||
|
||||
TokenSetter.set(context);
|
||||
|
||||
Projects<Project> client=projects("profiledConcessioni").build();;
|
||||
|
||||
|
||||
ArrayList<String> toSkipIds=new ArrayList<>();
|
||||
// toSkipIds.add("6102c8dd02ad3d05b5f81df4");
|
||||
// toSkipIds.add("610415af02ad3d05b5f81ee3");
|
||||
|
||||
AtomicLong count=new AtomicLong(0);
|
||||
AtomicLong nullCount=new AtomicLong(0);
|
||||
AtomicLong errCount=new AtomicLong(0);
|
||||
AtomicLong found=new AtomicLong(0);
|
||||
|
||||
Iterator<Project> it=null;
|
||||
it=client.query(new QueryRequest());
|
||||
// it=manager.search("{\"nome\" : {$regex : \"Mock .*\"}, \"creationTime\" :{$gt : \"2021-10-18T13:58:53.326\"}}");
|
||||
|
||||
ExecutorService service = Executors.newFixedThreadPool(3);
|
||||
|
||||
|
||||
it.forEachRemaining((Project c)->{
|
||||
found.incrementAndGet();
|
||||
service.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
TokenSetter.set(context);
|
||||
String currentId=c.getId();
|
||||
if(currentId==null) {
|
||||
System.out.println("ID IS NULL " + c);
|
||||
nullCount.incrementAndGet();
|
||||
}
|
||||
else
|
||||
if(toSkipIds.contains(currentId))
|
||||
System.out.println("Skipping "+currentId);
|
||||
else {
|
||||
System.out.println("Deleting " + c.getId());
|
||||
client.deleteById(c.getId(),true);
|
||||
}
|
||||
}catch(Throwable throwable){
|
||||
System.err.println(throwable);
|
||||
errCount.incrementAndGet();
|
||||
try {Thread.sleep(1000);} catch (InterruptedException i) {}
|
||||
}finally {
|
||||
count.incrementAndGet();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
while (!service.awaitTermination(1, TimeUnit.MINUTES)) {
|
||||
log.info("Waiting .. completed {}, out of {} ",count.get(),found.get());
|
||||
if(found.get()==count.get()) service.shutdown();
|
||||
}
|
||||
|
||||
System.out.println("Done "+count.get()+" [null : "+nullCount.get()+", err : "+errCount.get()+"]");
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.bson.Document;
|
||||
import org.gcube.application.cms.custom.gna.concessioni.model.ProfiledConcessione;
|
||||
import org.gcube.application.cms.tests.TokenSetter;
|
||||
import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI;
|
||||
import org.gcube.application.geoportal.client.utils.Serialization;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.legacy.*;
|
||||
|
@ -14,20 +13,21 @@ import org.gcube.application.geoportal.common.rest.Projects;
|
|||
import org.gcube.application.geoportal.common.utils.FileSets;
|
||||
import org.gcube.application.geoportal.common.utils.Files;
|
||||
import org.gcube.application.geoportal.common.utils.StorageUtils;
|
||||
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
||||
|
||||
import javax.print.Doc;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.projects;
|
||||
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.statefulMongoConcessioni;
|
||||
|
||||
@Slf4j
|
||||
public class ExportConcessioniAsProjects {
|
||||
|
@ -37,7 +37,7 @@ public class ExportConcessioniAsProjects {
|
|||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// read from imported folder
|
||||
File dir= new File("/Users/fabioisti/git/gcube-cms-suite/import1652276569045");
|
||||
String targetContext="/gcube/devsec/devVRE";
|
||||
|
@ -68,197 +68,25 @@ public class ExportConcessioniAsProjects {
|
|||
AtomicLong warnCount = new AtomicLong(0);
|
||||
AtomicLong errCount = new AtomicLong(0);
|
||||
|
||||
FileSets.RequestBuilder req=null;
|
||||
ExecutorService service = Executors.newFixedThreadPool(3);
|
||||
|
||||
long startProcess = System.currentTimeMillis();
|
||||
|
||||
|
||||
for (Concessione c : found) {
|
||||
try {
|
||||
log.info("Using {} {}",c.getNome(),c.getMongo_id());
|
||||
|
||||
//Copy core fields
|
||||
|
||||
Document doc=new Document();
|
||||
doc.put(ProfiledConcessione.NOME,c.getNome());
|
||||
doc.put(ProfiledConcessione.INTRODUZIONE,c.getIntroduzione());
|
||||
doc.put(ProfiledConcessione.DESCRIZIONE_CONTENUTO,c.getDescrizioneContenuto());
|
||||
doc.put(ProfiledConcessione.AUTHORS,c.getAuthors());
|
||||
doc.put(ProfiledConcessione.CONTRIBUTORE,c.getContributore());
|
||||
doc.put(ProfiledConcessione.TITOLARI,c.getTitolari());
|
||||
doc.put(ProfiledConcessione.RESPONSABILE,c.getResponsabile());
|
||||
doc.put(ProfiledConcessione.EDITORS,c.getEditore());
|
||||
doc.put(ProfiledConcessione.FONTI_FINANZIAMENTO,c.getFontiFinanziamento());
|
||||
doc.put(ProfiledConcessione.SOGGETTO,c.getSoggetto());
|
||||
doc.put(ProfiledConcessione.RISORSE_CORRELATE,c.getRisorseCorrelate());
|
||||
doc.put(ProfiledConcessione.DATA_INZIO_PROGETTO,c.getDataInizioProgetto());
|
||||
doc.put(ProfiledConcessione.DATA_FINE_PROGETTO,c.getDataFineProgetto());
|
||||
doc.put(ProfiledConcessione.TITOLARE_LICENZA,c.getTitolareLicenza());
|
||||
doc.put(ProfiledConcessione.TITOLARE_COPYRIGHT,c.getTitolareCopyright());
|
||||
doc.put(ProfiledConcessione.PAROLE_CHIAVE_LIBERE,c.getParoleChiaveLibere());
|
||||
doc.put(ProfiledConcessione.PAREOLE_CHIAVE_ICCD,c.getParoleChiaveICCD());
|
||||
|
||||
// CREATE Project
|
||||
Project project = client.createNew(doc);
|
||||
|
||||
// Relazione
|
||||
if(c.getRelazioneScavo()!=null) {
|
||||
RelazioneScavo rel=c.getRelazioneScavo();
|
||||
Document relDoc= new Document();
|
||||
relDoc.put(ProfiledConcessione.Sections.TITOLO,rel.getTitolo());
|
||||
relDoc.put(ProfiledConcessione.Relazione.RESPONSABILI,rel.getResponsabili());
|
||||
relDoc.put(ProfiledConcessione.SOGGETTO,rel.getSoggetto());
|
||||
|
||||
Document updated =project.getTheDocument();
|
||||
updated.put(ProfiledConcessione.RELAZIONE_SCAVO,relDoc);
|
||||
project = client.updateDocument(project.getId(),updated);
|
||||
|
||||
List<PersistedContent> content=rel.getActualContent();
|
||||
if(content!=null && !content.isEmpty()) {
|
||||
req = FileSets.build("$." + ProfiledConcessione.RELAZIONE_SCAVO, "fileset",
|
||||
"$." + ProfiledConcessione.RELAZIONE_SCAVO + "." + Field.CHILDREN
|
||||
+ "[?(@.fileset)]");
|
||||
req.addAll(upload(content,storage));
|
||||
project = client.registerFileSet(project.getId(),req.getTheRequest());
|
||||
}
|
||||
// upload fileset
|
||||
found.forEach(c -> {
|
||||
service.submit(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
publish(c,client,storage,errCount,count);
|
||||
}
|
||||
} );
|
||||
});
|
||||
|
||||
|
||||
if(c.getAbstractRelazione()!=null) {
|
||||
AbstractRelazione abs=c.getAbstractRelazione();
|
||||
Document absDoc= new Document();
|
||||
absDoc.put(ProfiledConcessione.Sections.TITOLO,abs.getTitolo());
|
||||
absDoc.put(ProfiledConcessione.AbstractRelazione.ABSTRACT_ENG,abs.getAbstractEng());
|
||||
absDoc.put(ProfiledConcessione.AbstractRelazione.ABSTRACT_ITA,abs.getAbstractIta());
|
||||
|
||||
|
||||
Document updated =project.getTheDocument();
|
||||
updated.put(ProfiledConcessione.ABSTRACT_RELAZIONE,absDoc);
|
||||
project = client.updateDocument(project.getId(),updated);
|
||||
|
||||
//TODO ask Fra about mapping
|
||||
// list persited content -> absIta, absEng
|
||||
|
||||
// List<PersistedContent> content=abs.getActualContent();
|
||||
// if(content!=null && !content.isEmpty()) {
|
||||
// req = FileSets.build("$." + ProfiledConcessione.RELAZIONE_SCAVO, "fileset",
|
||||
// "$." + ProfiledConcessione.RELAZIONE_SCAVO + "." + Field.CHILDREN
|
||||
// + "[?(@.fileset)]");
|
||||
// content.forEach(uploader);
|
||||
// project = client.registerFileSet(project.getId(),req.getTheRequest());
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
//Immagini rappresentative
|
||||
if(c.getImmaginiRappresentative()!=null){
|
||||
List<Document> imgs=new ArrayList<>();
|
||||
for (int i = 0; i < c.getImmaginiRappresentative().size(); i++) {
|
||||
UploadedImage img=c.getImmaginiRappresentative().get(i);
|
||||
Document imgDoc=new Document();
|
||||
imgDoc.put(ProfiledConcessione.Sections.TITOLO,img.getTitolo());
|
||||
imgDoc.put(ProfiledConcessione.Immagini.DIDASCALIA,img.getDidascalia());
|
||||
imgDoc.put(ProfiledConcessione.Relazione.RESPONSABILI,img.getResponsabili());
|
||||
imgDoc.put(ProfiledConcessione.SOGGETTO,img.getSoggetto());
|
||||
imgs.add(imgDoc);
|
||||
}
|
||||
|
||||
Document updated =project.getTheDocument();
|
||||
updated.put(ProfiledConcessione.IMMAGINI_RAPPRESENTATIVE,imgs);
|
||||
project = client.updateDocument(project.getId(),updated);
|
||||
|
||||
// FileSets
|
||||
for (int i = 0; i < c.getImmaginiRappresentative().size(); i++) {
|
||||
UploadedImage img=c.getImmaginiRappresentative().get(i);
|
||||
List<PersistedContent> content=img.getActualContent();
|
||||
if(content!=null && !content.isEmpty()) {
|
||||
req = FileSets.build("$." + ProfiledConcessione.IMMAGINI_RAPPRESENTATIVE+"["+i+"]", "fileset",
|
||||
"$." + ProfiledConcessione.IMMAGINI_RAPPRESENTATIVE + "." + Field.CHILDREN
|
||||
+ "[?(@.fileset)]");
|
||||
req.addAll(upload(content,storage));
|
||||
project = client.registerFileSet(project.getId(),req.getTheRequest());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// POS
|
||||
if(c.getPosizionamentoScavo()!=null) {
|
||||
LayerConcessione l=c.getPosizionamentoScavo();
|
||||
Document lDoc= new Document();
|
||||
lDoc.put(ProfiledConcessione.Sections.TITOLO,l.getTitolo());
|
||||
lDoc.put(ProfiledConcessione.RESPONSABILE,l.getResponsabile());
|
||||
lDoc.put(ProfiledConcessione.AUTHORS,l.getAuthors());
|
||||
lDoc.put(ProfiledConcessione.PAREOLE_CHIAVE_ICCD,l.getParoleChiaveICCD());
|
||||
lDoc.put(ProfiledConcessione.PAROLE_CHIAVE_LIBERE,l.getParoleChiaveLibere());
|
||||
lDoc.put(ProfiledConcessione.Layers.TOPIC,l.getTopicCategory());
|
||||
lDoc.put(ProfiledConcessione.Layers.SUB_TOPIC,l.getSubTopic());
|
||||
lDoc.put(ProfiledConcessione.Layers.METODO_RACCOLTA,l.getMetodoRaccoltaDati());
|
||||
lDoc.put(ProfiledConcessione.Layers.SCALA_ACQUISIZIONE,l.getScalaAcquisizione());
|
||||
lDoc.put(ProfiledConcessione.Layers.VALUTAZIONE_QUALITA,l.getValutazioneQualita());
|
||||
lDoc.put(ProfiledConcessione.Sections.ABSTRACT,l.getAbstractSection());
|
||||
|
||||
Document updated =project.getTheDocument();
|
||||
updated.put(ProfiledConcessione.POSIZIONAMENTO_SCAVO,lDoc);
|
||||
project = client.updateDocument(project.getId(),updated);
|
||||
|
||||
List<PersistedContent> content=l.getActualContent();
|
||||
if(content!=null && !content.isEmpty()) {
|
||||
req = FileSets.build("$." + ProfiledConcessione.POSIZIONAMENTO_SCAVO, "fileset",
|
||||
"$." + ProfiledConcessione.POSIZIONAMENTO_SCAVO + "." + Field.CHILDREN
|
||||
+ "[?(@.fileset)]");
|
||||
req.addAll(upload(content,storage));
|
||||
project = client.registerFileSet(project.getId(),req.getTheRequest());
|
||||
}
|
||||
// upload fileset
|
||||
}
|
||||
|
||||
// Piante
|
||||
if(c.getPianteFineScavo()!=null){
|
||||
List<Document> piante=new ArrayList<>();
|
||||
for (int i = 0; i < c.getPianteFineScavo().size(); i++) {
|
||||
LayerConcessione l=c.getPianteFineScavo().get(i);
|
||||
Document lDoc= new Document();
|
||||
lDoc.put(ProfiledConcessione.Sections.TITOLO,l.getTitolo());
|
||||
lDoc.put(ProfiledConcessione.RESPONSABILE,l.getResponsabile());
|
||||
lDoc.put(ProfiledConcessione.AUTHORS,l.getAuthors());
|
||||
lDoc.put(ProfiledConcessione.PAREOLE_CHIAVE_ICCD,l.getParoleChiaveICCD());
|
||||
lDoc.put(ProfiledConcessione.PAROLE_CHIAVE_LIBERE,l.getParoleChiaveLibere());
|
||||
lDoc.put(ProfiledConcessione.Layers.TOPIC,l.getTopicCategory());
|
||||
lDoc.put(ProfiledConcessione.Layers.SUB_TOPIC,l.getSubTopic());
|
||||
lDoc.put(ProfiledConcessione.Layers.METODO_RACCOLTA,l.getMetodoRaccoltaDati());
|
||||
lDoc.put(ProfiledConcessione.Layers.SCALA_ACQUISIZIONE,l.getScalaAcquisizione());
|
||||
lDoc.put(ProfiledConcessione.Layers.VALUTAZIONE_QUALITA,l.getValutazioneQualita());
|
||||
lDoc.put(ProfiledConcessione.Sections.ABSTRACT,l.getAbstractSection());
|
||||
piante.add(lDoc);
|
||||
}
|
||||
|
||||
Document updated =project.getTheDocument();
|
||||
updated.put(ProfiledConcessione.PIANTE_FINE_SCAVO,piante);
|
||||
project = client.updateDocument(project.getId(),updated);
|
||||
|
||||
// FileSets
|
||||
for (int i = 0; i < c.getImmaginiRappresentative().size(); i++) {
|
||||
UploadedImage img=c.getImmaginiRappresentative().get(i);
|
||||
List<PersistedContent> content=img.getActualContent();
|
||||
if(content!=null && !content.isEmpty()) {
|
||||
req = FileSets.build("$." + ProfiledConcessione.PIANTE_FINE_SCAVO+"["+i+"]", "fileset",
|
||||
"$." + ProfiledConcessione.PIANTE_FINE_SCAVO + "." + Field.CHILDREN
|
||||
+ "[?(@.fileset)]");
|
||||
req.addAll(upload(content,storage));
|
||||
project = client.registerFileSet(project.getId(),req.getTheRequest());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
System.err.println(throwable);
|
||||
errCount.incrementAndGet();
|
||||
} finally {
|
||||
count.incrementAndGet();
|
||||
}
|
||||
while (!service.awaitTermination(1, TimeUnit.MINUTES)) {
|
||||
log.info("Waiting .. completed {}, out of {} ",count.get(),found.size());
|
||||
if(found.size()==count.get()) service.shutdown();
|
||||
}
|
||||
|
||||
System.out.println("Done "+count.get()+" [warn : "+warnCount.get()+", err : "+errCount.get()+"]");
|
||||
System.out.println("Completed "+count.get()+" [elapsedTime = "+(System.currentTimeMillis()-startProcess)/1000+" sec] [warn : "+warnCount.get()+", err : "+errCount.get()+"]");
|
||||
|
||||
}
|
||||
|
||||
|
@ -273,4 +101,195 @@ public class ExportConcessioniAsProjects {
|
|||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
private static void publish(Concessione c, Projects<Project> client, StorageUtils storage, AtomicLong errCount,AtomicLong count){
|
||||
try {
|
||||
long startTime = System.currentTimeMillis();
|
||||
FileSets.RequestBuilder req=null;
|
||||
|
||||
log.info("Using {} {}",c.getNome(),c.getMongo_id());
|
||||
|
||||
//Copy core fields
|
||||
|
||||
Document doc=new Document();
|
||||
doc.put(ProfiledConcessione.NOME,c.getNome());
|
||||
doc.put(ProfiledConcessione.INTRODUZIONE,c.getIntroduzione());
|
||||
doc.put(ProfiledConcessione.DESCRIZIONE_CONTENUTO,c.getDescrizioneContenuto());
|
||||
doc.put(ProfiledConcessione.AUTHORS,c.getAuthors());
|
||||
doc.put(ProfiledConcessione.CONTRIBUTORE,c.getContributore());
|
||||
doc.put(ProfiledConcessione.TITOLARI,c.getTitolari());
|
||||
doc.put(ProfiledConcessione.RESPONSABILE,c.getResponsabile());
|
||||
doc.put(ProfiledConcessione.EDITORS,c.getEditore());
|
||||
doc.put(ProfiledConcessione.FONTI_FINANZIAMENTO,c.getFontiFinanziamento());
|
||||
doc.put(ProfiledConcessione.SOGGETTO,c.getSoggetto());
|
||||
doc.put(ProfiledConcessione.RISORSE_CORRELATE,c.getRisorseCorrelate());
|
||||
doc.put(ProfiledConcessione.DATA_INZIO_PROGETTO,c.getDataInizioProgetto());
|
||||
doc.put(ProfiledConcessione.DATA_FINE_PROGETTO,c.getDataFineProgetto());
|
||||
doc.put(ProfiledConcessione.TITOLARE_LICENZA,c.getTitolareLicenza());
|
||||
doc.put(ProfiledConcessione.TITOLARE_COPYRIGHT,c.getTitolareCopyright());
|
||||
doc.put(ProfiledConcessione.PAROLE_CHIAVE_LIBERE,c.getParoleChiaveLibere());
|
||||
doc.put(ProfiledConcessione.PAREOLE_CHIAVE_ICCD,c.getParoleChiaveICCD());
|
||||
|
||||
// CREATE Project
|
||||
Project project = client.createNew(doc);
|
||||
|
||||
// Relazione
|
||||
if(c.getRelazioneScavo()!=null) {
|
||||
RelazioneScavo rel=c.getRelazioneScavo();
|
||||
Document relDoc= new Document();
|
||||
relDoc.put(ProfiledConcessione.Sections.TITOLO,rel.getTitolo());
|
||||
relDoc.put(ProfiledConcessione.Relazione.RESPONSABILI,rel.getResponsabili());
|
||||
relDoc.put(ProfiledConcessione.SOGGETTO,rel.getSoggetto());
|
||||
|
||||
Document updated =project.getTheDocument();
|
||||
updated.put(ProfiledConcessione.RELAZIONE_SCAVO,relDoc);
|
||||
project = client.updateDocument(project.getId(),updated);
|
||||
|
||||
List<PersistedContent> content=rel.getActualContent();
|
||||
if(content!=null && !content.isEmpty()) {
|
||||
req = FileSets.build("$." + ProfiledConcessione.RELAZIONE_SCAVO, "fileset",
|
||||
"$." + ProfiledConcessione.RELAZIONE_SCAVO + "." + Field.CHILDREN
|
||||
+ "[?(@.fileset)]");
|
||||
req.addAll(upload(content,storage));
|
||||
project = client.registerFileSet(project.getId(),req.getTheRequest());
|
||||
}
|
||||
// upload fileset
|
||||
}
|
||||
|
||||
|
||||
if(c.getAbstractRelazione()!=null) {
|
||||
AbstractRelazione abs=c.getAbstractRelazione();
|
||||
Document absDoc= new Document();
|
||||
absDoc.put(ProfiledConcessione.Sections.TITOLO,abs.getTitolo());
|
||||
absDoc.put(ProfiledConcessione.AbstractRelazione.ABSTRACT_ENG,abs.getAbstractEng());
|
||||
absDoc.put(ProfiledConcessione.AbstractRelazione.ABSTRACT_ITA,abs.getAbstractIta());
|
||||
|
||||
|
||||
Document updated =project.getTheDocument();
|
||||
updated.put(ProfiledConcessione.ABSTRACT_RELAZIONE,absDoc);
|
||||
project = client.updateDocument(project.getId(),updated);
|
||||
|
||||
//TODO ask Fra about mapping
|
||||
// list persited content -> absIta, absEng
|
||||
|
||||
// List<PersistedContent> content=abs.getActualContent();
|
||||
// if(content!=null && !content.isEmpty()) {
|
||||
// req = FileSets.build("$." + ProfiledConcessione.RELAZIONE_SCAVO, "fileset",
|
||||
// "$." + ProfiledConcessione.RELAZIONE_SCAVO + "." + Field.CHILDREN
|
||||
// + "[?(@.fileset)]");
|
||||
// content.forEach(uploader);
|
||||
// project = client.registerFileSet(project.getId(),req.getTheRequest());
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
//Immagini rappresentative
|
||||
if(c.getImmaginiRappresentative()!=null){
|
||||
List<Document> imgs=new ArrayList<>();
|
||||
for (int i = 0; i < c.getImmaginiRappresentative().size(); i++) {
|
||||
UploadedImage img=c.getImmaginiRappresentative().get(i);
|
||||
Document imgDoc=new Document();
|
||||
imgDoc.put(ProfiledConcessione.Sections.TITOLO,img.getTitolo());
|
||||
imgDoc.put(ProfiledConcessione.Immagini.DIDASCALIA,img.getDidascalia());
|
||||
imgDoc.put(ProfiledConcessione.Relazione.RESPONSABILI,img.getResponsabili());
|
||||
imgDoc.put(ProfiledConcessione.SOGGETTO,img.getSoggetto());
|
||||
imgs.add(imgDoc);
|
||||
}
|
||||
|
||||
Document updated =project.getTheDocument();
|
||||
updated.put(ProfiledConcessione.IMMAGINI_RAPPRESENTATIVE,imgs);
|
||||
project = client.updateDocument(project.getId(),updated);
|
||||
|
||||
// FileSets
|
||||
for (int i = 0; i < c.getImmaginiRappresentative().size(); i++) {
|
||||
UploadedImage img=c.getImmaginiRappresentative().get(i);
|
||||
List<PersistedContent> content=img.getActualContent();
|
||||
if(content!=null && !content.isEmpty()) {
|
||||
req = FileSets.build("$." + ProfiledConcessione.IMMAGINI_RAPPRESENTATIVE+"["+i+"]", "fileset",
|
||||
"$." + ProfiledConcessione.IMMAGINI_RAPPRESENTATIVE + "." + Field.CHILDREN
|
||||
+ "[?(@.fileset)]");
|
||||
req.addAll(upload(content,storage));
|
||||
project = client.registerFileSet(project.getId(),req.getTheRequest());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// POS
|
||||
if(c.getPosizionamentoScavo()!=null) {
|
||||
LayerConcessione l=c.getPosizionamentoScavo();
|
||||
Document lDoc= new Document();
|
||||
lDoc.put(ProfiledConcessione.Sections.TITOLO,l.getTitolo());
|
||||
lDoc.put(ProfiledConcessione.RESPONSABILE,l.getResponsabile());
|
||||
lDoc.put(ProfiledConcessione.AUTHORS,l.getAuthors());
|
||||
lDoc.put(ProfiledConcessione.PAREOLE_CHIAVE_ICCD,l.getParoleChiaveICCD());
|
||||
lDoc.put(ProfiledConcessione.PAROLE_CHIAVE_LIBERE,l.getParoleChiaveLibere());
|
||||
lDoc.put(ProfiledConcessione.Layers.TOPIC,l.getTopicCategory());
|
||||
lDoc.put(ProfiledConcessione.Layers.SUB_TOPIC,l.getSubTopic());
|
||||
lDoc.put(ProfiledConcessione.Layers.METODO_RACCOLTA,l.getMetodoRaccoltaDati());
|
||||
lDoc.put(ProfiledConcessione.Layers.SCALA_ACQUISIZIONE,l.getScalaAcquisizione());
|
||||
lDoc.put(ProfiledConcessione.Layers.VALUTAZIONE_QUALITA,l.getValutazioneQualita());
|
||||
lDoc.put(ProfiledConcessione.Sections.ABSTRACT,l.getAbstractSection());
|
||||
|
||||
Document updated =project.getTheDocument();
|
||||
updated.put(ProfiledConcessione.POSIZIONAMENTO_SCAVO,lDoc);
|
||||
project = client.updateDocument(project.getId(),updated);
|
||||
|
||||
List<PersistedContent> content=l.getActualContent();
|
||||
if(content!=null && !content.isEmpty()) {
|
||||
req = FileSets.build("$." + ProfiledConcessione.POSIZIONAMENTO_SCAVO, "fileset",
|
||||
"$." + ProfiledConcessione.POSIZIONAMENTO_SCAVO + "." + Field.CHILDREN
|
||||
+ "[?(@.fileset)]");
|
||||
req.addAll(upload(content,storage));
|
||||
project = client.registerFileSet(project.getId(),req.getTheRequest());
|
||||
}
|
||||
// upload fileset
|
||||
}
|
||||
|
||||
// Piante
|
||||
if(c.getPianteFineScavo()!=null){
|
||||
List<Document> piante=new ArrayList<>();
|
||||
for (int i = 0; i < c.getPianteFineScavo().size(); i++) {
|
||||
LayerConcessione l=c.getPianteFineScavo().get(i);
|
||||
Document lDoc= new Document();
|
||||
lDoc.put(ProfiledConcessione.Sections.TITOLO,l.getTitolo());
|
||||
lDoc.put(ProfiledConcessione.RESPONSABILE,l.getResponsabile());
|
||||
lDoc.put(ProfiledConcessione.AUTHORS,l.getAuthors());
|
||||
lDoc.put(ProfiledConcessione.PAREOLE_CHIAVE_ICCD,l.getParoleChiaveICCD());
|
||||
lDoc.put(ProfiledConcessione.PAROLE_CHIAVE_LIBERE,l.getParoleChiaveLibere());
|
||||
lDoc.put(ProfiledConcessione.Layers.TOPIC,l.getTopicCategory());
|
||||
lDoc.put(ProfiledConcessione.Layers.SUB_TOPIC,l.getSubTopic());
|
||||
lDoc.put(ProfiledConcessione.Layers.METODO_RACCOLTA,l.getMetodoRaccoltaDati());
|
||||
lDoc.put(ProfiledConcessione.Layers.SCALA_ACQUISIZIONE,l.getScalaAcquisizione());
|
||||
lDoc.put(ProfiledConcessione.Layers.VALUTAZIONE_QUALITA,l.getValutazioneQualita());
|
||||
lDoc.put(ProfiledConcessione.Sections.ABSTRACT,l.getAbstractSection());
|
||||
piante.add(lDoc);
|
||||
}
|
||||
|
||||
Document updated =project.getTheDocument();
|
||||
updated.put(ProfiledConcessione.PIANTE_FINE_SCAVO,piante);
|
||||
project = client.updateDocument(project.getId(),updated);
|
||||
|
||||
// FileSets
|
||||
for (int i = 0; i < c.getPianteFineScavo().size(); i++) {
|
||||
LayerConcessione img=c.getPianteFineScavo().get(i);
|
||||
List<PersistedContent> content=img.getActualContent();
|
||||
if(content!=null && !content.isEmpty()) {
|
||||
req = FileSets.build("$." + ProfiledConcessione.PIANTE_FINE_SCAVO+"["+i+"]", "fileset",
|
||||
"$." + ProfiledConcessione.PIANTE_FINE_SCAVO + "." + Field.CHILDREN
|
||||
+ "[?(@.fileset)]");
|
||||
req.addAll(upload(content,storage));
|
||||
project = client.registerFileSet(project.getId(),req.getTheRequest());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Done "+c.getId()+" in "+(System.currentTimeMillis()-startTime)/1000+" sec");
|
||||
} catch (Throwable throwable) {
|
||||
System.err.println(throwable);
|
||||
errCount.incrementAndGet();
|
||||
} finally {
|
||||
count.incrementAndGet();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue