allow circle web deps and dedup at runtime
All checks were successful
studiorailgun/trpg/pipeline/head This commit looks good
All checks were successful
studiorailgun/trpg/pipeline/head This commit looks good
This commit is contained in:
parent
f3f9711340
commit
413be570f3
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"tag": "linguistics",
|
"tag": "linguistics",
|
||||||
"dependencies" : [
|
"dependencies" : [
|
||||||
|
"./data/webs/philosophy/philosophy.json",
|
||||||
"./data/webs/linguistics/name.json"
|
"./data/webs/linguistics/name.json"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -1,3 +1,2 @@
|
|||||||
{
|
{
|
||||||
"selfId": 2
|
|
||||||
}
|
}
|
||||||
@ -77,7 +77,8 @@ public class KnowledgeWeb {
|
|||||||
public static KnowledgeWeb load(String startPoint){
|
public static KnowledgeWeb load(String startPoint){
|
||||||
Map<String,Integer> crossRelationLookupMap = new HashMap<String,Integer>();
|
Map<String,Integer> crossRelationLookupMap = new HashMap<String,Integer>();
|
||||||
List<String> webTagList = new LinkedList<String>();
|
List<String> webTagList = new LinkedList<String>();
|
||||||
KnowledgeWeb rVal = KnowledgeWeb.recursivelyLoad(crossRelationLookupMap, webTagList, startPoint);
|
List<String> parsedFilesList = new LinkedList<String>();
|
||||||
|
KnowledgeWeb rVal = KnowledgeWeb.recursivelyLoad(crossRelationLookupMap, parsedFilesList, webTagList, startPoint);
|
||||||
if(rVal.getTag() == null){
|
if(rVal.getTag() == null){
|
||||||
throw new UnsupportedOperationException("Web without tag defined! " + startPoint);
|
throw new UnsupportedOperationException("Web without tag defined! " + startPoint);
|
||||||
}
|
}
|
||||||
@ -143,7 +144,7 @@ public class KnowledgeWeb {
|
|||||||
* @param root The path to the current root knowledge web
|
* @param root The path to the current root knowledge web
|
||||||
* @return Merged knowledge web
|
* @return Merged knowledge web
|
||||||
*/
|
*/
|
||||||
private static KnowledgeWeb recursivelyLoad(Map<String,Integer> crossRelationLookupMap, List<String> foundTags, String startPoint){
|
private static KnowledgeWeb recursivelyLoad(Map<String,Integer> crossRelationLookupMap, List<String> parsedFilePaths, List<String> foundTags, String startPoint){
|
||||||
KnowledgeWeb rVal = FileUtils.loadObjectFromFile(new File(startPoint), KnowledgeWeb.class);
|
KnowledgeWeb rVal = FileUtils.loadObjectFromFile(new File(startPoint), KnowledgeWeb.class);
|
||||||
if(rVal == null){
|
if(rVal == null){
|
||||||
throw new Error("Failed to load file! " + startPoint);
|
throw new Error("Failed to load file! " + startPoint);
|
||||||
@ -151,6 +152,7 @@ public class KnowledgeWeb {
|
|||||||
if(foundTags.contains(rVal.getTag())){
|
if(foundTags.contains(rVal.getTag())){
|
||||||
throw new UnsupportedOperationException("Trying to load two webs with the same tag! " + rVal.getTag());
|
throw new UnsupportedOperationException("Trying to load two webs with the same tag! " + rVal.getTag());
|
||||||
}
|
}
|
||||||
|
parsedFilePaths.add(startPoint);
|
||||||
//add nodes to crossrelational lookup map
|
//add nodes to crossrelational lookup map
|
||||||
HashMap<Integer,Node> newNodeMap = new HashMap<Integer,Node>();
|
HashMap<Integer,Node> newNodeMap = new HashMap<Integer,Node>();
|
||||||
for(Node node : rVal.nodes.values()){
|
for(Node node : rVal.nodes.values()){
|
||||||
@ -179,7 +181,10 @@ public class KnowledgeWeb {
|
|||||||
//parse children
|
//parse children
|
||||||
if(rVal.getDependencies() != null && rVal.getDependencies().size() > 0){
|
if(rVal.getDependencies() != null && rVal.getDependencies().size() > 0){
|
||||||
for(String child : rVal.getDependencies()){
|
for(String child : rVal.getDependencies()){
|
||||||
KnowledgeWeb childWeb = KnowledgeWeb.recursivelyLoad(crossRelationLookupMap, foundTags, child);
|
if(parsedFilePaths.contains(child)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
KnowledgeWeb childWeb = KnowledgeWeb.recursivelyLoad(crossRelationLookupMap, parsedFilePaths, foundTags, child);
|
||||||
KnowledgeWeb.registerChildItems(crossRelationLookupMap, rVal, childWeb);
|
KnowledgeWeb.registerChildItems(crossRelationLookupMap, rVal, childWeb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,9 +26,10 @@ public class LoadingTests {
|
|||||||
@Test
|
@Test
|
||||||
public void testExportCSV(){
|
public void testExportCSV(){
|
||||||
assertDoesNotThrow(() -> {
|
assertDoesNotThrow(() -> {
|
||||||
KnowledgeWeb web = FileUtils.loadObjectFromFile(new File("./data/webs/test/web.json"), KnowledgeWeb.class);
|
Globals.init("./data/webs/test/web.json");
|
||||||
web.initLinks();
|
if(Globals.web.getNodes().size() == 0){
|
||||||
Globals.web = web;
|
throw new Error("No nodes defined in main test web!");
|
||||||
|
}
|
||||||
CSVExport.export("test");
|
CSVExport.export("test");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user