Пример #1
0
        def creator(label_uri):
            if not label_uri:
                return
            label, uri = label_uri
            if not label:
                label = None

            types = [type_uri]

            if not uri:
                uri = uri_gen = self.doc.infGenerateUri(label)
            else:
                uri_gen = None

            props = []
            if self.doc.annotations_by_name.get('defaultRdsId'):
                props.append(LiteralTriple.of(uri, self.doc.annotations_by_name.get('defaultRdsId'), self.doc.infDefaultRdsId(uri_gen)))

            if data.get('template'):
                types.append(kb.ns_owl+'Thing')
                tpl = self.doc._findTemplate(type_uri)
                if tpl:
                    for v in tpl['roles'].itervalues():
                        if v.get('restricted_by_value'):
                            props.append(ObjectTriple.of(uri, v['uri'], v['type_uri']))
                        if v['is_literal']:
                            props.append(DatatypeQuad.of(uri, v['uri'], '', v['type_uri']))
            self.doc << actions.AddEntity(self.doc, uri, types, label, props)
Пример #2
0
 def creator(prop_value):
     if not prop_value:
         return
     prop, value = prop_value
     if not prop or not value:
         return
     p = props[prop]['uri']
     datatype = props[prop].get('type_uri')
     if datatype:
         k = DatatypeQuad.of(self.parent.uri, p, value, datatype)
     else:
         k = LiteralTriple.of(self.parent.uri, p, value)
     self.doc << actions.AddProperty(self.doc, k)