|
@@ -13,7 +13,6 @@ include "utils.alh"
|
|
|
include "conformance_finding.alh"
|
|
|
include "typing.alh"
|
|
|
|
|
|
-
|
|
|
String core_model_location = "models/core"
|
|
|
|
|
|
Element core = ?
|
|
@@ -40,26 +39,7 @@ String function get_filename(name : String):
|
|
|
return list_pop_final(string_split(name, "/"))!
|
|
|
|
|
|
String function full_name(model_id : String):
|
|
|
- //if (dict_in(caches["full_name"], model_id)):
|
|
|
- // if (get_entry_id(caches["full_name"][model_id]) == model_id):
|
|
|
- // return caches["full_name"]!
|
|
|
-
|
|
|
- // No cache, or out of date
|
|
|
- Element incoming
|
|
|
- String parent
|
|
|
- String parent_name
|
|
|
-
|
|
|
- incoming = allAssociationOrigins(core, model_id, "contains")
|
|
|
- if (set_len(incoming) > 0):
|
|
|
- parent = set_pop(incoming)
|
|
|
- parent_name = full_name(parent)
|
|
|
- //dict_add(caches["full_name"], parent, parent_name)
|
|
|
- if (parent_name == ""):
|
|
|
- return read_attribute(core, model_id, "name")!
|
|
|
- else:
|
|
|
- return string_join(parent_name + "/", read_attribute(core, model_id, "name"))!
|
|
|
- else:
|
|
|
- return ""!
|
|
|
+ return read_attribute(core, model_id, "name")!
|
|
|
|
|
|
Void function initialize_core():
|
|
|
// TODO make this more flexible by putting it in the bootstrap in a similar way as other models
|
|
@@ -274,30 +254,31 @@ String function get_entry_id(name : String):
|
|
|
String elem
|
|
|
Boolean found
|
|
|
|
|
|
- i = 0
|
|
|
- //log("Searching for " + name)
|
|
|
- hierarchy_split = string_split(name, "/")
|
|
|
- current = caches["root"]
|
|
|
-
|
|
|
- Element dict
|
|
|
- while (i < list_len(hierarchy_split)):
|
|
|
- current_part = list_read(hierarchy_split, i)
|
|
|
- if (current_part != ""):
|
|
|
- dict = dict_create()
|
|
|
- found = False
|
|
|
- elems = allAssociationDestinations(core, current, "contains")
|
|
|
- while (set_len(elems) > 0):
|
|
|
- elem = set_pop(elems)
|
|
|
- if (value_eq(read_attribute(core, elem, "name"), current_part)):
|
|
|
- current = elem
|
|
|
- found = True
|
|
|
- break!
|
|
|
+ log("Searching for " + name)
|
|
|
+ if (name == ""):
|
|
|
+ return caches["root"]!
|
|
|
|
|
|
- if (bool_not(found)):
|
|
|
- return ""!
|
|
|
- i = i + 1
|
|
|
+ //if (dict_in(caches["models"], name)):
|
|
|
+ // if (full_name(caches["models"][name]) == name):
|
|
|
+ // return caches["models"][name]!
|
|
|
|
|
|
- return current!
|
|
|
+ current = get_entry_id(get_foldername(name))
|
|
|
+ if (current == ""):
|
|
|
+ return ""!
|
|
|
+
|
|
|
+ log("Got result!")
|
|
|
+ if (current_part != ""):
|
|
|
+ elems = allAssociationDestinations(core, current, "contains")
|
|
|
+ while (set_len(elems) > 0):
|
|
|
+ elem = set_pop(elems)
|
|
|
+ dict_overwrite(caches["models"], read_attribute(core, elem, "name"), elem)
|
|
|
+ if (value_eq(name, read_attribute(core, elem, "name"))):
|
|
|
+ return elem!
|
|
|
+ else:
|
|
|
+ return current!
|
|
|
+
|
|
|
+ log("NOT FOUND")
|
|
|
+ return ""!
|
|
|
|
|
|
String function get_service_id(name : String):
|
|
|
Element services
|
|
@@ -356,12 +337,15 @@ String function create_folders(user_id : String, folder_name : String):
|
|
|
// Go through folders first
|
|
|
while (i < list_len(hierarchy)):
|
|
|
elem = list_read(hierarchy, i)
|
|
|
- cummul = string_join(cummul + "/", elem)
|
|
|
+ if (cummul == ""):
|
|
|
+ cummul = elem
|
|
|
+ else:
|
|
|
+ cummul = string_join(cummul + "/", elem)
|
|
|
|
|
|
if (get_entry_id(cummul) == ""):
|
|
|
// Element does not exist yet!
|
|
|
new_entry = instantiate_node(core, "Folder", "")
|
|
|
- instantiate_attribute(core, new_entry, "name", elem)
|
|
|
+ instantiate_attribute(core, new_entry, "name", cummul)
|
|
|
instantiate_attribute(core, new_entry, "permissions", "200")
|
|
|
instantiate_link(core, "contains", "", prev, new_entry)
|
|
|
instantiate_link(core, "group", "", new_entry, get_group_id("nobody"))
|
|
@@ -370,13 +354,13 @@ String function create_folders(user_id : String, folder_name : String):
|
|
|
prev = get_entry_id(cummul)
|
|
|
i = i + 1
|
|
|
|
|
|
- log("Create of folders " + folder_name)
|
|
|
- log("Results in " + prev)
|
|
|
return prev!
|
|
|
|
|
|
String function store_entry(model_id : String, full_name : String, user_id : String):
|
|
|
String prev
|
|
|
+ log("Creating folders for " + full_name)
|
|
|
prev = create_folders(user_id, get_foldername(full_name))
|
|
|
+ log("Created folders up to: " + cast_v2s(read_attribute(core, prev, "name")))
|
|
|
instantiate_link(core, "contains", "", prev, model_id)
|
|
|
return get_filename(full_name)!
|
|
|
|
|
@@ -1231,9 +1215,9 @@ String function cmd_model_list(user_id : String, location : String):
|
|
|
while (set_len(models) > 0):
|
|
|
m = set_pop(models)
|
|
|
if (is_nominal_instance(core, m, "Folder")):
|
|
|
- result = result + string_join(read_attribute(core, m, "name"), "/\n")
|
|
|
+ result = result + (get_filename(read_attribute(core, m, "name")) + "/\n")
|
|
|
else:
|
|
|
- result = result + string_join(read_attribute(core, m, "name"), "\n")
|
|
|
+ result = result + (get_filename(read_attribute(core, m, "name")) + "\n")
|
|
|
return result!
|
|
|
else:
|
|
|
return "Permission denied to folder: " + location!
|
|
@@ -1261,9 +1245,9 @@ String function cmd_model_list_full(user_id : String, location : String):
|
|
|
owner = read_attribute(core, set_pop(allAssociationDestinations(core, m, "owner")), "name")
|
|
|
group = read_attribute(core, set_pop(allAssociationDestinations(core, m, "group")), "name")
|
|
|
if (is_nominal_instance(core, m, "Folder")):
|
|
|
- name = string_join(read_attribute(core, m, "name"), "/")
|
|
|
+ name = get_filename(read_attribute(core, m, "name")) + "/"
|
|
|
else:
|
|
|
- name = read_attribute(core, m, "name")
|
|
|
+ name = get_filename(read_attribute(core, m, "name"))
|
|
|
result = result + (((((((permissions + " ") + owner) + " ") + group) + " ") + name) + "\n")
|
|
|
return result!
|
|
|
else:
|