From 7c64a0770a4800d80c5a53eea2243c46301f7749 Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Mon, 19 Jan 2015 20:51:04 +0100 Subject: reintroduced some setters in Domain, but probably not enough yet. --- src/core/model/Document.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/core/model/Document.cpp') diff --git a/src/core/model/Document.cpp b/src/core/model/Document.cpp index a329392..66b36b0 100644 --- a/src/core/model/Document.cpp +++ b/src/core/model/Document.cpp @@ -156,7 +156,7 @@ bool DocumentEntity::doValidate(Logger &logger) const FieldDescriptor::FieldType::PRIMITIVE) { switch (fields[f].size()) { case 0: - if (!fieldDescs[f]->optional) { + if (!fieldDescs[f]->isOptional()) { logger.error(std::string("Primitive Field \"") + fieldDescs[f]->getName() + "\" had no content!"); @@ -180,7 +180,7 @@ bool DocumentEntity::doValidate(Logger &logger) const // we can do a faster check if this field is empty. if (fields[f].size() == 0) { // if this field is optional, an empty field is valid anyways. - if (fieldDescs[f]->optional) { + if (fieldDescs[f]->isOptional()) { continue; } /* @@ -212,6 +212,13 @@ bool DocumentEntity::doValidate(Logger &logger) const // iterate over every actual child of this DocumentEntity for (auto &rc : fields[f]) { + // check if the parent reference is correct. + if (rc->getParent() != subInst) { + logger.error(std::string("A child of field \"") + + fieldDescs[f]->getName() + + "\" has the wrong parent reference!"); + valid = false; + } if (rc->isa(RttiTypes::Anchor)) { // Anchors are uninteresting and can be ignored. continue; @@ -453,7 +460,9 @@ bool Document::doValidate(Logger &logger) const valid = false; } else { // check if the root is allowed to be a root. - if (!root->getDescriptor().cast()->root) { + if (!root->getDescriptor() + .cast() + ->hasRootPermission()) { logger.error(std::string("A node of type \"") + root->getDescriptor()->getName() + "\" is not allowed to be the Document root!"); -- cgit v1.2.3