diff options
author | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2015-01-21 22:21:24 +0100 |
---|---|---|
committer | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2015-01-21 22:21:24 +0100 |
commit | c2fb0693208c2e980fdb161e63ef82096c49d59a (patch) | |
tree | c689995979c2b352ebb168a76e1485fcabd0984c /src/core | |
parent | 71bb4de05099601651f1a7a77d72ebf072a38be6 (diff) |
added variant content validation for Documents.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/model/Document.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/core/model/Document.cpp b/src/core/model/Document.cpp index 7552bd3..f29af1c 100644 --- a/src/core/model/Document.cpp +++ b/src/core/model/Document.cpp @@ -147,10 +147,14 @@ bool DocumentEntity::doValidate(Logger &logger) const // a constructor we can not check anything else. return false; } - // TODO: check the validated form of Attributes - // TODO: Check if descriptor is registered at the Document? - - bool valid = true; + // check the attribute primitive content. + bool valid; + if (descriptor->getAttributesDescriptor() == nullptr) { + valid = getAttributes() == nullptr; + } else { + valid = descriptor->getAttributesDescriptor()->isValid(getAttributes(), + logger); + } /* * generate the set of effective fields. This is trivial for * AnnotationEntities, but in the case of StructuredEntities we have to @@ -188,7 +192,18 @@ bool DocumentEntity::doValidate(Logger &logger) const continue; } // if we are here we know that exactly one child exists. - // TODO: Check the primitive type of the child. + if (!fields[f][0]->isa(RttiTypes::DocumentPrimitive)) { + logger.error(std::string("Primitive Field \"") + + fieldDescs[f]->getName() + + "\" has non primitive content!"); + valid = false; + } else { + Handle<DocumentPrimitive> primitive = + fields[f][0].cast<DocumentPrimitive>(); + valid = valid & + fieldDescs[f]->getPrimitiveType()->isValid( + primitive->getContent(), logger); + } continue; } |