|
|
@@ -2,10 +2,12 @@ import { project } from "./project.js";
|
|
|
import { element } from "./element.js";
|
|
|
import { elements_list } from "./elements_list.js";
|
|
|
import { submission } from "./submission.js";
|
|
|
+import { submissions_list } from "./submissions_list.js";
|
|
|
import { parser } from "./parser.js";
|
|
|
|
|
|
class database {
|
|
|
#project;
|
|
|
+ #submissions;
|
|
|
|
|
|
constructor(content) {
|
|
|
if (!(content instanceof Object)) {
|
|
|
@@ -17,8 +19,11 @@ class database {
|
|
|
|
|
|
#load(content) {
|
|
|
const loader = new parser(content, "root");
|
|
|
+ const project = loader.get_parser("project");
|
|
|
+ const submissions = loader.get_parser("submissions");
|
|
|
|
|
|
- this.#project = this.#parse_project(loader.get_parser("project"));
|
|
|
+ this.#project = this.#parse_project(project);
|
|
|
+ this.#submissions = this.#parse_submissions(submissions);
|
|
|
}
|
|
|
|
|
|
#parse_project(content) {
|
|
|
@@ -31,6 +36,49 @@ class database {
|
|
|
|
|
|
return new project(name, description);
|
|
|
}
|
|
|
+
|
|
|
+ #parse_elements(content) {
|
|
|
+ const list = new elements_list();
|
|
|
+
|
|
|
+ content.properties.forEach(name => {
|
|
|
+ const loader = content.get_parser(name);
|
|
|
+
|
|
|
+ const result = new element(
|
|
|
+ name
|
|
|
+ );
|
|
|
+
|
|
|
+ list.append(result);
|
|
|
+ });
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ #parse_submissions(content) {
|
|
|
+ const list = new submissions_list();
|
|
|
+
|
|
|
+ content.properties.forEach(title => {
|
|
|
+ const loader = content.get_parser(title);
|
|
|
+ const description = loader.get("description");
|
|
|
+ const picture = loader.get("picture");
|
|
|
+ const elements_parser = loader.get_parser("elements");
|
|
|
+ const elements = this.#parse_elements(elements_parser);
|
|
|
+
|
|
|
+ const result = new submission(
|
|
|
+ title,
|
|
|
+ description,
|
|
|
+ picture,
|
|
|
+ elements
|
|
|
+ );
|
|
|
+
|
|
|
+ list.append(result);
|
|
|
+ });
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ get project() {
|
|
|
+ return this.#project;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
export { database };
|