Compare commits

..

No commits in common. "ec6b347f909dca3f685ba0ec2504a9f3586295cb" and "cdff7547a515b7e62293f823300010fea882fc55" have entirely different histories.

5 changed files with 63 additions and 88 deletions

View File

@ -100,7 +100,7 @@ public class Files {
toFix=toFix.substring(0,toFix.indexOf(".")); toFix=toFix.substring(0,toFix.indexOf("."));
} }
return toFix.toLowerCase(). return toFix.toLowerCase().
replaceAll("[\\-\\*\\+\\/\\\\ \\[\\]\\(\\)\\.\\\"\\:\\;\\|\\=]","_")+extension.toLowerCase(); replaceAll("[\\-\\*\\+\\/\\\\ \\[\\]\\(\\)\\.\\\"\\:\\;\\|\\=]","_")+extension;
} }
public static final File downloadFromUrl(String name,String url) throws IOException { public static final File downloadFromUrl(String name,String url) throws IOException {

View File

@ -44,8 +44,9 @@ public class ProfiledConcessioniTests extends AbstractProfiledDocumentsTests{
UserUtils.DEFAULT_ROLES.add("Data-Manager"); UserUtils.DEFAULT_ROLES.add("Data-Manager");
// Create new // Create new
Document theDoc=Document.parse("{" + Document theDoc=Document.parse("{\n" +
"\"posizionamentoScavo\" :{\"titolo\" : \"mio titolo\"},\"nome\":\"TEST SDI Extensions\"}"); "\"posizionamentoScavo\" :{\n" +
"\t\"titolo\" : \"mio titolo\"}}");
theDoc.put("startTime", LocalDateTime.now()); theDoc.put("startTime", LocalDateTime.now());
@ -67,7 +68,7 @@ public class ProfiledConcessioniTests extends AbstractProfiledDocumentsTests{
"$.posizionamentoScavo."+ Field.CHILDREN+"[?(@.fileset)]", "$.posizionamentoScavo."+ Field.CHILDREN+"[?(@.fileset)]",
null, null,
RegisterFileSetRequest.ClashOptions.MERGE_EXISTING, RegisterFileSetRequest.ClashOptions.MERGE_EXISTING,
"concessioni/pos.SHP"); "concessioni/pos.shp");
System.out.println("Registered posizionamento, result is "+ Serialization.write(doc)); System.out.println("Registered posizionamento, result is "+ Serialization.write(doc));

View File

@ -19,7 +19,7 @@ public abstract class SupportedFormat {
case ".tif" : {toReturn.add(new SupportedFormat(".tif") { case ".tif" : {toReturn.add(new SupportedFormat(".tif") {
@Override @Override
public void consider(RegisteredFile f) { public void consider(RegisteredFile f) {
if (f.getName().toLowerCase().endsWith(getFileExtension())){ if (f.getName().endsWith(getFileExtension())){
getToUseFileSet().add(f); getToUseFileSet().add(f);
isProposedFilesetValid=true; isProposedFilesetValid=true;
} }
@ -31,7 +31,7 @@ public abstract class SupportedFormat {
@Override @Override
public void consider(RegisteredFile f) { public void consider(RegisteredFile f) {
getToUseFileSet().add(f); getToUseFileSet().add(f);
if (f.getName().toLowerCase().endsWith(getFileExtension())){ if (f.getName().endsWith(getFileExtension())){
isProposedFilesetValid=true; isProposedFilesetValid=true;
} }
} }

View File

@ -45,12 +45,10 @@ public class ClearProjects {
Iterator<Project> it=null; 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(); 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); it=client.query(q);

View File

@ -26,7 +26,6 @@ import org.gcube.application.geoportal.common.utils.tests.GCubeTest;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.SQLOutput;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
@ -34,7 +33,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.regex.Matcher;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.projects; import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.projects;
@ -48,7 +46,6 @@ public class ExportConcessioniAsProjects {
public static void main(String[] args) throws InterruptedException, IOException { public static void main(String[] args) throws InterruptedException, IOException {
// read from imported folder // read from imported folder
File dir= new File("/Users/fabioisti/git/gcube-cms-suite/import1668778302348"); File dir= new File("/Users/fabioisti/git/gcube-cms-suite/import1668778302348");
@ -80,29 +77,12 @@ public class ExportConcessioniAsProjects {
Files.saveString(importFolder.sort(),new File(dir,"relationships.csv").toPath()); Files.saveString(importFolder.sort(),new File(dir,"relationships.csv").toPath());
TokenSetter.set(GCubeTest.getContext());
if(!pushProjects){ if(!pushProjects){
System.out.println("PUSH PROJECTS FLAG IS FALSE.. CLOSING."); 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); System.exit(0);
} }
TokenSetter.set(GCubeTest.getContext());
// StorageUtils storage = new StorageUtils(); // StorageUtils storage = new StorageUtils();
@ -132,7 +112,7 @@ public class ExportConcessioniAsProjects {
if(delete.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(),true); client.deleteById(project.getId());
} }
}else publish.set(false); }else publish.set(false);
} }
@ -470,60 +450,56 @@ public class ExportConcessioniAsProjects {
public static String quote(String string) { public static String quote(String string) {
if(string!=null) if (string == null || string.length() == 0) {
// return "\""+string.replaceAll("\"","\"")+"\""; return "\"\"";
return "\""+string.replaceAll("\"",Matcher.quoteReplacement("\\\""))+"\""; }
else return "\"\"";
// if (string == null || string.length() == 0) { char c = 0;
// return "\"\""; int i;
// } int len = string.length();
// StringBuilder sb = new StringBuilder(len + 4);
// char c = 0; String t;
// int i;
// int len = string.length(); sb.append('"');
// StringBuilder sb = new StringBuilder(len + 4); for (i = 0; i < len; i += 1) {
// String t; c = string.charAt(i);
// switch (c) {
// sb.append('"'); case '\\':
// for (i = 0; i < len; i += 1) { case '"':
// c = string.charAt(i); sb.append('\\');
// switch (c) { sb.append(c);
// case '\\': break;
// case '"': case '/':
// sb.append('\\'); // if (b == '<') {
// sb.append(c); sb.append('\\');
// break; // }
// case '/': sb.append(c);
// // if (b == '<') { break;
// sb.append('\\'); case '\b':
// // } sb.append("\\b");
// sb.append(c); break;
// break; case '\t':
// case '\b': sb.append("\\t");
// sb.append("\\b"); break;
// break; case '\n':
// case '\t': sb.append("\\n");
// sb.append("\\t"); break;
// break; case '\f':
// case '\n': sb.append("\\f");
// sb.append("\\n"); break;
// break; case '\r':
// case '\f': sb.append("\\r");
// sb.append("\\f"); break;
// break; default:
// case '\r': if (c < ' ') {
// sb.append("\\r"); t = "000" + Integer.toHexString(c);
// break; sb.append("\\u" + t.substring(t.length() - 4));
// default: } else {
// if (c < ' ') { sb.append(c);
// t = "000" + Integer.toHexString(c); }
// sb.append("\\u" + t.substring(t.length() - 4)); }
// } else { }
// sb.append(c); sb.append('"');
// } return sb.toString();
// }
// }
// sb.append('"');
// return sb.toString();
} }
} }