MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / writeOutExternal

Method writeOutExternal

src/main/java/fieldbox/io/IO.java:650–697  ·  view source on GitHub ↗
(String defaultPrefix, External external)

Source from the content-addressed store, hash-verified

648 protected void writeOutExternal(String defaultPrefix, External external) throws IOException {
649 for (Map.Entry<String, String> e : external.textFiles.entrySet()) {
650 String text = external.box.properties.get(new Dict.Prop<String>(e.getKey()));
651 if (text == null) continue;
652 File filename = filenameFor(defaultPrefix, e.getValue());
653
654 try {
655 writeToFile(filename, text);
656 } catch (Exception ex) {
657 System.err.println(" exception thrown while saving out a file :" + filename + " for property :" + e + " in box +" + external.box);
658 ex.printStackTrace();
659 System.err.println(" continuing on");
660 }
661 }
662
663 File dataFile = filenameFor(external.dataFile);
664
665 if (dataFile != null) {
666 Map<String, Object> data = new LinkedHashMap<String, Object>();
667
668 Set<Map.Entry<Dict.Prop, Object>> es = external.box.properties.getMap()
669 .entrySet();
670 for (Map.Entry<Dict.Prop, Object> e : es)
671 if (isPeristant(e.getKey())) data.put(e.getKey()
672 .getName(), e.getValue());
673
674
675 data.put("__boxclass__", external.boxClass);
676
677 writeToFile(dataFile, serializeToString(data));
678 }
679
680 Log.log("io.general", () -> "sweep for persistent, perDocument properties");
681 for (Map.Entry<Dict.Prop, Object> e : external.box.properties.getMap()
682 .entrySet()) {
683 Log.log("io.general", () -> "property :" + e.getKey()
684 .toCanon() + " attributes are " + e.getKey()
685 .toCanon()
686 .getAttributes());
687
688 if (e.getKey()
689 .toCanon()
690 .getAttributes()
691 .isTrue(perDocument, false) && isPeristant(e.getKey()))
692 external.overriddenProperties.put(e.getKey()
693 .getName(), e.getValue());
694 }
695 }
696
697 private String serializeToString(Object data) {
698 String written = edn.write(data);
699 Log.log("io.general", () -> "edn is " + written);
700 return written;

Callers 1

writeOutDocumentMethod · 0.95

Calls 14

filenameForMethod · 0.95
writeToFileMethod · 0.95
isPeristantMethod · 0.95
serializeToStringMethod · 0.95
logMethod · 0.95
getMapMethod · 0.80
toCanonMethod · 0.80
getAttributesMethod · 0.80
isTrueMethod · 0.80
getMethod · 0.65
getValueMethod · 0.45
printlnMethod · 0.45

Tested by

no test coverage detected