Compare commits
2 Commits
cdff7547a5
...
ec6b347f90
Author | SHA1 | Date |
---|---|---|
Fabio Sinibaldi | ec6b347f90 | |
Fabio Sinibaldi | fc638de33c |
|
@ -100,7 +100,7 @@ public class Files {
|
|||
toFix=toFix.substring(0,toFix.indexOf("."));
|
||||
}
|
||||
return toFix.toLowerCase().
|
||||
replaceAll("[\\-\\*\\+\\/\\\\ \\[\\]\\(\\)\\.\\\"\\:\\;\\|\\=]","_")+extension;
|
||||
replaceAll("[\\-\\*\\+\\/\\\\ \\[\\]\\(\\)\\.\\\"\\:\\;\\|\\=]","_")+extension.toLowerCase();
|
||||
}
|
||||
|
||||
public static final File downloadFromUrl(String name,String url) throws IOException {
|
||||
|
|
|
@ -44,9 +44,8 @@ public class ProfiledConcessioniTests extends AbstractProfiledDocumentsTests{
|
|||
UserUtils.DEFAULT_ROLES.add("Data-Manager");
|
||||
// Create new
|
||||
|
||||
Document theDoc=Document.parse("{\n" +
|
||||
"\"posizionamentoScavo\" :{\n" +
|
||||
"\t\"titolo\" : \"mio titolo\"}}");
|
||||
Document theDoc=Document.parse("{" +
|
||||
"\"posizionamentoScavo\" :{\"titolo\" : \"mio titolo\"},\"nome\":\"TEST SDI Extensions\"}");
|
||||
|
||||
theDoc.put("startTime", LocalDateTime.now());
|
||||
|
||||
|
@ -68,7 +67,7 @@ public class ProfiledConcessioniTests extends AbstractProfiledDocumentsTests{
|
|||
"$.posizionamentoScavo."+ Field.CHILDREN+"[?(@.fileset)]",
|
||||
null,
|
||||
RegisterFileSetRequest.ClashOptions.MERGE_EXISTING,
|
||||
"concessioni/pos.shp");
|
||||
"concessioni/pos.SHP");
|
||||
|
||||
|
||||
System.out.println("Registered posizionamento, result is "+ Serialization.write(doc));
|
||||
|
|
|
@ -19,7 +19,7 @@ public abstract class SupportedFormat {
|
|||
case ".tif" : {toReturn.add(new SupportedFormat(".tif") {
|
||||
@Override
|
||||
public void consider(RegisteredFile f) {
|
||||
if (f.getName().endsWith(getFileExtension())){
|
||||
if (f.getName().toLowerCase().endsWith(getFileExtension())){
|
||||
getToUseFileSet().add(f);
|
||||
isProposedFilesetValid=true;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public abstract class SupportedFormat {
|
|||
@Override
|
||||
public void consider(RegisteredFile f) {
|
||||
getToUseFileSet().add(f);
|
||||
if (f.getName().endsWith(getFileExtension())){
|
||||
if (f.getName().toLowerCase().endsWith(getFileExtension())){
|
||||
isProposedFilesetValid=true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,10 +45,12 @@ public class ClearProjects {
|
|||
|
||||
Iterator<Project> it=null;
|
||||
|
||||
String queryString = String.format("{\"_theDocument.nome\" :{\"$eq\" : \"Landro (Comune di Tambre, BL) \"},\"_theDocument.dataInizioProgetto\":{\"$eq\":\"2021-05-29T00:00:00\"}}\n" +
|
||||
"}");
|
||||
QueryRequest q = new QueryRequest();
|
||||
q.setFilter(Document.parse(queryString));
|
||||
|
||||
// String queryString = String.format("{\"_theDocument.nome\" :{\"$eq\" : \"Landro (Comune di Tambre, BL) \"},\"_theDocument.dataInizioProgetto\":{\"$eq\":\"2021-05-29T00:00:00\"}}\n" +
|
||||
// "}");
|
||||
// q.setFilter(Document.parse(queryString));
|
||||
//
|
||||
it=client.query(q);
|
||||
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.gcube.application.geoportal.common.utils.tests.GCubeTest;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.rmi.RemoteException;
|
||||
import java.sql.SQLOutput;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
|
@ -33,6 +34,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.projects;
|
||||
|
@ -46,6 +48,7 @@ public class ExportConcessioniAsProjects {
|
|||
|
||||
|
||||
public static void main(String[] args) throws InterruptedException, IOException {
|
||||
|
||||
// read from imported folder
|
||||
File dir= new File("/Users/fabioisti/git/gcube-cms-suite/import1668778302348");
|
||||
|
||||
|
@ -77,12 +80,29 @@ public class ExportConcessioniAsProjects {
|
|||
|
||||
Files.saveString(importFolder.sort(),new File(dir,"relationships.csv").toPath());
|
||||
|
||||
TokenSetter.set(GCubeTest.getContext());
|
||||
|
||||
|
||||
|
||||
if(!pushProjects){
|
||||
System.out.println("PUSH PROJECTS FLAG IS FALSE.. CLOSING.");
|
||||
StringBuilder reportBuilder = new StringBuilder();
|
||||
StringBuilder concReportBuilder = new StringBuilder();
|
||||
|
||||
importFolder.getRelationshipMap().forEach((s,l)->{
|
||||
l.forEach(c->concReportBuilder.append(c.getReport().getStatus()+","+c.getReport().getWarningMessages()+","+c.getMongo_id()+","+c.getNome()+"\n"));
|
||||
try {
|
||||
// reportBuilder.append(getExisting(l.get(0),client).size()+","+s+"\n");
|
||||
} catch (Throwable e) {
|
||||
log.error("Unable to get count for {} ",s,e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
Files.saveString(reportBuilder.toString(),new File(dir,"found.csv").toPath());
|
||||
Files.saveString(concReportBuilder.toString(),new File(dir,"originalStatuses.csv").toPath());
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
TokenSetter.set(GCubeTest.getContext());
|
||||
|
||||
// StorageUtils storage = new StorageUtils();
|
||||
|
||||
|
@ -112,7 +132,7 @@ public class ExportConcessioniAsProjects {
|
|||
if(delete.get()){
|
||||
log.debug("Deleting error set for {}",c.getNome());
|
||||
for (Project project : existing) {
|
||||
client.deleteById(project.getId());
|
||||
client.deleteById(project.getId(),true);
|
||||
}
|
||||
}else publish.set(false);
|
||||
}
|
||||
|
@ -450,56 +470,60 @@ public class ExportConcessioniAsProjects {
|
|||
|
||||
|
||||
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();
|
||||
if(string!=null)
|
||||
// return "\""+string.replaceAll("\"","\"")+"\"";
|
||||
return "\""+string.replaceAll("\"",Matcher.quoteReplacement("\\\""))+"\"";
|
||||
else return "\"\"";
|
||||
// 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