event type
type: DatatypeProperty
range: string

eccairs-form-generation-0.2
type: Ontology
imports: aviation
imports: eccairs-form-0.2
imports: eccairs-form-config-0.2
imports: eccairs-form-generated-0.2
imports: eccairs-form-lib
imports: eccairs-form-mapping-0.2
imports: eccairs-form-static-0.2
imports: operational-full
imports: model
imports: form-layout
imports: sm-module-adapter
imports: spin-function
imports: core
version info: Created with TopBraid Composer

Bind root question
type: BindBySelect
next: Layout form
select query: Select
  result variables:
    var name: rootQuestion
  text: SELECT ?rootQuestion WHERE { ?rootQuestion a doc:question . # TODO temporal fix remove !!! OPTIONAL { ?rootQuestion form:has-template ?rootQT . } FILTER( (?rootQT = e-a-3.4.0.2:e-24-qt) || (!bound(?rootQT))) FILTER NOT EXISTS { ?superQuestion doc:has_related_question ?rootQuestion . ?superQuestion a doc:question } }
  where:
    object: question
    predicate: type
    subject:
      var name: rootQuestion
  where: Optional
    elements:
      object:
        var name: rootQT
      predicate: has-template
      subject:
        var name: rootQuestion
  where: Filter
    expression: or
      arg1: eq
        arg2: e-24-qt
      arg2: not
        arg1: bound
  where: Filter
    expression: notExists
      elements:
        predicate: has related question
      elements:
        object: question
        predicate: type

Bind sample report uri
type: BindWithConstant
next: Bind sample report service uri
output variable: sampleReportUri
value: http://onto.fel.cvut.cz/ontologies/documentation/report-i/246BAFD49E19E611B897002655546824.e5x/246BAFD49E19E611B897002655546824.xml
comment: ###################### ###### NOT WORKING ##### ###################### ### " BMS140 letící DCT PITOK se EC EPWW nepodařilo přeladit na kmitočet sektoru M. "@en http://onto.fel.cvut.cz/ontologies/documentation/report-i/246BAFD49E19E611B897002655546824.e5x/246BAFD49E19E611B897002655546824.xml ### PIC po DEP ohlasil střet s ptákem v bodě rotace. http://onto.fel.cvut.cz/ontologies/documentation/report-i/36E482143035E611B897002655546824.e5x/36E482143035E611B897002655546824.xml ##################### ###### DEPRECATED ##### ##################### ### RCOM LKPR - Rušení FREQ 132,890 http://onto.fel.cvut.cz/ontologies/report-2FA6D6D1AE15E611B897002655546824.xml

Save eccairs schema
type: ExportToRDFFile
base URI: http://onto.fel.cvut.cz/ontologies/eccairs/aviation-3.4.0.2
target file path: /inbas/forms/eccairs-0.2/output/aviation-eccairs-3.4.0.2.ttl

Save sample report
type: ExportToRDFFile
base URI: http://onto.fel.cvut.cz/ontologies/report-2FA6D6D1AE15E611B897002655546824.xml/temp
target file path: /inbas/forms/eccairs-0.2/output/sample-report.ttl

Annotate saved questions
type: ApplyConstruct
next: Recover question template from origin
construct query: Construct
  templates:
    object: saved-questions
    predicate: is-relevant-if
    subject:
      var name: q
  text: CONSTRUCT { ?q form:is-relevant-if "saved-questions" . } WHERE { ?q a doc:question . }
  where:
    object: question
    predicate: type
    subject:
      var name: q
replace: true

Application repository url
type: DatatypeProperty
range: string

attach-clone-values
type: ApplyConstruct
has-input-graph-constraint: Ask
  text: # there is a question that is both clone and cloned ASK WHERE { ?q form:is-clone-of-question ?clonedQ . ?cloneQ form:is-clone-of-question ?q . }
  where:
    object:
      var name: clonedQ
    predicate: is-clone-of-question
    subject:
      var name: q
  where:
    object:
      var name: q
    predicate: is-clone-of-question
    subject:
      var name: cloneQ
  comment: there is a question that is both clone and cloned
has-input-graph-constraint: Ask
  text: # there is a question that is clone of multiple questions ASK WHERE { ?q form:is-clone-of-question ?clonedQ1 ; form:is-clone-of-question ?clonedQ2 . FILTER(?clonedQ1 != ?clonedQ2) }
  where:
    object:
      var name: clonedQ1
    predicate: is-clone-of-question
    subject:
      var name: q
  where:
    object:
      var name: clonedQ2
    predicate: is-clone-of-question
    subject:
      var name: q
  where: Filter
    expression: ne
      arg1:
        var name: clonedQ1
      arg2:
        var name: clonedQ2
  comment: there is a question that is clone of multiple questions
has-output-graph-constraint: Ask
  text: # there is a question clone without answer value ASK WHERE { ?q a doc:question ; form:is-clone-of-question ?clonedQ . FILTER NOT EXISTS { ?q doc:has_answer ?a . ?a doc:has_data_value ?qPath . } }
  where:
    object: question
    predicate: type
    subject:
      var name: q
  where:
    object:
      var name: clonedQ
    predicate: is-clone-of-question
    subject:
      var name: q
  where: Filter
    expression: notExists
      elements:
        predicate: has answer
      elements:
        predicate: has data value
  comment: there is a question clone without answer value
next: disable-question-clones
construct query: Construct
  templates:
    object:
      var name: boundA
    predicate: has answer
    subject:
      var name: q
  templates:
    object: answer
    predicate: type
    subject:
      var name: boundA
  templates:
    object:
      var name: qPath
    predicate: has data value
    subject:
      var name: boundA
  text: CONSTRUCT { ?q doc:has_answer ?boundA . ?boundA a doc:answer ; doc:has_data_value ?qPath . } WHERE { ?q form:is-clone-of-question ?clonedQ . ?clonedQ form-ecc-gen-0.2:has-question-path ?clonedQPath . OPTIONAL { ?q doc:has_answer ?a . } BIND(concat("links to ", ?clonedQPath, "") as ?qPath) BIND(form-ecc-lib:create-a(?q) as ?newA) BIND(COALESCE(?a, ?newA) as ?boundA) }
  where:
    object:
      var name: clonedQ
    predicate: is-clone-of-question
    subject:
      var name: q
  where:
    object:
      var name: clonedQPath
    predicate: has question path
    subject:
      var name: clonedQ
  where: Optional
    elements:
      object:
        var name: a
      predicate: has answer
      subject:
        var name: q
  where: Bind
    expression: concat
      arg1: links to
      arg2:
        var name: clonedQPath
    variable:
      var name: qPath
  where: Bind
    expression: create-a
      arg1:
        var name: q
    variable:
      var name: newA
  where: Bind
    expression: coalesce
      arg1:
        var name: a
      arg2:
        var name: newA
    variable:
      var name: boundA
replace: false

attach-eccairs-views
type: ApplyConstruct
has-input-graph-constraint: Ask
  text: # each section defines subset of attributes of exactly one entity ASK WHERE { # SERVICE ?operationalFullServiceUri { # ?topic e-mv:entityid ?ent . # ?topic e-mv:has_child ?section . # ?section e-mv:allattributes ?attr . # ?section rdfs:label ?sectionLabel . # } }
  comment: each section defines subset of attributes of exactly one entity
has-output-graph-constraint: Ask
  text: # there is a question template relation that does not have its reification constructed ASK WHERE { ?parent_qt form:has-subtemplate ?child_qt . FILTER NOT EXISTS { ?r_qt_relation rdf:subject ?parent_qt ; rdf:predicate form:has-subtemplate ; rdf:object ?child_qt . } }
  where:
    object:
      var name: child_qt
    predicate: has-subtemplate
    subject:
      var name: parent_qt
  where: Filter
    expression: notExists
      elements:
        predicate: subject
      elements:
        object: has-subtemplate
        predicate: predicate
      elements:
        predicate: object
  comment: there is a question template relation that does not have its reification constructed
has-output-graph-constraint: Ask
  text: # there is a section with sub-template relation that does not have its reification ASK WHERE { ?section_qt form:has-subtemplate ?child_qt ; form:has-origin-type e-mv:section . FILTER NOT EXISTS { ?r_qt_relation rdf:subject ?section_qt ; rdf:predicate form:has-subtemplate ; rdf:object ?child_qt . } }
  where:
    object:
      var name: child_qt
    predicate: has-subtemplate
    subject:
      var name: section_qt
  where:
    object: section
    predicate: has-origin-type
    subject:
      var name: section_qt
  where: Filter
    expression: notExists
      elements:
        predicate: subject
      elements:
        object: has-subtemplate
        predicate: predicate
      elements:
        predicate: object
  comment: there is a section with sub-template relation that does not have its reification
next: attach-subtemplate-relation-metadata
construct query: Construct
  templates:
    object:
      var name: section_qt
    predicate: has-subtemplate
    subject:
      var name: ent_qt
  templates:
    object: question-template
    predicate: type
    subject:
      var name: section_qt
  templates:
    object:
      var name: attr_qt
    predicate: has-subtemplate
    subject:
      var name: section_qt
  templates:
    object:
      var name: sectionLabelFixed
    predicate: label
    subject:
      var name: section_qt
  templates:
    object:
      var name: section
    predicate: has-template-origin
    subject:
      var name: section_qt
  templates:
    object: section
    predicate: has-origin-type
    subject:
      var name: section_qt
  templates:
    object:
      var name: section_qt
    predicate: subject
    subject:
      var name: r_sec_attr_qt_relation
  templates:
    object: has-subtemplate
    predicate: predicate
    subject:
      var name: r_sec_attr_qt_relation
  templates:
    object:
      var name: attr_qt
    predicate: object
    subject:
      var name: r_sec_attr_qt_relation
  templates:
    object:
      var name: isLinkFlag
    predicate: is-relevant-if
    subject:
      var name: r_sec_attr_qt_relation
  templates:
    object:
      var name: ent_qt
    predicate: subject
    subject:
      var name: r_ent_sec_qt_relation
  templates:
    object: has-subtemplate
    predicate: predicate
    subject:
      var name: r_ent_sec_qt_relation
  templates:
    object:
      var name: section_qt
    predicate: object
    subject:
      var name: r_ent_sec_qt_relation
  templates:
    object:
      var name: ent_qt
    predicate: subject
    subject:
      var name: r_qt_relation
  templates:
    object: has-subtemplate
    predicate: predicate
    subject:
      var name: r_qt_relation
  templates:
    object:
      var name: attr_qt
    predicate: object
    subject:
      var name: r_qt_relation
  templates:
    object: eccairs-data-schema
    predicate: is-relevant-if
    subject:
      var name: r_qt_relation
  text: # constuct eccairs views CONSTRUCT { # TODO -- not very readable .. should have been constructed incrementaly using construct-recursion ?ent_qt form:has-subtemplate ?section_qt . ?section_qt a form:question-template ; form:has-subtemplate ?attr_qt ; rdfs:label ?sectionLabelFixed ; form:has-template-origin ?section ; form:has-origin-type e-mv:section . ?r_sec_attr_qt_relation rdf:subject ?section_qt ; rdf:predicate form:has-subtemplate ; rdf:object ?attr_qt ; form:is-relevant-if ?isLinkFlag . ?r_ent_sec_qt_relation rdf:subject ?ent_qt ; rdf:predicate form:has-subtemplate ; rdf:object ?section_qt . # filtering rule ?r_qt_relation rdf:subject ?ent_qt ; rdf:predicate form:has-subtemplate ; rdf:object ?attr_qt ; form:is-relevant-if "eccairs-data-schema" . } WHERE { # match question template entity -> attribute ?ent_qt form:has-subtemplate ?attr_qt . ?ent_qt form:has-template-origin ?ent . ?attr_qt form:has-template-origin ?attr . ?ent a e-m:entity . ?attr a e-m:attribute . # match softlinks ?r_qt_relation rdf:subject ?ent_qt ; rdf:predicate form:has-subtemplate ; rdf:object ?attr_qt . OPTIONAL { ?r_qt_relation form:is-relevant-if ?isLinkFlag . } SERVICE ?operationalFullServiceUri { ?topic e-mv:entityid ?ent . ?topic e-mv:has_child ?section . ?section e-mv:allattributes ?attr . ?section rdfs:label ?sectionLabel . } # bind new reification of entity -> section relation BIND(md5(concat(str(?r_qt_relation), "-", str(?section))) as ?r_new_qt_relation_id) BIND(iri(concat(str(?ent), "-", ?r_new_qt_relation_id, "-qts-relation")) as ?r_ent_sec_qt_relation) # bind new reification of section -> attribute relation BIND(iri(concat(str(?section), "-", ?r_new_qt_relation_id, "-qts-relation")) as ?r_sec_attr_qt_relation) BIND(form-ecc-lib:create-qt(?section) as ?section_qt) # BIND(spif:titleCase(fn:lower-case(replace(?sectionLabel, "_", " "))) as ?sectionLabelFixed) BIND(fn:lower-case(replace(?sectionLabel, "_", " ")) as ?sectionLabelFixed) }
  where:
    object:
      var name: attr_qt
    predicate: has-subtemplate
    subject:
      var name: ent_qt
  where:
    object:
      var name: ent
    predicate: has-template-origin
    subject:
      var name: ent_qt
  where:
    object:
      var name: attr
    predicate: has-template-origin
    subject:
      var name: attr_qt
  where:
    object: entity
    predicate: type
    subject:
      var name: ent
  where:
    object: attribute
    predicate: type
    subject:
      var name: attr
  where:
    object:
      var name: ent_qt
    predicate: subject
    subject:
      var name: r_qt_relation
  where:
    object: has-subtemplate
    predicate: predicate
    subject:
      var name: r_qt_relation
  where:
    object:
      var name: attr_qt
    predicate: object
    subject:
      var name: r_qt_relation
  where: Optional
    elements:
      object:
        var name: isLinkFlag
      predicate: is-relevant-if
      subject:
        var name: r_qt_relation
  where: Service
    elements:
      object:
        var name: ent
      predicate: entityid
      subject:
        var name: topic
  where: Bind
  comment: constuct eccairs views
replace: false

Attach attribute-based event-type filter to templates
type: ApplyConstruct
next: Attach entity-based event-type filter to templates
construct query: Construct
  templates:
    object: uniset-event-enhancement
    predicate: is-relevant-if
    subject:
      var name: qt
  text: # 1 - annotate uniset attributes CONSTRUCT { ?qt form:is-relevant-if "uniset-event-enhancement" . } WHERE { SERVICE ?eccairsMappingServiceUri { ?situation a e-m-map:organization-to-attribute-mapping ; e-m-map:has-if-present-organization-type ?organizationType ; # e-m-map:has-if-present-attribute-value ?eccRelAttributeValue . e-m-map:has-related-attribute-value ?eccAttributeValue . } ?qt form:has-template-origin ?eccAttributeValue . }
  where: Service
    elements:
      object: organization-to-attribute-mapping
      predicate: type
      subject:
        var name: situation
    elements:
      object:
        var name: organizationType
      predicate: has-if-present-organization-type
      subject:
        var name: situation
    elements:
      object:
        var name: eccAttributeValue
      predicate: has-related-attribute-value
      subject:
        var name: situation
    service URI:
      var name: eccairsMappingServiceUri
  where:
    object:
      var name: eccAttributeValue
    predicate: has-template-origin
    subject:
      var name: qt
  comment: 1 - annotate uniset attributes
construct query: Construct
  templates:
    object:
      var name: eccEventType
    predicate: is-relevant-if
    subject:
      var name: qt
  templates:
    object: value
    predicate: type
    subject:
      var name: eccEventType
  text: # 0 - annotate event-type specific attributes CONSTRUCT { ?qt form:is-relevant-if ?eccEventType . ?eccEventType a e-m:value . } WHERE { SERVICE ?eccairsMappingServiceUri { ?situation a e-m-map:event-type-to-attribute-mapping ; e-m-map:has-event-type-value ?eccEventType ; e-m-map:has-if-present-organization-type ?organizationType ; # e-m-map:has-if-present-attribute-value ?eccRelAttributeValue . e-m-map:has-related-attribute-value ?eccAttributeValue . } ?qt form:has-template-origin ?eccAttributeValue . }
  where: Service
    elements:
      object: event-type-to-attribute-mapping
      predicate: type
      subject:
        var name: situation
    elements:
      object:
        var name: eccEventType
      predicate: has-event-type-value
      subject:
        var name: situation
    elements:
      object:
        var name: organizationType
      predicate: has-if-present-organization-type
      subject:
        var name: situation
    elements:
      object:
        var name: eccAttributeValue
      predicate: has-related-attribute-value
      subject:
        var name: situation
    service URI:
      var name: eccairsMappingServiceUri
  where:
    object:
      var name: eccAttributeValue
    predicate: has-template-origin
    subject:
      var name: qt
  comment: 0 - annotate event-type specific attributes
replace: false

attach-event-type-question-links
type: ApplyConstruct
has-output-graph-constraint: Ask
  text: # there exists question that relates to link but is not clone of any other question ASK WHERE { FILTER(true = false) }
  where: Filter
    expression: eq
      arg1: true
      arg2: false
  comment: there exists question that relates to link but is not clone of any other question
next: form generator sink
construct query: Construct
  templates:
    object:
      var name: q2
    predicate: is-clone-of-question
    subject:
      var name: q1
  templates:
    object: is-question-clone
    predicate: is-relevant-if
    subject:
      var name: q1
  text: # construct links between event-type questions CONSTRUCT { ?q1 form:is-clone-of-question ?q2 ; form:is-relevant-if "is-question-clone" . } WHERE { # bind question 1 ?parentQ1 doc:has_related_question ?q1 ; form:has-template ?parentQT1 . ?q1 a doc:question ; form:has-template ?qt ; ### constructed by event-enhancement form:is-relevant-if "event-enhancement" . ?q1QTSRelation rdf:subject ?parentQT1 ; rdf:object ?qt. # bind question 2 ?parentQ2 doc:has_related_question ?q2 ; form:has-template ?parentQT2 . ?q2 a doc:question ; form:has-template ?qt ; ### constructed by event-enhancement form:is-relevant-if "event-enhancement" . ?q2QTSRelation rdf:subject ?parentQT2 ; rdf:object ?qt. # check link template ?q1QTSRelation form:is-link-template-of ?q2QTSRelation . FILTER(?q1 != ?q2) }
  where:
    object:
      var name: q1
    predicate: has related question
    subject:
      var name: parentQ1
  where:
    object:
      var name: parentQT1
    predicate: has-template
    subject:
      var name: parentQ1
  where:
    object: question
    predicate: type
    subject:
      var name: q1
  where:
    object:
      var name: qt
    predicate: has-template
    subject:
      var name: q1
  where:
    object: event-enhancement
    predicate: is-relevant-if
    subject:
      var name: q1
  where:
    object:
      var name: parentQT1
    predicate: subject
    subject:
      var name: q1QTSRelation
  where:
    object:
      var name: qt
    predicate: object
    subject:
      var name: q1QTSRelation
  where:
    object:
      var name: q2
    predicate: has related question
    subject:
      var name: parentQ2
  where:
    object:
      var name: parentQT2
    predicate: has-template
    subject:
      var name: parentQ2
  where:
    object: question
    predicate: type
    subject:
      var name: q2
  where:
    object:
      var name: qt
    predicate: has-template
    subject:
      var name: q2
  where:
    object: event-enhancement
    predicate: is-relevant-if
    subject:
      var name: q2
  where:
    object:
      var name: parentQT2
    predicate: subject
    subject:
      var name: q2QTSRelation
  where:
    object:
      var name: qt
    predicate: object
    subject:
      var name: q2QTSRelation
  where:
    object:
      var name: q2QTSRelation
    predicate: is-link-template-of
    subject:
      var name: q1QTSRelation
  where: Filter
    expression: ne
      arg1:
        var name: q1
      arg2:
        var name: q2
  comment: construct links between event-type questions
replace: false

attach-imported-answers
type: ApplyConstruct
next: filter-populable-answers
construct query: Construct
  templates:
    object: answer
    predicate: type
    subject:
      var name: a
  templates:
    object:
      var name: a
    predicate: has answer
    subject:
      var name: q
  text: CONSTRUCT { ?a a doc:answer . ?q doc:has_answer ?a . } WHERE { ?q a doc:question . BIND(form-ecc-lib:create-a(?q) as ?a) }
  where:
    object: question
    predicate: type
    subject:
      var name: q
  where: Bind
    expression: create-a
      arg1:
        var name: q
    variable:
      var name: a

attach-imported-question-links
type: ApplyConstruct
next: Attach event-type questions from templates
construct query: Construct
  templates:
    object:
      var name: q2
    predicate: is-clone-of-question
    subject:
      var name: q1
  templates:
    object: is-question-clone
    predicate: is-relevant-if
    subject:
      var name: q1
  text: # construct links between imported questions CONSTRUCT { ?q1 form:is-clone-of-question ?q2 ; form:is-relevant-if "is-question-clone" . } WHERE { ?q1 a doc:question ; form:has-question-origin ?q1Origin . ?q1Origin form-ecc-gen-0.2:is-origin-of-question-templates-reification ?q1QTSRelation ; rdf:object ?qObject . ?q2 a doc:question ; form:has-question-origin ?q2Origin . ?q2Origin form-ecc-gen-0.2:is-origin-of-question-templates-reification ?q2QTSRelation ; rdf:object ?qObject . ?q1QTSRelation form:is-link-template-of ?q2QTSRelation . FILTER(?q1 != ?q2) }
  where:
    object: question
    predicate: type
    subject:
      var name: q1
  where:
    object:
      var name: q1Origin
    predicate: has-question-origin
    subject:
      var name: q1
  where:
    object:
      var name: q1QTSRelation
    predicate: is-origin-of-question-templates-reification
    subject:
      var name: q1Origin
  where:
    object:
      var name: qObject
    predicate: object
    subject:
      var name: q1Origin
  where:
    object: question
    predicate: type
    subject:
      var name: q2
  where:
    object:
      var name: q2Origin
    predicate: has-question-origin
    subject:
      var name: q2
  where:
    object:
      var name: q2QTSRelation
    predicate: is-origin-of-question-templates-reification
    subject:
      var name: q2Origin
  where:
    object:
      var name: qObject
    predicate: object
    subject:
      var name: q2Origin
  where:
    object:
      var name: q2QTSRelation
    predicate: is-link-template-of
    subject:
      var name: q1QTSRelation
  where: Filter
    expression: ne
      arg1:
        var name: q1
      arg2:
        var name: q2
  comment: construct links between imported questions
replace: false

attach imported questions
type: ApplyConstruct
has-input-graph-constraint: Ask
  text: # there is a question template without label ASK WHERE { ?qt a form:question-template . FILTER NOT EXISTS { ?qt rdfs:label ?label . } . }
  where:
    object: question-template
    predicate: type
    subject:
      var name: qt
  where: Filter
    expression: notExists
      elements:
        predicate: label
  comment: there is a question template without label
has-max-iteration-count: 15
has-output-graph-constraint: Ask
  text: # 0 - there is a question without specified question template ASK WHERE { ?question a doc:question . FILTER NOT EXISTS { ?question form:has-template ?questionTemplate . } . }
  where:
    object: question
    predicate: type
    subject:
      var name: question
  where: Filter
    expression: notExists
      elements:
        predicate: has-template
  comment: 0 - there is a question without specified question template
has-output-graph-constraint: Ask
  text: # 1 - there is a question without specified question origin ASK WHERE { ?question a doc:question . FILTER NOT EXISTS { ?question form:has-question-origin ?origin . } . }
  where:
    object: question
    predicate: type
    subject:
      var name: question
  where: Filter
    expression: notExists
      elements:
        predicate: has-question-origin
  comment: 1 - there is a question without specified question origin
has-output-graph-constraint: Ask
  text: # 3 - question for a question origin does not exist ASK WHERE { FILTER(! bound(?savedQAExists)) ?questionOrigin a form:question-origin . FILTER NOT EXISTS { ?q form:has-question-origin ?questionOrigin . } }
  where: Filter
    expression: not
      arg1: bound
  where:
    object: question-origin
    predicate: type
    subject:
      var name: questionOrigin
  where: Filter
    expression: notExists
      elements:
        predicate: has-question-origin
  comment: 3 - question for a question origin does not exist
has-output-graph-constraint: Ask
  text: # 4 - there is a question with two parent questions w.r.t. has_related_question relation ASK WHERE { ?parentQ1 doc:has_related_question ?childQ . ?parentQ2 doc:has_related_question ?childQ . FILTER(?parentQ1 != ?parentQ2) }
  where:
    object:
      var name: childQ
    predicate: has related question
    subject:
      var name: parentQ1
  where:
    object:
      var name: childQ
    predicate: has related question
    subject:
      var name: parentQ2
  where: Filter
    expression: ne
      arg1:
        var name: parentQ1
      arg2:
        var name: parentQ2
  comment: 4 - there is a question with two parent questions w.r.t. has_related_question relation
next: attach-imported-answers
next: attach-imported-question-links
construct query: Construct
  templates:
    object:
      var name: childQ
    predicate: has related question
    subject:
      var name: parentQ
  templates:
    object: question
    predicate: type
    subject:
      var name: childQ
  templates:
    object:
      var name: childOrigin
    predicate: has-question-origin
    subject:
      var name: childQ
  templates:
    object:
      var name: childQT
    predicate: has-template
    subject:
      var name: childQ
  templates:
    object: imported-question
    predicate: is-relevant-if
    subject:
      var name: childQ
  templates:
    object:
      var name: childLabel
    predicate: altLabel
    subject:
      var name: childQ
  text: # 0 - construct simple imported questions (without section) CONSTRUCT { ?parentQ doc:has_related_question ?childQ . ?childQ a doc:question ; form:has-question-origin ?childOrigin ; form:has-template ?childQT ; form:is-relevant-if "imported-question" . # for debugging only ?childQ skos:altLabel ?childLabel . } WHERE { # precondition -- questions where not saved yet FILTER(! bound(?savedQAExists)) # bind parent Q ?parentQ a doc:question ; form:has-question-origin ?parentOrigin ; form:has-template ?parentQT . # parent must not be created from softlink ?parentOrigin form-ecc-gen-0.2:is-origin-of-question-templates-reification ?parentQTRelation . FILTER NOT EXISTS { ?parentQTRelation form:is-relevant-if "is-link" . } # bind childOrigin, childQT; bound(?childOrigin) => not a section ?childOrigin a form:question-origin ; form-ecc-gen-0.2:is-origin-of-question-template ?childQT ; rdf:subject ?parentObject . ?parentOrigin rdf:object ?parentObject . # retrive from QT schema ?parentQT form:has-subtemplate ?childQT . # childQT is entity => childOrigin is one per question BIND(form-ecc-lib:create-q(concat(str(?childOrigin), "-", ?executionId)) AS ?childQ) # for debugging only ?childQT rdfs:label ?childLabel . }
  where: Filter
    expression: not
      arg1: bound
  where:
    object: question
    predicate: type
    subject:
      var name: parentQ
  where:
    object:
      var name: parentOrigin
    predicate: has-question-origin
    subject:
      var name: parentQ
  where:
    object:
      var name: parentQT
    predicate: has-template
    subject:
      var name: parentQ
  where:
    object:
      var name: parentQTRelation
    predicate: is-origin-of-question-templates-reification
    subject:
      var name: parentOrigin
  where: Filter
    expression: notExists
      elements:
        object: is-link
        predicate: is-relevant-if
  where:
    object: question-origin
    predicate: type
    subject:
      var name: childOrigin
  where:
    object:
      var name: childQT
    predicate: is-origin-of-question-template
    subject:
      var name: childOrigin
  where:
    object:
      var name: parentObject
    predicate: subject
    subject:
      var name: childOrigin
  where:
    object:
      var name: parentObject
    predicate: object
    subject:
      var name: parentOrigin
  where:
    object:
      var name: childQT
    predicate: has-subtemplate
    subject:
      var name: parentQT
  where: Bind
    expression: create-q
      arg1: concat
        arg1: str
        arg2: -
    variable:
      var name: childQ
  where:
    object:
      var name: childLabel
    predicate: label
    subject:
      var name: childQT
  comment: 0 - construct simple imported questions (without section)
construct query: Construct
  templates:
    object:
      var name: secQ
    predicate: has related question
    subject:
      var name: entQ
  templates:
    object: question
    predicate: type
    subject:
      var name: secQ
  templates:
    object:
      var name: secOrigin
    predicate: has-question-origin
  text: # 1 - construct imported questions within section CONSTRUCT { ?entQ doc:has_related_question ?secQ . ?secQ a doc:question ; form:has-question-origin ?secOrigin ; form:has-template ?secQT ; form:is-relevant-if "imported-question" ; form:is-relevant-if "section-question" ; doc:has_related_question ?attrQ . ?attrQ a doc:question ; form:has-question-origin ?attrOrigin ; form:has-template ?attrQT ; form:is-relevant-if "imported-question" ; form:is-relevant-if "part-of-view-question" ; form:is-relevant-if ?isLinkFlag . # for debugging only ?secQ skos:altLabel ?secLabel . ?attrQ skos:altLabel ?attrLabel . } WHERE { # precondition -- questions where not saved yet FILTER(! bound(?savedQAExists)) # bind entQ ?entQ a doc:question ; form:has-question-origin ?entOrigin ; form:has-template ?entQT . # entQ must not be created from softlink ?entOrigin form-ecc-gen-0.2:is-origin-of-question-templates-reification ?entQTRelation . FILTER NOT EXISTS { ?entQTRelation form:is-relevant-if "is-link" . } # bind attrOrigin, attrQT ?attrOrigin form-ecc-gen-0.2:is-origin-of-question-template ?attrQT ; rdf:subject ?entObject . ?entOrigin rdf:object ?entObject . # bind entQT -> secQT -> attrQT ?entQT form:has-subtemplate ?secQT . ?secQT form:has-subtemplate ?attrQT . # ensure secQT is section ?secQT form:has-template-origin ?section . ?secQT form:has-origin-type e-mv:section . # bind section metadata BIND(md5(concat(str(?entOrigin), str(?section), ?executionId)) as ?secId) BIND(form-ecc-lib:create-qo(?secQT) AS ?secOrigin) BIND(form-ecc-lib:create-q(concat(str(?section),"-",?secId)) AS ?secQ) # bind attr metadata BIND(md5(concat(str(?section), str(?attrOrigin), ?executionId)) as ?attrId) BIND(form-ecc-lib:create-q(concat(str(?attrOrigin),"-",?attrId)) AS ?attrQ) # for debugging only ?secQT rdfs:label ?secLabel . ?attrQT rdfs:label ?attrLabel . }
  where: Filter
  where: Bind
  comment: 1 - construct imported questions within section
replace: false
comment: There is no need to pay special attention to hard-links as each question origin of imported data represents exactly 1 hard-link.

attach-initial-question-path
type: ApplyConstruct
next: attach question paths
construct query: Construct
  templates:
    predicate: has question path
    subject:
      var name: rootQ
  text: CONSTRUCT { ?rootQ form-ecc-gen-0.2:has-question-path "" . } WHERE { ?rootQT form:has-template-origin ?rootEntity . ?rootQ form:has-template ?rootQT . }
  where:
    object:
      var name: rootEntity
    predicate: has-template-origin
    subject:
      var name: rootQT
  where:
    object:
      var name: rootQT
    predicate: has-template
    subject:
      var name: rootQ

attach question paths
type: ApplyConstruct
has-max-iteration-count: 10
has-output-graph-constraint: Ask
  text: # there is a question without question path assigned ASK WHERE { ?q a doc:question . FILTER NOT EXISTS { ?q form-ecc-gen-0.2:has-question-path ?path . } }
  where:
    object: question
    predicate: type
    subject:
      var name: q
  where: Filter
    expression: notExists
      elements:
        predicate: has question path
  comment: there is a question without question path assigned
next: attach-clone-values
construct query: Construct
  templates:
    object:
      var name: childPath
    predicate: has question path
    subject:
      var name: childQ
  text: CONSTRUCT { ?childQ form-ecc-gen-0.2:has-question-path ?childPath . } WHERE { ?parentQ form-ecc-gen-0.2:has-question-path ?parentPath . ?parentQ doc:has_related_question ?childQ . ?childQ rdfs:label ?childLabel . BIND(concat(?parentPath, "/", ?childLabel) as ?childPath) }
  where:
    object:
      var name: parentPath
    predicate: has question path
    subject:
      var name: parentQ
  where:
    object:
      var name: childQ
    predicate: has related question
    subject:
      var name: parentQ
  where:
    object:
      var name: childLabel
    predicate: label
    subject:
      var name: childQ
  where: Bind
    expression: concat
      arg1:
        var name: parentPath
      arg2: /
      arg3:
        var name: childLabel
    variable:
      var name: childPath
replace: false

Attach possible values hook
type: ApplyConstruct
next: merge-form-data
construct query: Construct
  templates:
    object:
      var name: downloadString
    predicate: has-possible-values-query
    subject:
      var name: question
  templates:
    object: type-ahead
    predicate: has-layout-class
    subject:
      var name: question
  text: # TODO nemalo by byt potreba to viazat na eccairs schema URI CONSTRUCT { ?question form:has-possible-values-query ?downloadString . # TODO layout sem nepatri !!!! ?question form-lt:has-layout-class "type-ahead" . } WHERE { # get all attributes with predefined value type SERVICE ?eccairsSchemaServiceUri { ?eccAttribute a e-m:attribute . ?eccAttribute e-m:has-value-type "PredefinedValueList" . } ?question a doc:question . ?question form:has-template ?questionTemplate . ?questionTemplate form:has-template-origin ?eccAttribute . BIND(CONCAT(str(?eccairsSchemaServiceUri), "&query=") as ?dowloadPrefix) BIND(replace(?attributePossibleValuesQueryTemplate, "XXXXX", str(?eccAttribute)) as ?downloadSuffixRaw) BIND(ENCODE_FOR_URI(?downloadSuffixRaw) as ?downloadSuffix) BIND(concat(?dowloadPrefix, ?downloadSuffix) as ?downloadString) }
  where: Service
    elements:
      object: attribute
      predicate: type
      subject:
        var name: eccAttribute
    elements:
      object: PredefinedValueList
      predicate: has-value-type
      subject:
        var name: eccAttribute
    service URI:
      var name: eccairsSchemaServiceUri
  where:
    object: question
    predicate: type
    subject:
      var name: question
  where:
    object:
      var name: questionTemplate
    predicate: has-template
    subject:
      var name: question
  where:
    object:
      var name: eccAttribute
    predicate: has-template-origin
    subject:
      var name: questionTemplate
  where: Bind
    expression: concat
      arg1: str
      arg2: &query=
    variable:
      var name: dowloadPrefix
  where: Bind
    expression: replace
      arg1:
        var name: attributePossibleValuesQueryTemplate
      arg2: XXXXX
      arg3: str
    variable:
      var name: downloadSuffixRaw
  where: Bind
    expression: encode for uri
      arg1:
        var name: downloadSuffixRaw
    variable:
      var name: downloadSuffix
  where: Bind
    expression: concat
      arg1:
        var name: dowloadPrefix
      arg2:
        var name: downloadSuffix
    variable:
      var name: downloadString
  comment: TODO nemalo by byt potreba to viazat na eccairs schema URI
replace: true

attach-subtemplate-relation-metadata
type: ApplyConstruct
has-input-graph-constraint: Ask
  text: # there is a template without label ASK WHERE { ?qt a form:question-template . OPTIONAL { ?qt rdfs:label ?qtLabel . } FILTER(! bound(?qtLabel)) }
  where:
    object: question-template
    predicate: type
    subject:
      var name: qt
  where: Optional
    elements:
      object:
        var name: qtLabel
      predicate: label
      subject:
        var name: qt
  where: Filter
    expression: not
      arg1: bound
  comment: there is a template without label
has-output-graph-constraint: Ask
  text: # there is a subtemplate relation without label ASK WHERE { ?qtsRelation rdf:predicate form:has-subtemplate . OPTIONAL { ?qtsRelation rdfs:label ?qtsRelationLabel . } FILTER(! bound(?qtsRelationLabel)) }
  where:
    object: has-subtemplate
    predicate: predicate
    subject:
      var name: qtsRelation
  where: Optional
    elements:
      object:
        var name: qtsRelationLabel
      predicate: label
      subject:
        var name: qtsRelation
  where: Filter
    expression: not
      arg1: bound
  comment: there is a subtemplate relation without label
next: Filter out irrelevant templates
construct query: Construct
  templates:
    object:
      var name: qtsRelationLabel
    predicate: label
    subject:
      var name: qtsRelation
  text: CONSTRUCT { ?qtsRelation rdfs:label ?qtsRelationLabel . } WHERE { ?qtsRelation rdf:predicate form:has-subtemplate ; rdf:object ?objQT . ?objQT rdfs:label ?objQTLabel . OPTIONAL { ?qtsRelation rdf:subject ?subjQT . ?subjQT rdfs:label ?subjQTLabel . } BIND(COALESCE(?subjQTLabel, "") as ?subjQTBoundLabel) BIND(concat(?subjQTBoundLabel, " -> ", ?objQTLabel) as ?qtsRelationLabel) }
  where:
    object: has-subtemplate
    predicate: predicate
    subject:
      var name: qtsRelation
  where:
    object:
      var name: objQT
    predicate: object
    subject:
      var name: qtsRelation
  where:
    object:
      var name: objQTLabel
    predicate: label
    subject:
      var name: objQT
  where: Optional
    elements:
      object:
        var name: subjQT
      predicate: subject
      subject:
        var name: qtsRelation
    elements:
      object:
        var name: subjQTLabel
      predicate: label
      subject:
        var name: subjQT
  where: Bind
    expression: coalesce
      arg1:
        var name: subjQTLabel
    variable:
      var name: subjQTBoundLabel
  where: Bind
    expression: concat
      arg1:
        var name: subjQTBoundLabel
      arg2: ->
      arg3:
        var name: objQTLabel
    variable:
      var name: qtsRelationLabel
replace: false

Attach entity-based event-type filter to templates
type: ApplyConstruct
has-max-iteration-count: 6
next: bind-event-type-matcher
construct query: Construct
  templates:
    object: uniset-event-enhancement
    predicate: is-relevant-if
    subject:
      var name: parentQT
  text: # 1 - propagates is-relevant-if uniset-flag from attributes to entities CONSTRUCT { ?parentQT form:is-relevant-if "uniset-event-enhancement" . } WHERE { ?parentQT form:has-subtemplate ?childQT . ?childQT form:is-relevant-if "uniset-event-enhancement" . }
  where:
    object:
      var name: childQT
    predicate: has-subtemplate
    subject:
      var name: parentQT
  where:
    object: uniset-event-enhancement
    predicate: is-relevant-if
    subject:
      var name: childQT
  comment: 1 - propagates is-relevant-if uniset-flag from attributes to entities
construct query: Construct
  templates:
    object:
      var name: eccEventType
    predicate: is-relevant-if
    subject:
      var name: parentQT
  text: # 0 - propagates is-relevant-if event from attributes to entities CONSTRUCT { ?parentQT form:is-relevant-if ?eccEventType . } WHERE { ?parentQT form:has-subtemplate ?childQT . ?childQT form:is-relevant-if ?eccEventType . ?eccEventType a e-m:value . }
  where:
    object:
      var name: childQT
    predicate: has-subtemplate
    subject:
      var name: parentQT
  where:
    object:
      var name: eccEventType
    predicate: is-relevant-if
    subject:
      var name: childQT
  where:
    object: value
    predicate: type
    subject:
      var name: eccEventType
  comment: 0 - propagates is-relevant-if event from attributes to entities
replace: false

bind-attribute-query
type: BindWithConstant
next: Attach possible values hook
output variable: attributePossibleValuesQueryTemplate
value: prefix e-m: <http://onto.fel.cvut.cz/ontologies/eccairs/model/> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> CONSTRUCT { ?value rdfs:label ?label . ?value rdfs:comment ?explanation . } WHERE { ?eccAttribute a e-m:attribute . ?eccAttribute e-m:has-child+ ?value . ?value rdfs:label ?label . ?value e-m:has-explanation ?explanation . } VALUES (?eccAttribute) { (<XXXXX>) }

Bind concrete report service uri
type: BindWithConstant
next: Extract concrete report
output variable: concreteReportServiceUri
value: create-sparql-service-url
  arg1:
    var name: repositoryUrl
  arg2:
    var name: reportGraphId

Bind eccairs model service uri
type: BindWithConstant
next: Construct simple question templates
output variable: eccairsModelServiceUri
value: create-sparql-service-url
  arg1:
    var name: eccairsRepositoryUri
  arg2: http://onto.fel.cvut.cz/ontologies/eccairs/model

bind-event-type-matcher
type: BindBySelect
has-output-graph-constraint: Ask
  text: # event type matcher not bound ASK WHERE { FILTER(! bound(?eventTypeMatcher)) }
  where: Filter
    expression: not
      arg1: bound
  comment: event type matcher not bound
next: Attach event-type questions from templates
select query: Select
  limit: 1
  result variables:
    var name: eventTypeMatcher
  text: # bind matcher for event type enhancement SELECT ?eventTypeMatcher WHERE { # BIND(COALESCE(iri(?eventType), "uniset-event-enhancement") as ?eventTypeMatcher) BIND(iri(?eventType) as ?eventTypeIri) OPTIONAL { ?qt form:is-relevant-if ?eventTypeIri . } BIND((bound(?qt) && bound(?eventType)) as ?hasSpecificEventMapping) BIND(IF(?hasSpecificEventMapping, ?eventTypeIri, "uniset-event-enhancement") as ?eventTypeMatcher) } LIMIT 1
  where: Bind
    expression: iri
      arg1:
        var name: eventType
    variable:
      var name: eventTypeIri
  where: Optional
    elements:
      object:
        var name: eventTypeIri
      predicate: is-relevant-if
      subject:
        var name: qt
  where: Bind
    expression: and
      arg1: bound
      arg2: bound
    variable:
      var name: hasSpecificEventMapping
  where: Bind
    expression: if
      arg1:
        var name: hasSpecificEventMapping
      arg2:
        var name: eventTypeIri
      arg3: uniset-event-enhancement
    variable:
      var name: eventTypeMatcher
  comment: bind matcher for event type enhancement

bind-execution-id
type: BindBySelect
has-input-graph-constraint: Ask
  text: # input parameter "isIdempotent" is invalid ({?isIdempotent}) ASK { FILTER ( bound(?isIdempotent) && (str(?isIdempotent) != "true") && (str(?isIdempotent) != "false") ) }
  where: Filter
    expression: and
      arg1: and
        arg1: bound
        arg2: ne
      arg2: ne
        arg1: str
        arg2: false
  comment: input parameter "isIdempotent" is invalid ({?isIdempotent})
has-input-graph-constraint: Ask
  text: # input parameter reportKey is not bound ASK { FILTER ( ! bound(?reportKey) ) }
  where: Filter
    expression: not
      arg1: bound
  comment: input parameter reportKey is not bound
has-output-graph-constraint: Ask
  text: # input parameter executionId is not bound ASK { FILTER ( ! bound(?executionId) ) }
  where: Filter
    expression: not
      arg1: bound
  comment: input parameter executionId is not bound
next: Construct imported questions
node x: 4206
node y: 595
select query: Select
  result variables:
    var name: executionId
  text: SELECT ?executionId { # default value BIND(str(COALESCE(?isIdempotent, true)) as ?isIdempotentStr) # bind event BIND(COALESCE(str(?event), "") as ?eventStr) BIND(IF( ?isIdempotentStr = "false", STRUUID(), md5(concat(str(?reportKey), ?eventStr))) as ?executionId) }
  where: Bind
    expression: str
      arg1: coalesce
        arg2: true
    variable:
      var name: isIdempotentStr
  where: Bind
    expression: coalesce
      arg1: str
    variable:
      var name: eventStr
  where: Bind
    expression: if
      arg1: eq
        arg2: false
      arg2: struuid
      arg3: md5
        arg1: concat
    variable:
      var name: executionId

bind-existence-of-imported-report
type: BindBySelect
next: filter-for-qa-construction
node x: 3418
node y: 442
select query: Select
  limit: 1
  result variables:
    var name: importedReportExists
  text: SELECT ?importedReportExists WHERE { ?q a e-m:instance . BIND("true"^^xsd:boolean as ?importedReportExists) } LIMIT 1
  where:
    object: instance
    predicate: type
    subject:
      var name: q
  where: Bind
    expression: true
    variable:
      var name: importedReportExists

Bind if Q&A exists
type: BindBySelect
next: Annotate saved questions
next: filter-out-all
select query: Select
  limit: 1
  result variables:
    var name: savedQAExists
  text: SELECT ?savedQAExists WHERE { ?q a doc:question . BIND("true"^^xsd:boolean as ?savedQAExists) } LIMIT 1
  where:
    object: question
    predicate: type
    subject:
      var name: q
  where: Bind
    expression: true
    variable:
      var name: savedQAExists

Bind imported report service uri
type: BindWithConstant
next: Extract imported report
output variable: importedReportServiceUri
value: create-sparql-service-url
  arg1:
    var name: repositoryUrl
  arg2:
    var name: dataGraphId

Bind imported reports repository uri
type: BindWithConstant
output variable: importedReportsRepositoryUri
value: concat
  arg1:
    var name: rdf4jServerUri
  arg2: /repositories/
  arg3: reports-refactoring

bind-operational-full-service-uri
type: BindWithConstant
next: attach-eccairs-views
output variable: operationalFullServiceUri
value: create-sparql-service-url
  arg1:
    var name: eccairsRepositoryUri
  arg2:
    var name: operationalFullUri

Bind question templates cache uri
type: BindWithConstant
next: question-templates-cache-service-uri
output variable: questionTemplatesCacheUri
value: http://onto.fel.cvut.cz/ontologies/forms/eccairs/question-templates

Bind record graph
type: BindWithConstant
output variable: reportGraphUriStable
value: http://www.inbas.cz/ontologies/reporting-tool/formGen

bind-report-key
type: BindBySelect
next: bind-execution-id
node x: 4206
node y: 456
select query: Select
  result variables:
    var name: reportKey
  text: SELECT ?reportKey WHERE { ?report a doc:report . ?report doc:has_key ?reportKey . }
  where:
    object: report
    predicate: type
    subject:
      var name: report
  where:
    object:
      var name: reportKey
    predicate: has key
    subject:
      var name: report

Bind reports repository
type: BindWithConstant
next: Bind record graph
output variable: reportsRepositoryUri
value: concat
  arg1:
    var name: rdf4jServerUri
  arg2: /repositories/
  arg3: form-generator

bind-root-entity
type: BindWithConstant
next: Construct question origins
output variable: rootEntity
value: e-24

Bind sample report service uri
type: BindWithConstant
next: Extract sample report
output variable: sampleReportServiceUri
value: create-sparql-service-url
  arg1:
    var name: sampleReportsRepositoryUri
  arg2:
    var name: sampleReportUri

Bind sample reports repository
type: BindWithConstant
next: Bind sample report service uri
output variable: sampleReportsRepositoryUri
value: concat
  arg1:
    var name: rdf4jServerUri
  arg2: /repositories/
  arg3: reports-refactoring

Bind schema mapping uri
type: BindWithConstant
output variable: schemaMappingUri
value: http://onto.fel.cvut.cz/ontologies/eccairs/mapping/aerodrome

construct-answer-origins
type: ApplyConstruct
next: populate answers
construct query: Construct
  templates:
    object: answer-origin
    predicate: type
    subject:
      var name: valueObject
  text: CONSTRUCT { ?valueObject a form:answer-origin . } WHERE { # precondition -- questions where not saved yet FILTER(! bound(?savedQAExists)) ?qOrigin a form:question-origin . # find concrete data ?qOrigin rdf:object ?i . # retrieve answer value ?i a e-m:instance . ?i e-m:has-value ?valueObject . }
  where: Filter
    expression: not
      arg1: bound
  where:
    object: question-origin
    predicate: type
    subject:
      var name: qOrigin
  where:
    object:
      var name: i
    predicate: object
    subject:
      var name: qOrigin
  where:
    object: instance
    predicate: type
    subject:
      var name: i
  where:
    object:
      var name: valueObject
    predicate: has-value
    subject:
      var name: i
replace: false

populate answers
type: ApplyConstruct
has-output-graph-constraint: Ask
  text: # there is an answer origin not connected to any question ASK WHERE { ?ao a form:answer-origin . FILTER NOT EXISTS { ?q doc:has_answer ?a . ?a form:has-answer-origin ?ao . } }
  where:
    object: answer-origin
    predicate: type
    subject:
      var name: ao
  where: Filter
    expression: notExists
      elements:
        predicate: has answer
      elements:
        predicate: has-answer-origin
  comment: there is an answer origin not connected to any question
has-output-graph-constraint: Ask
  text: # there is an answer to a question that has two data value ASK WHERE { ?a a doc:answer . ?a doc:has_data_value ?dataValue1 . ?a doc:has_data_value ?dataValue2 . FILTER(?dataValue1 != ?dataValue2) }
  where:
    object: answer
    predicate: type
    subject:
      var name: a
  where:
    object:
      var name: dataValue1
    predicate: has data value
    subject:
      var name: a
  where:
    object:
      var name: dataValue2
    predicate: has data value
    subject:
      var name: a
  where: Filter
    expression: ne
      arg1:
        var name: dataValue1
      arg2:
        var name: dataValue2
  comment: there is an answer to a question that has two data value
has-output-graph-constraint: Ask
  text: # there is an answer to a question that has two data value ASK WHERE { ?a a doc:answer . ?a doc:has_object_value ?objectValue1 . ?a doc:has_object_value ?objectValue2 . FILTER(?objectValue1 != ?objectValue2) }
  where:
    object: answer
    predicate: type
    subject:
      var name: a
  where:
    object:
      var name: objectValue1
    predicate: has object value
    subject:
      var name: a
  where:
    object:
      var name: objectValue2
    predicate: has object value
    subject:
      var name: a
  where: Filter
    expression: ne
      arg1:
        var name: objectValue1
      arg2:
        var name: objectValue2
  comment: there is an answer to a question that has two data value
next: form generator sink
construct query: Construct
  templates:
    object:
      var name: codeValue
    predicate: has object value
    subject:
      var name: a
  templates:
    object:
      var name: codeObject
    predicate: has-answer-origin
    subject:
      var name: a
  text: # 0 - populate code value answers CONSTRUCT { ?a doc:has_object_value ?codeValue . ?a form:has-answer-origin ?codeObject . } WHERE { # precondition -- questions where not saved yet FILTER(! bound(?savedQAExists)) # match question, answer instance ?a a doc:answer . ?q doc:has_answer ?a ; form:has-question-origin ?qOrigin . # find concrete data ?qOrigin rdf:object ?i . # retrieve answer value ?i a e-m:instance . ?i e-m:has-value ?codeObject . ?codeObject e-m:has-code-value ?codeValue . # attach metadata # TODO maybe elsewhere SERVICE ?eccairsSchemaServiceUri { ?codeValue rdfs:label ?codeLabel . OPTIONAL { ?codeValue e-m:has-explanation ?codeComment . } } }
  where: Filter
    expression: not
      arg1: bound
  where:
    object: answer
    predicate: type
    subject:
      var name: a
  where:
    object:
      var name: a
    predicate: has answer
    subject:
      var name: q
  where:
    object:
      var name: qOrigin
    predicate: has-question-origin
    subject:
      var name: q
  where:
    object:
      var name: i
    predicate: object
    subject:
      var name: qOrigin
  where:
    object: instance
    predicate: type
    subject:
      var name: i
  where:
    object:
      var name: codeObject
    predicate: has-value
    subject:
      var name: i
  where:
    object:
      var name: codeValue
    predicate: has-code-value
    subject:
      var name: codeObject
  where: Service
    elements:
      object:
        var name: codeLabel
      predicate: label
      subject:
        var name: codeValue
    elements: Optional
      elements:
        predicate: has-explanation
    service URI:
      var name: eccairsSchemaServiceUri
  comment: 0 - populate code value answers
construct query: Construct
  templates:
    object:
      var name: textValue
    predicate: has data value
    subject:
      var name: a
  templates:
    object:
      var name: textObject
    predicate: has-answer-origin
    subject:
      var name: a
  text: # 1 - populate text value answers CONSTRUCT { ?a doc:has_data_value ?textValue . ?a form:has-answer-origin ?textObject . } WHERE { # precondition -- questions where not saved yet FILTER(! bound(?savedQAExists)) # match question, answer instance ?a a doc:answer . ?q doc:has_answer ?a ; form:has-question-origin ?qOrigin . # find concrete data ?qOrigin rdf:object ?i . # retrieve answer value ?i a e-m:instance . ?i e-m:has-value ?textObject . ?textObject e-m:has-text-value ?textValue . }
  where: Filter
    expression: not
      arg1: bound
  where:
    object: answer
    predicate: type
    subject:
      var name: a
  where:
    object:
      var name: a
    predicate: has answer
    subject:
      var name: q
  where:
    object:
      var name: qOrigin
    predicate: has-question-origin
    subject:
      var name: q
  where:
    object:
      var name: i
    predicate: object
    subject:
      var name: qOrigin
  where:
    object: instance
    predicate: type
    subject:
      var name: i
  where:
    object:
      var name: textObject
    predicate: has-value
    subject:
      var name: i
  where:
    object:
      var name: textValue
    predicate: has-text-value
    subject:
      var name: textObject
  comment: 1 - populate text value answers
replace: false

Construct imported questions
type: ApplyConstruct
next: Recover question template from origin
construct query: Construct
  templates:
    object: question
    predicate: type
    subject:
      var name: q
  templates:
    object:
      var name: qOrigin
    predicate: has-question-origin
    subject:
      var name: q
  templates:
    object: imported-questions
    predicate: is-relevant-if
    subject:
      var name: q
  text: CONSTRUCT { ?q a doc:question ; form:has-question-origin ?qOrigin ; form:is-relevant-if "imported-questions" . } WHERE { # apply only if there are no saved questions FILTER(?savedQAExists = false) ?qOrigin a form:question-origin . BIND(form-ecc-lib:create-q(concat(str(?qOrigin), "-", ?executionId)) as ?q) # TODO ---- execution ID ? }
  where: Filter
    expression: eq
      arg1:
        var name: savedQAExists
      arg2: false
  where:
    object: question-origin
    predicate: type
    subject:
      var name: qOrigin
  where: Bind
    expression: create-q
      arg1: concat
        arg1: str
        arg2: -
    variable:
      var name: q

Construct question origins
type: ApplyConstruct
has-input-graph-constraint: Ask
  text: # 0 - ?rootEntity is not bound ASK WHERE { FILTER(! bound(?rootEntity)) }
  where: Filter
    expression: not
      arg1: bound
  comment: 0 - ?rootEntity is not bound
has-input-graph-constraint: Ask
  text: # 1 - there is no root e-m:instance of type ?rootEntity ASK WHERE { ?i a e-m:instance . FILTER NOT EXISTS { ?root_i a e-m:instance . ?root_i a ?rootEntity . } }
  where:
    object: instance
    predicate: type
    subject:
      var name: i
  where: Filter
    expression: notExists
      elements:
        object: instance
        predicate: type
      elements:
        predicate: type
  comment: 1 - there is no root e-m:instance of type ?rootEntity
has-input-graph-constraint: Ask
  text: # 2 - there is more than one root e-m:instance of type ?rootEntity ASK WHERE { ?root_i1 a ?rootEntity ; a e-m:instance . ?root_i1 a ?rootEntity ; a e-m:instance . FILTER(?root_i1 != ?root_i2) }
  where:
    object:
      var name: rootEntity
    predicate: type
    subject:
      var name: root_i1
  where:
    object: instance
    predicate: type
    subject:
      var name: root_i1
  where:
    object:
      var name: rootEntity
    predicate: type
    subject:
      var name: root_i1
  where:
    object: instance
    predicate: type
    subject:
      var name: root_i1
  where: Filter
    expression: ne
      arg1:
        var name: root_i1
      arg2:
        var name: root_i2
  comment: 2 - there is more than one root e-m:instance of type ?rootEntity
has-output-graph-constraint: Ask
  text: # 0 - there is some eccairs attribute or entity not associated with question origin ASK WHERE { ?o e-m:has-child-instance|^e-m:has-child-instance ?connectedObject . FILTER NOT EXISTS { ?questionOrigin a form:question-origin ; rdf:object ?o . } }
  where: TriplePath
    object:
      var name: connectedObject
    path: AltPath
      path1: has-child-instance
      path2: ReversePath
        sub path: has-child-instance
    subject:
      var name: o
  where: Filter
    expression: notExists
      elements:
        object: question-origin
        predicate: type
      elements:
        predicate: object
  comment: 0 - there is some eccairs attribute or entity not associated with question origin
has-output-graph-constraint: Ask
  text: # 1 - there is a question origin refering to multiple subjects of a relation ASK WHERE { ?questionOrigin a form:question-origin ; rdf:subject ?s1 ; rdf:subject ?s2 . FILTER(?s1 != ?s2) }
  where:
    object: question-origin
    predicate: type
    subject:
      var name: questionOrigin
  where:
    object:
      var name: s1
    predicate: subject
    subject:
      var name: questionOrigin
  where:
    object:
      var name: s2
    predicate: subject
    subject:
      var name: questionOrigin
  where: Filter
    expression: ne
      arg1:
        var name: s1
      arg2:
        var name: s2
  comment: 1 - there is a question origin refering to multiple subjects of a relation
has-output-graph-constraint: Ask
  text: #2 - there is a question origin refering to multiple objects of a relation ASK WHERE { ?questionOrigin a form:question-origin ; rdf:object ?o1 ; rdf:object ?o2 . FILTER(?o1 != ?o2) }
  where:
    object: question-origin
    predicate: type
    subject:
      var name: questionOrigin
  where:
    object:
      var name: o1
    predicate: object
    subject:
      var name: questionOrigin
  where:
    object:
      var name: o2
    predicate: object
    subject:
      var name: questionOrigin
  where: Filter
    expression: ne
      arg1:
        var name: o1
      arg2:
        var name: o2
  comment: 2 - there is a question origin refering to multiple objects of a relation
next: construct-answer-origins
next: assign-question-origins-to-templates
construct query: Construct
  templates:
    object: question-origin
    predicate: type
    subject:
      var name: r_so
  templates:
    object: Statement
    predicate: type
    subject:
      var name: r_so
  templates:
    object:
      var name: s
    predicate: subject
    subject:
      var name: r_so
  templates:
    object: has-child-instance
    predicate: predicate
    subject:
      var name: r_so
  templates:
    object:
      var name: o
    predicate: object
    subject:
      var name: r_so
  templates:
    object:
      var name: o_type
    predicate: type
    subject:
      var name: o
  text: # 0 - create imported question origins CONSTRUCT { ?r_so a form:question-origin ; a rdf:Statement ; rdf:subject ?s ; rdf:predicate e-m:has-child-instance ; rdf:object ?o . ?o a ?o_type . } WHERE { # origins are accessible from form root ?rootO a ?rootEntity ; e-m:has-child-instance* ?o . ?o a e-m:instance . OPTIONAL { ?s e-m:has-child-instance ?o . } # add type ?o a ?o_type . FILTER(?o_type != e-m:instance) BIND(COALESCE(concat("-", md5(str(?s))),"") as ?subjectHash) BIND(form-ecc-lib:create-qo(concat(str(?o), ?subjectHash)) as ?r_so) . # label for debugging BIND(?s as ?boundS) OPTIONAL { ?boundS rdfs:label ?sLabel . } }
  where:
    object:
      var name: rootEntity
    predicate: type
    subject:
      var name: rootO
  where: TriplePath
    object:
      var name: o
    path: ModPath
      mod max: -2
      mod min: 0
      sub path: has-child-instance
    subject:
      var name: rootO
  where:
    object: instance
    predicate: type
    subject:
      var name: o
  where: Optional
    elements:
      object:
        var name: o
      predicate: has-child-instance
      subject:
        var name: s
  where:
    object:
      var name: o_type
    predicate: type
    subject:
      var name: o
  where: Filter
    expression: ne
      arg1:
        var name: o_type
      arg2: instance
  where: Bind
    expression: coalesce
      arg1: concat
        arg1: -
        arg2: md5
  comment: 0 - create imported question origins
replace: false

attach initial question
type: ApplyConstruct
has-input-graph-constraint: Ask
  text: # ?rootEntity is not bound ASK WHERE { FILTER(! bound(?rootEntity)) }
  where: Filter
    expression: not
      arg1: bound
  comment: ?rootEntity is not bound
has-output-graph-constraint: Ask
  text: # there is a question without specified question origin ASK WHERE { ?question a doc:question . FILTER NOT EXISTS { ?question form:has-question-origin ?origin . } . }
  where:
    object: question
    predicate: type
    subject:
      var name: question
  where: Filter
    expression: notExists
      elements:
        predicate: has-question-origin
  comment: there is a question without specified question origin
has-output-graph-constraint: Ask
  text: # there is a question without specified question template ASK WHERE { ?question a doc:question . FILTER NOT EXISTS { ?question form:has-template ?questionTemplate . } . }
  where:
    object: question
    predicate: type
    subject:
      var name: question
  where: Filter
    expression: notExists
      elements:
        predicate: has-template
  comment: there is a question without specified question template
next: attach imported questions
construct query: Construct
  templates:
    object: question
    predicate: type
    subject:
      var name: rootQ
  templates:
    object:
      var name: rootEntity
    predicate: has-origin-type
    subject:
      var name: rootQ
  templates:
    object:
      var name: rootOrigin
    predicate: has-question-origin
    subject:
      var name: rootQ
  templates:
    object:
      var name: rootQT
    predicate: has-template
    subject:
      var name: rootQ
  text: # 0 - construct ROOT question if not present CONSTRUCT { ?rootQ a doc:question ; form:has-origin-type ?rootEntity ; form:has-question-origin ?rootOrigin ; form:has-template ?rootQT . } WHERE { ?rootQT form:has-template-origin ?rootEntity . # do nothing if having root question FILTER NOT EXISTS { ?rootQNotBound form:has-template ?rootQT . } # assign new root question based on imported data OPTIONAL { ?importedOrigin form-ecc-gen-0.2:is-origin-of-question-template ?rootQT . } BIND(form-ecc-lib:create-q(concat(str(?importedOrigin))) as ?importedRootQ) #assign new root question based on root template BIND(form-ecc-lib:create-q(concat(str(?rootQT),"-", ?executionId)) as ?newRootQ) # bind new variables BIND(COALESCE(?importedRootQ, ?newRootQ) as ?rootQ) BIND(COALESCE(?importedOrigin, ?rootQT) as ?rootOrigin) }
  where:
    object:
      var name: rootEntity
    predicate: has-template-origin
    subject:
      var name: rootQT
  where: Filter
    expression: notExists
      elements:
        predicate: has-template
  where: Optional
    elements:
      object:
        var name: rootQT
      predicate: is-origin-of-question-template
      subject:
        var name: importedOrigin
  where: Bind
    expression: create-q
      arg1: concat
        arg1: str
    variable:
      var name: importedRootQ
  where: Bind
    expression: create-q
      arg1: concat
        arg1: str
        arg2: -
    variable:
      var name: newRootQ
  where: Bind
    expression: coalesce
      arg1:
        var name: importedRootQ
      arg2:
        var name: newRootQ
    variable:
      var name: rootQ
  where: Bind
    expression: coalesce
      arg1:
        var name: importedOrigin
      arg2:
        var name: rootQT
    variable:
      var name: rootOrigin
  comment: 0 - construct ROOT question if not present
replace: false

Construct simple question templates
type: ApplyConstruct
has-input-graph-constraint: Ask
  text: # there exists eccairs entity that does not have reification of its has-child relationship ASK WHERE { SERVICE ?eccairsSchemaServiceUri { ?s a e-m:entity . ?s e-m:has-child ?o . OPTIONAL { ?reification rdf:subject ?s ; rdf:predicate e-m:has-child ; rdf:object ?o . } FILTER(!bound(?reification)) } }
  where: Service
    elements:
      object: entity
      predicate: type
      subject:
        var name: s
    elements:
      object:
        var name: o
      predicate: has-child
      subject:
        var name: s
    elements: Optional
      elements:
        predicate: subject
      elements:
        object: has-child
        predicate: predicate
      elements:
        predicate: object
    elements: Filter
      expression: not
        arg1: bound
    service URI:
      var name: eccairsSchemaServiceUri
  comment: there exists eccairs entity that does not have reification of its has-child relationship
next: attach-eccairs-views
construct query: Construct
  templates:
    object: has-subtemplate
    predicate: predicate
    subject:
      var name: r_qt_relation
  templates:
    object:
      var name: o_qt
    predicate: object
    subject:
      var name: r_qt_relation
  text: # 0 - create root question templates CONSTRUCT { ?r_qt_relation rdf:predicate form:has-subtemplate ; rdf:object ?o_qt ; } WHERE { SERVICE ?eccairsSchemaServiceUri { ?o a e-m:entity . FILTER NOT EXISTS { ?notBoundParent e-m:has-child ?o . } } BIND(iri(concat(str(?o), "-qts-relation")) as ?r_qt_relation) BIND(form-ecc-lib:create-qt(?o) as ?o_qt) }
  where: Service
    elements:
      object: entity
      predicate: type
      subject:
        var name: o
    elements: Filter
      expression: notExists
    service URI:
      var name: eccairsSchemaServiceUri
  where: Bind
    expression: iri
      arg1: concat
        arg1: str
        arg2: -qts-relation
    variable:
      var name: r_qt_relation
  where: Bind
    expression: create-qt
      arg1:
        var name: o
    variable:
      var name: o_qt
  comment: 0 - create root question templates
construct query: Construct
  templates:
    object:
      var name: o_qt
    predicate: has-subtemplate
    subject:
      var name: s_qt
  templates:
    object:
      var name: s_qt
    predicate: subject
    subject:
      var name: r_qt_relation
  templates:
    object: has-subtemplate
    predicate: predicate
    subject:
      var name: r_qt_relation
  templates:
    object:
      var name: o_qt
    predicate: object
    subject:
      var name: r_qt_relation
  templates:
    object:
      var name: isLinkStr
    predicate: is-relevant-if
    subject:
      var name: r_qt_relation
  text: # 1 - create structure of question templates CONSTRUCT { ?s_qt form:has-subtemplate ?o_qt . ?r_qt_relation rdf:subject ?s_qt ; rdf:predicate form:has-subtemplate ; rdf:object ?o_qt ; form:is-relevant-if ?isLinkStr . } WHERE { SERVICE ?eccairsSchemaServiceUri { ?s a e-m:entity . ?s e-m:has-child ?o . ?reification rdf:subject ?s ; rdf:predicate e-m:has-child ; rdf:object ?o . OPTIONAL { ?reification e-m:is-link ?isLinkFlag . } } BIND(IF(?isLinkFlag = "1", "is-link", ?notBoundVariable) as ?isLinkStr) BIND(iri(concat(str(?reification), "-qts-relation")) as ?r_qt_relation) BIND(form-ecc-lib:create-qt(?s) as ?s_qt) BIND(form-ecc-lib:create-qt(?o) as ?o_qt) }
  where: Service
    elements:
      object: entity
      predicate: type
      subject:
        var name: s
    elements:
      object:
        var name: o
      predicate: has-child
      subject:
        var name: s
    elements:
      object:
        var name: s
      predicate: subject
      subject:
        var name: reification
    elements:
      object: has-child
      predicate: predicate
      subject:
        var name: reification
    elements:
      object:
        var name: o
      predicate: object
      subject:
        var name: reification
    elements: Optional
      elements:
        predicate: is-link
    service URI:
      var name: eccairsSchemaServiceUri
  where: Bind
    expression: if
      arg1: eq
        arg2: 1
      arg2: is-link
      arg3:
        var name: notBoundVariable
    variable:
      var name: isLinkStr
  where: Bind
    expression: iri
      arg1: concat
        arg1: str
        arg2: -qts-relation
    variable:
      var name: r_qt_relation
  where: Bind
    expression: create-qt
      arg1:
        var name: s
    variable:
      var name: s_qt
  where: Bind
    expression: create-qt
      arg1:
        var name: o
    variable:
      var name: o_qt
  comment: 1 - create structure of question templates
construct query: Construct
  templates:
    object:
      var name: type
    predicate: type
    subject:
      var name: s
  templates:
    object:
      var name: s
    predicate: has-template-origin
    subject:
      var name: s_qt
  templates:
    object:
      var name: type
    predicate: has-origin-type
    subject:
      var name: s_qt
  templates:
    object: question-template
    predicate: type
    subject:
      var name: s_qt
  templates:
    object:
      var name: sLabel
    predicate: label
    subject:
      var name: s_qt
  templates:
    object:
      var name: sDescription
    predicate: comment
    subject:
      var name: s_qt
  text: # 2 - attach info to each question template CONSTRUCT { ?s a ?type . ?s_qt form:has-template-origin ?s . ?s_qt form:has-origin-type ?type . ?s_qt a form:question-template . ?s_qt rdfs:label ?sLabel . ?s_qt rdfs:comment ?sDescription . } WHERE { SERVICE ?eccairsSchemaServiceUri { ?s a ?type . ?s rdfs:label ?sLabel . ?s e-m:has-explanation ?sDescription . FILTER(?type in (e-m:entity, e-m:attribute)) } BIND(form-ecc-lib:create-qt(?s) as ?s_qt) }
  where: Service
    elements:
      object:
        var name: type
      predicate: type
    elements: Filter
  where: Bind
  comment: 2 - attach info to each question template
replace: true

Attach event-type questions from templates
type: ApplyConstruct
has-max-iteration-count: 10
has-output-graph-constraint: Ask
  text: # question for a question template matched by eventTypeMatcher not found ASK WHERE { ?childQT form:is-relevant-if ?eventTypeMatcher . FILTER NOT EXISTS { ?q form:has-template ?childQT . } }
  where:
    object:
      var name: eventTypeMatcher
    predicate: is-relevant-if
    subject:
      var name: childQT
  where: Filter
    expression: notExists
      elements:
        predicate: has-template
  comment: question for a question template matched by eventTypeMatcher not found
has-output-graph-constraint: Ask
  text: # there is a question with two parent questions w.r.t. has_related_question relation ASK WHERE { ?parentQ1 doc:has_related_question ?childQ . ?parentQ2 doc:has_related_question ?childQ . FILTER(?parentQ1 != ?parentQ2) }
  where:
    object:
      var name: childQ
    predicate: has related question
    subject:
      var name: parentQ1
  where:
    object:
      var name: childQ
    predicate: has related question
    subject:
      var name: parentQ2
  where: Filter
    expression: ne
      arg1:
        var name: parentQ1
      arg2:
        var name: parentQ2
  comment: there is a question with two parent questions w.r.t. has_related_question relation
next: attach-event-type-question-links
construct query: Construct
  templates:
    object: question
    predicate: type
    subject:
      var name: childQ
  templates:
    object:
      var name: childEntity
    predicate: has-origin-type
    subject:
      var name: childQ
  templates:
    object:
      var name: childOrigin
    predicate: has-question-origin
    subject:
      var name: childQ
  templates:
    object:
      var name: childQT
    predicate: has-template
    subject:
      var name: childQ
  templates:
    object: event-enhancement
    predicate: is-relevant-if
    subject:
      var name: childQ
  templates:
    object:
      var name: eventTypeMatcher
    predicate: is-relevant-if
    subject:
      var name: childQ
  templates:
    object:
      var name: childQ
    predicate: has related question
    subject:
      var name: parentQ
  templates:
    object:
      var name: childLabel
    predicate: altLabel
    subject:
      var name: childQ
  text: # 0 - construct next level of questions based on event type CONSTRUCT { # TODO (management issues) -- caching should be rather automatic and thus input must be "filter irrelevant questions" instead ?childQ a doc:question ; form:has-origin-type ?childEntity ; form:has-question-origin ?childOrigin ; form:has-template ?childQT ; form:is-relevant-if "event-enhancement" ; form:is-relevant-if ?eventTypeMatcher . ?parentQ doc:has_related_question ?childQ . # only for debugging ?childQ skos:altLabel ?childLabel . } WHERE { # bind templates that are relevant to eventType ?childQT form:is-relevant-if ?eventTypeMatcher . # find parent question to attach to ?parentQ a doc:question ; form:has-template ?parentQT . ?parentQT form:has-subtemplate ?childQT . ?childQT form:has-template-origin ?childEntity . # attach only if parentQ is not link ?parentQTRelation rdf:object ?parentQT . { ?grantParentQ doc:has_related_question ?parentQ ; form:has-template ?grandParentQT . ?parentQTRelation rdf:subject ?grandParentQT . FILTER NOT EXISTS { ?parentQTRelation form:is-relevant-if "is-link" . } } UNION { FILTER NOT EXISTS { ?grantParentQ doc:has_related_question ?parentQ . } } # bind new question BIND(md5(concat(str(?parentQ), str(?childQT), ?executionId)) as ?childId) BIND(form-ecc-lib:create-q(concat(str(?childQT),"-", ?childId)) as ?childQ) # bind child origin BIND(form-ecc-lib:create-qo(?childQT) as ?childOrigin) # create only if question does not exist already FILTER NOT EXISTS { ?parentQ doc:has_related_question ?childQNotBound . ?childQNotBound form:has-template ?childQT . } # only for debugging ?childQT rdfs:label ?childLabel . }
  where:
    object:
      var name: eventTypeMatcher
    predicate: is-relevant-if
    subject:
      var name: childQT
  where:
    object: question
    predicate: type
    subject:
      var name: parentQ
  where:
    object:
      var name: parentQT
    predicate: has-template
    subject:
      var name: parentQ
  where:
    object:
      var name: childQT
    predicate: has-subtemplate
    subject:
      var name: parentQT
  where:
    object:
      var name: childEntity
    predicate: has-template-origin
    subject:
      var name: childQT
  where:
    object:
      var name: parentQT
    predicate: object
    subject:
      var name: parentQTRelation
  where: Union
    elements:
      object:
        var name: parentQ
      predicate: has related question
      subject:
        var name: grantParentQ
    elements:
      object:
        var name: grandParentQT
      predicate: has-template
      subject:
        var name: grantParentQ
    elements:
      object:
        var name: grandParentQT
      predicate: subject
      subject:
        var name: parentQTRelation
    elements: Filter
      expression: notExists
    elements: Filter
      expression: notExists
  where: Bind
    expression: md5
      arg1: concat
        arg1: str
        arg2: str
    variable:
      var name: childId
  where: Bind
    expression: create-q
      arg1: concat
        arg1: str
        arg2: -
    variable:
      var name: childQ
  where: Bind
    expression: create-qo
      arg1:
        var name: childQT
    variable:
      var name: childOrigin
  where: Filter
    expression: notExists
      elements:
        predicate: has related question
      elements:
        predicate: has-template
  where:
    object:
      var name: childLabel
    predicate: label
    subject:
      var name: childQT
  comment: 0 - construct next level of questions based on event type
replace: false

construct-template-symlinks
type: ApplyConstruct
has-input-graph-constraint: Ask
  text: # 0 - there is a question-template without a label ASK WHERE { ?qt a form:question-template . OPTIONAL { ?qt rdfs:label ?label . } FILTER( !bound(?label)) }
  where:
    object: question-template
    predicate: type
    subject:
      var name: qt
  where: Optional
    elements:
      object:
        var name: label
      predicate: label
      subject:
        var name: qt
  where: Filter
    expression: not
      arg1: bound
  comment: 0 - there is a question-template without a label
has-input-graph-constraint: Ask
  text: # there are multiple levels of sections (NOT IMPLEMENTED) ASK WHERE { ?parent_section_qt form:has-subtemplate ?section_qt ; form:has-origin-type e-mv:section . ?section_qt form:has-subtemplate ?child_qt ; form:has-origin-type e-mv:section . }
  where:
    object:
      var name: section_qt
    predicate: has-subtemplate
    subject:
      var name: parent_section_qt
  where:
    object: section
    predicate: has-origin-type
    subject:
      var name: parent_section_qt
  where:
    object:
      var name: child_qt
    predicate: has-subtemplate
    subject:
      var name: section_qt
  where:
    object: section
    predicate: has-origin-type
    subject:
      var name: section_qt
  comment: there are multiple levels of sections (NOT IMPLEMENTED)
has-output-graph-constraint: Ask
  text: # 0 - there are two sections sharing same attribute but are not implementing symlinks ASK # TODO -- make it not eccairs specific, make it more generic w.r.t. multiple levels of sections WHERE { ?root_qt form:has-subtemplate ?section1_qt ; form:has-subtemplate ?section2_qt . FILTER(?section1_qt != ?section2_qt) ?section1_qt form:has-subtemplate ?child_qt ; form:has-origin-type e-mv:section . ?section2_qt form:has-subtemplate ?child_qt ; form:has-origin-type e-mv:section . ?r_1_qt_relation rdf:subject ?section1_qt ; rdf:predicate form:has-subtemplate ; rdf:object ?child_qt . ?r_2_qt_relation rdf:subject ?section1_qt ; rdf:predicate form:has-subtemplate ; rdf:object ?child_qt . OPTIONAL { ?r_1_qt_relation form:is-relevant-if ?isLink1 . } OPTIONAL { ?r_2_qt_relation form:is-relevant-if ?isLink2 . } FILTER(! ((?isLink1 = "is-link") || (?isLink2 = "is-link")) ) }
  where:
    object:
      var name: section1_qt
    predicate: has-subtemplate
    subject:
      var name: root_qt
  where:
    object:
      var name: section2_qt
    predicate: has-subtemplate
    subject:
      var name: root_qt
  where: Filter
    expression: ne
      arg1:
        var name: section1_qt
      arg2:
        var name: section2_qt
  where:
    object:
      var name: child_qt
    predicate: has-subtemplate
    subject:
      var name: section1_qt
  where:
    object: section
    predicate: has-origin-type
    subject:
      var name: section1_qt
  where:
    object:
      var name: child_qt
    predicate: has-subtemplate
    subject:
      var name: section2_qt
  where:
    object: section
    predicate: has-origin-type
    subject:
      var name: section2_qt
  where:
    object:
      var name: section1_qt
    predicate: subject
    subject:
      var name: r_1_qt_relation
  where:
    object: has-subtemplate
    predicate: predicate
    subject:
      var name: r_1_qt_relation
  where:
    object:
      var name: child_qt
    predicate: object
    subject:
      var name: r_1_qt_relation
  where:
    object:
      var name: section1_qt
    predicate: subject
    subject:
      var name: r_2_qt_relation
  where:
    object: has-subtemplate
    predicate: predicate
    subject:
      var name: r_2_qt_relation
  where:
    object:
      var name: child_qt
    predicate: object
    subject:
      var name: r_2_qt_relation
  where: Optional
    elements:
      object:
        var name: isLink1
      predicate: is-relevant-if
      subject:
        var name: r_1_qt_relation
  where: Optional
    elements:
      object:
        var name: isLink2
      predicate: is-relevant-if
      subject:
        var name: r_2_qt_relation
  where: Filter
    expression: not
      arg1: or
        arg1: eq
        arg2: eq
  comment: 0 - there are two sections sharing same attribute but are not implementing symlinks
has-output-graph-constraint: Ask
  text: # 1 - there is symlink that does not have hardlink associated ASK WHERE { ?parent_qt form:has-subtemplate ?child_qt . ?r_symlink_qt_relation rdf:subject ?parent_qt ; rdf:predicate form:has-subtemplate ; rdf:object ?child_qt ; form:is-relevant-if "is-link" . FILTER NOT EXISTS { ?r_symlink_qt_relation form:is-link-template-of ?r_hardlink_qt_relation . } }
  where:
    object:
      var name: child_qt
    predicate: has-subtemplate
    subject:
      var name: parent_qt
  where:
    object:
      var name: parent_qt
    predicate: subject
    subject:
      var name: r_symlink_qt_relation
  where:
    object: has-subtemplate
    predicate: predicate
    subject:
      var name: r_symlink_qt_relation
  where:
    object:
      var name: child_qt
    predicate: object
    subject:
      var name: r_symlink_qt_relation
  where:
    object: is-link
    predicate: is-relevant-if
    subject:
      var name: r_symlink_qt_relation
  where: Filter
    expression: notExists
      elements:
        predicate: is-link-template-of
  comment: 1 - there is symlink that does not have hardlink associated
has-output-graph-constraint: Ask
  text: # 2 - there is more than one hardlink for some eccairs template question relation (eccairs specific constraint) ASK WHERE { ?r_symlink_qt_relation form:is-link-template-of ?r_hardlink_qt_relation1 ; form:is-link-template-of ?r_hardlink_qt_relation2 . FILTER(?r_hardlink_qt_relation1 != ?r_hardlink_qt_relation2) }
  where:
    object:
      var name: r_hardlink_qt_relation1
    predicate: is-link-template-of
    subject:
      var name: r_symlink_qt_relation
  where:
    object:
      var name: r_hardlink_qt_relation2
    predicate: is-link-template-of
    subject:
      var name: r_symlink_qt_relation
  where: Filter
    expression: ne
      arg1:
        var name: r_hardlink_qt_relation1
      arg2:
        var name: r_hardlink_qt_relation2
  comment: 2 - there is more than one hardlink for some eccairs template question relation (eccairs specific constraint)
has-output-graph-constraint: Ask
  text: # 3 - there is a question tempate relation that act as hardlink and symlink at the same time ASK WHERE { ?r_symlink_qt_relation form:is-link-template-of ?r_bad_qt_relation . ?r_bad_qt_relation form:is-link-template-of ?r_hardlink_qt_relation. }
  where:
    object:
      var name: r_bad_qt_relation
    predicate: is-link-template-of
  comment: 3 - there is a question tempate relation that act as hardlink and symlink at the same time
next: Filter template-set shape
construct query: Construct
replace: false

Named graph id imported data
type: DatatypeProperty
comment: Context that contains original data from email importer that contains 2 types of data -- eccairs schema compliant and aviation ontology compliant data. Aviation ontology compliant data might be possibly reduced (moved to default graph of RT).
range: string

deploy-question-templates
type: deploy
p-is-replace: true
p-sesame-context-iri: http://onto.fel.cvut.cz/ontologies/forms/eccairs/question-templates
p-sesame-repository-name: form-generator
p-sesame-server-url: http://dev.inbas.cz/rdf4j-server

disable-question-clones
type: ApplyConstruct
next: Filter irrelevant
construct query: Construct
  templates:
    object: true
    predicate: is-disabled
    subject:
      var name: q
  text: CONSTRUCT { ?q form-lt:is-disabled true . } WHERE { ?q form:is-clone-of-question ?clonedQ . }
  where:
    object:
      var name: clonedQ
    predicate: is-clone-of-question
    subject:
      var name: q
replace: false

Event
type: DatatypeProperty
range: string

Event type
type: DatatypeProperty
range: string

Extract concrete report
type: ApplyConstruct
has-output-graph-constraint: Ask
  text: # there is a question with two parents ASK WHERE { ?parentQ1 doc:has_related_question ?q . ?parentQ2 doc:has_related_question ?q . FILTER(?parentQ1 != ?parentQ2) }
  where:
    object:
      var name: q
    predicate: has related question
    subject:
      var name: parentQ1
  where:
    object:
      var name: q
    predicate: has related question
    subject:
      var name: parentQ2
  where: Filter
    expression: ne
      arg1:
        var name: parentQ1
      arg2:
        var name: parentQ2
  comment: there is a question with two parents
next: bind-report-key
next: filter relevant form [rt]
construct query: Construct
  templates:
    object:
      var name: o
    predicate:
      var name: p
    subject:
      var name: s
  text: CONSTRUCT { ?s ?p ?o . } WHERE { SERVICE ?concreteReportServiceUri { ?s ?p ?o . } }
  where: Service
    elements:
      object:
        var name: o
      predicate:
        var name: p
      subject:
        var name: s
    service URI:
      var name: concreteReportServiceUri
replace: false

Extract eccairs schema
type: ApplyConstruct
next: Save eccairs schema
construct query: Construct
  templates:
    object:
      var name: o
    predicate:
      var name: p
    subject:
      var name: s
  text: CONSTRUCT { ?s ?p ?o . } WHERE { SERVICE ?eccairsSchemaServiceUri { ?s ?p ?o . } }
  where: Service
    elements:
      object:
        var name: o
      predicate:
        var name: p
      subject:
        var name: s
    service URI:
      var name: eccairsSchemaServiceUri
replace: true

Extract sample report
type: ApplyConstruct
next: Save sample report
construct query: Construct
  templates:
    object:
      var name: o
    predicate:
      var name: p
    subject:
      var name: s
  text: CONSTRUCT { ?s ?p ?o . } WHERE { SERVICE ?sampleReportServiceUri { ?s ?p ?o . } }
  where: Service
    elements:
      object:
        var name: o
      predicate:
        var name: p
      subject:
        var name: s
    service URI:
      var name: sampleReportServiceUri
replace: true

Extract imported report
type: ApplyConstruct
next: bind-existence-of-imported-report
construct query: Construct
  templates:
    object:
      var name: o
    predicate:
      var name: p
    subject:
      var name: s
  text: CONSTRUCT { ?s ?p ?o . } WHERE { SERVICE ?importedReportServiceUri { ?s ?p ?o . } }
  where: Service
    elements:
      object:
        var name: o
      predicate:
        var name: p
      subject:
        var name: s
    service URI:
      var name: importedReportServiceUri
replace: false

Filter template-set shape
type: ApplyConstruct
next: deploy-question-templates
next: !!! TMP question-template-merge
construct query: Construct
  templates:
    object:
      var name: o
    predicate:
      var name: p
    subject:
      var name: s
  text: # TODO -- include shape CONSTRUCT { ?s ?p ?o . } WHERE { ?s ?p ?o . }
  where:
    object:
      var name: o
    predicate:
      var name: p
    subject:
      var name: s
  comment: TODO -- include shape
replace: true

filter-for-qa-construction
type: ApplyConstruct
next: Construct question origins
construct query: Construct
  templates:
    object:
      var name: o
    predicate:
      var name: p
    subject:
      var name: s
  text: # filter only necessary data for q&a reconstruction CONSTRUCT { ?s ?p ?o . } WHERE { ?s ?p ?o . }
  where:
    object:
      var name: o
    predicate:
      var name: p
    subject:
      var name: s
  comment: filter only necessary data for q&a reconstruction
replace: true

Filter irrelevant
type: ApplyConstruct
next: merge-form-data
construct query: Construct
  templates:
    object:
      var name: o
    predicate:
      var name: p
    subject:
      var name: s
  text: CONSTRUCT { ?s ?p ?o . } WHERE { ?s ?p ?o . FILTER(?p != form:has-subtemplate) FILTER(?p != rdf:object) FILTER(?p != rdf:subject) FILTER(?p != rdf:predicate) FILTER(?p != form:is-relevant-if) }
  where:
    object:
      var name: o
    predicate:
      var name: p
    subject:
      var name: s
  where: Filter
    expression: ne
      arg1:
        var name: p
      arg2: has-subtemplate
  where: Filter
    expression: ne
      arg1:
        var name: p
      arg2: object
  where: Filter
    expression: ne
      arg1:
        var name: p
      arg2: subject
  where: Filter
    expression: ne
      arg1:
        var name: p
      arg2: predicate
  where: Filter
    expression: ne
      arg1:
        var name: p
      arg2: is-relevant-if
replace: true

Filter out irrelevant templates
type: ApplyConstruct
has-output-graph-constraint: Ask
  text: # there is a template for an attribute that is both in section and outside of it ASK # TODO make it not eccairs specific WHERE { ?entQT form:has-subtemplate ?attrQT ; form:has-subtemplate ?secQT . ?secQT form:has-subtemplate ?attrQT ; form:has-origin-type e-m-v:section . }
  where:
    object:
      var name: attrQT
    predicate: has-subtemplate
    subject:
      var name: entQT
  where:
    object:
      var name: secQT
    predicate: has-subtemplate
    subject:
      var name: entQT
  where:
    object:
      var name: attrQT
    predicate: has-subtemplate
    subject:
      var name: secQT
  where:
    object: section
    predicate: has-origin-type
    subject:
      var name: secQT
  comment: there is a template for an attribute that is both in section and outside of it
next: construct-template-symlinks
construct query: Construct
  templates:
    object:
      var name: o
    predicate:
      var name: p
    subject:
      var name: s
  text: # TODO put ?disabledContext -> VALUES CONSTRUCT { ?s ?p ?o . } WHERE { ?s ?p ?o . OPTIONAL { ?reification rdf:subject ?s ; rdf:predicate ?p ; rdf:object ?o ; form:is-relevant-if "eccairs-data-schema" . } FILTER(! bound(?reification)) }
  where:
    object:
      var name: o
    predicate:
      var name: p
    subject:
      var name: s
  where: Optional
    elements:
      object:
        var name: s
      predicate: subject
      subject:
        var name: reification
    elements:
      object:
        var name: p
      predicate: predicate
      subject:
        var name: reification
    elements:
      object:
        var name: o
      predicate: object
      subject:
        var name: reification
    elements:
      object: eccairs-data-schema
      predicate: is-relevant-if
      subject:
        var name: reification
  where: Filter
    expression: not
      arg1: bound
  comment: TODO put ?disabledContext -> VALUES
replace: true

filter-out-all
type: ApplyConstruct
next: filter-for-qa-construction
construct query: Construct
  text: # only path to propagate variables CONSTRUCT { } WHERE { }
  comment: only path to propagate variables

filter-populable-answers
type: ApplyConstruct
next: populate answers
construct query: Construct
  templates:
    object: answer
    predicate: type
    subject:
      var name: a
  templates:
    object:
      var name: a
    predicate: has answer
    subject:
      var name: q
  templates:
    object:
      var name: qOrigin
    predicate: has-question-origin
    subject:
      var name: q
  text: # filter only answers that should be populated from imported questions CONSTRUCT { ?a a doc:answer . ?q doc:has_answer ?a ; form:has-question-origin ?qOrigin . } WHERE { # precondition -- questions where not saved yet FILTER(! bound(?savedQAExists)) ?a a doc:answer . ?q doc:has_answer ?a ; form:has-question-origin ?qOrigin . # question is leaf node question FILTER NOT EXISTS { ?q doc:has_related_question ?childQ . } # question is not a clone FILTER NOT EXISTS { ?qOrigin form-ecc-gen-0.2:is-origin-of-question-templates-reification ?qTRelation . ?qTRelation form:is-relevant-if "is-link" . } }
  where: Filter
    expression: not
      arg1: bound
  where:
    object: answer
    predicate: type
    subject:
      var name: a
  where:
    object:
      var name: a
    predicate: has answer
    subject:
      var name: q
  where:
    object:
      var name: qOrigin
    predicate: has-question-origin
    subject:
      var name: q
  where: Filter
    expression: notExists
      elements:
        predicate: has related question
  where: Filter
    expression: notExists
      elements:
        predicate: is-origin-of-question-templates-reification
      elements:
        object: is-link
        predicate: is-relevant-if
  comment: filter only answers that should be populated from imported questions
replace: true

filter relevant form [rt]
type: ApplyConstruct
has-output-graph-constraint: Ask
  text: # there are two root questions ASK WHERE { ?root_q1 a doc:question . ?root_q2 a doc:question . FILTER(?root_q1 != ?root_q2) FILTER NOT EXISTS { ?notBoundq1 doc:has_related_question ?root_q1 . } FILTER NOT EXISTS { ?notBoundq2 doc:has_related_question ?root_q2 . } }
  where:
    object: question
    predicate: type
    subject:
      var name: root_q1
  where:
    object: question
    predicate: type
    subject:
      var name: root_q2
  where: Filter
    expression: ne
      arg1:
        var name: root_q1
      arg2:
        var name: root_q2
  where: Filter
    expression: notExists
      elements:
        predicate: has related question
  where: Filter
    expression: notExists
      elements:
        predicate: has related question
  comment: there are two root questions
has-output-graph-constraint: Ask
  text: # there is a question with two parents ASK WHERE { ?q a doc:question . ?parentQ1 doc:has_related_question ?q . ?parentQ2 doc:has_related_question ?q . FILTER(?parentQ1 != ?parentQ2) }
  where:
    object: question
    predicate: type
    subject:
      var name: q
  where:
    object:
      var name: q
    predicate: has related question
    subject:
      var name: parentQ1
  where:
    object:
      var name: q
    predicate: has related question
    subject:
      var name: parentQ2
  where: Filter
    expression: ne
      arg1:
        var name: parentQ1
      arg2:
        var name: parentQ2
  comment: there is a question with two parents
next: Bind if Q&A exists
node x: 4533
node y: 448
construct query: Construct
  templates:
    object:
      var name: o
    predicate:
      var name: p
    subject:
      var name: s
  text: # return only questions rooted by input eccairs event CONSTRUCT { ?s ?p ?o . } WHERE { ?event doc:has_related_question ?rootQ . ?rootQ (doc:has_related_question*|doc:has_answer*)* ?s . ?s ?p ?o . }
  where:
    object:
      var name: rootQ
    predicate: has related question
    subject:
      var name: event
  where: TriplePath
    object:
      var name: s
    path: ModPath
      mod max: -2
      mod min: 0
      sub path: AltPath
        path1: ModPath
        path2: ModPath
    subject:
      var name: rootQ
  where:
    object:
      var name: o
    predicate:
      var name: p
    subject:
      var name: s
  comment: return only questions rooted by input eccairs event
replace: true

form generator sink
type: ApplyConstruct
has-input-graph-constraint: Ask
  text: # there exists generated question but only loaded ones should be present ASK WHERE { FILTER NOT EXISTS { ?s a doc:question . FILTER(contains(str(?s), "http://onto.fel.cvut.cz/ontologies/eccairs/model/instance")) } FILTER(bound(?qaExists)) }
  where: Filter
    expression: notExists
      elements:
        object: question
        predicate: type
      elements: Filter
        expression: contains
  where: Filter
    expression: bound
      arg1:
        var name: qaExists
  comment: there exists generated question but only loaded ones should be present
has-input-graph-constraint: Ask
  text: # there is a question with two parents ASK WHERE { ?q a doc:question . ?parentQ1 doc:has_related_question ?q . ?parentQ2 doc:has_related_question ?q . FILTER(?parentQ1 != ?parentQ2) }
  where:
    object: question
    predicate: type
    subject:
      var name: q
  where:
    object:
      var name: q
    predicate: has related question
    subject:
      var name: parentQ1
  where:
    object:
      var name: q
    predicate: has related question
    subject:
      var name: parentQ2
  where: Filter
    expression: ne
      arg1:
        var name: parentQ1
      arg2:
        var name: parentQ2
  comment: there is a question with two parents
next: Bind root question
next: attach-initial-question-path
next: Attach possible values hook
next: Filter irrelevant
next: Construct questions info from templates
construct query: Construct
  templates:
    object:
      var name: o
    predicate:
      var name: p
    subject:
      var name: s
  text: CONSTRUCT { ?s ?p ?o . } WHERE { ?s ?p ?o . }
  where:
    object:
      var name: o
    predicate:
      var name: p
    subject:
      var name: s
replace: false

generateEccairsForms
type: Function
constraint: Argument
  default value: http://dev.inbas.cz/rdf4j-server/repositories/form-generator
  optional: false
  predicate: Repository url
  next: Bind concrete report service uri
  next: Bind imported report service uri
  next: question-templates-cache-service-uri
  comment: Repository url parameter
constraint: Argument
  default value: http://onto.fel.cvut.cz/ontologies/eccairs/aviation-3.4.0.2/vl-a-390/v-2180107
  optional: true
  predicate: Event type
  next: bind-event-type-matcher
  comment: Event type.
constraint: Argument
  default value: http://onto.fel.cvut.cz/ontologies/ufo/Event#instance-351263038
  optional: true
  predicate: Event
  value type: string
  next: bind-execution-id
  next: filter relevant form [rt]
  node x: 4477
  node y: 269
  comment: Event parameter
constraint: Argument
  default value: http://www.inbas.cz/ontologies/reporting-tool/formGen1471849823485
  optional: false
  predicate: Named graph id of a report
  next: Bind concrete report service uri
  comment: Named graph id of report parameter
constraint: Argument
  default value: http://www.inbas.cz/ontologies/reporting-tool/formGen1471849823487
  optional: false
  predicate: Named graph id imported data
  next: Bind imported report service uri
  comment: Named graph id of imported email parameter
constraint: Argument
  predicate: isIdempotent
  next: bind-execution-id
  node x: 3774
  node y: 460
  comment: If true, generation of form should be idempotent i.e. 2 runs of the generator on the same data should results in same result.
return module: generateEccairsForms Return
comment: Generate forms from occurrence category.
subclass of: Functions

has-context
type: Property

has question path
type: Property

has subquestion origin
type: Property

is-origin-of-question-template
type: Property

is-origin-of-question-templates-reification
type: Property

Layout form
type: ApplyConstruct
next: merge-form-data
construct query: Construct
  templates:
    object: form
    predicate: has-layout-class
    subject:
      var name: rootQuestion
  text: # 0 - create form layout question CONSTRUCT { ?rootQuestion form-lt:has-layout-class "form" . } WHERE { }
  comment: 0 - create form layout question
construct query: Construct
  templates:
    object: section
    predicate: has-layout-class
    subject:
      var name: sectionQuestion
  text: # 1 - create section layout classes CONSTRUCT { ?sectionQuestion form-lt:has-layout-class "section" . } WHERE { ?sectionQuestion doc:has_related_question ?subQuestion . FILTER(?rootQuestion != ?sectionQuestion) }
  where:
    object:
      var name: subQuestion
    predicate: has related question
    subject:
      var name: sectionQuestion
  where: Filter
    expression: ne
      arg1:
        var name: rootQuestion
      arg2:
        var name: sectionQuestion
  comment: 1 - create section layout classes
construct query: Construct
  templates:
    object: wizard-step
    predicate: has-layout-class
    subject:
      var name: topSectionQuestion
  templates:
    object: section
    predicate: has-layout-class
    subject:
      var name: topSectionQuestion
  text: # 2 - create wizard step layout for top level sections CONSTRUCT { ?topSectionQuestion form-lt:has-layout-class "wizard-step" . # TODO !!! remove asi ?? ?topSectionQuestion form-lt:has-layout-class "section" . } WHERE { ?rootQuestion doc:has_related_question ?topSectionQuestion . }
  where:
    object:
      var name: topSectionQuestion
    predicate: has related question
    subject:
      var name: rootQuestion
  comment: 2 - create wizard step layout for top level sections
replace: true

merge-form-data
type: Merge
has-input-graph-constraint: Ask
  text: # root question does not have any subquestions ASK WHERE { ?rootQuestion form-lt:has-layout-class "form" . FILTER NOT EXISTS { ?rootQuestion doc:has_related_question ?subQuestion . } }
  where:
    object: form
    predicate: has-layout-class
    subject:
      var name: rootQuestion
  where: Filter
    expression: notExists
      elements:
        predicate: has related question
  comment: root question does not have any subquestions
has-input-graph-constraint: Ask
  text: # there is a question with more than one answer ASK WHERE { ?q a doc:question ; doc:has_answer ?a1 ; doc:has_answer ?a2 . FILTER(?a1 != ?a2) }
  where:
    object: question
    predicate: type
    subject:
      var name: q
  where:
    object:
      var name: a1
    predicate: has answer
    subject:
      var name: q
  where:
    object:
      var name: a2
    predicate: has answer
    subject:
      var name: q
  where: Filter
    expression: ne
      arg1:
        var name: a1
      arg2:
        var name: a2
  comment: there is a question with more than one answer
has-input-graph-constraint: Ask
  text: # there is a question without a label ASK WHERE { ?question a doc:question . FILTER NOT EXISTS { ?question rdfs:label ?label . } }
  where:
    object: question
    predicate: type
    subject:
      var name: question
  where: Filter
    expression: notExists
      elements:
        predicate: label
  comment: there is a question without a label
has-input-graph-constraint: Ask
  text: # there is a question without specified question origin ASK WHERE { ?question a doc:question . FILTER NOT EXISTS { ?question form:has-question-origin ?origin . } }
  where:
    object: question
    predicate: type
    subject:
      var name: question
  where: Filter
    expression: notExists
      elements:
        predicate: has-question-origin
  comment: there is a question without specified question origin
has-input-graph-constraint: Ask
  text: # there is an empty section within the form ASK WHERE { ?sectionQ form-lt:has-layout-class "section" . FILTER NOT EXISTS { ?sectionQ doc:has_related_question ?subQ . } }
  where:
    object: section
    predicate: has-layout-class
    subject:
      var name: sectionQ
  where: Filter
    expression: notExists
      elements:
        predicate: has related question
  comment: there is an empty section within the form
has-input-graph-constraint: Ask
  text: # there is no "form" element ASK WHERE { FILTER NOT EXISTS { ?s form-lt:has-layout-class "form" . } }
  where: Filter
    expression: notExists
      elements:
        object: form
        predicate: has-layout-class
  comment: there is no "form" element
next: generateEccairsForms Return

operational-full-uri
type: BindWithConstant
next: bind-operational-full-service-uri
output variable: operationalFullUri
value: http://onto.fel.cvut.cz/ontologies/eccairs/aviation-3.4.0.2/views/operational-full

Construct questions info from templates
type: ApplyConstruct
next: attach question paths
next: merge-form-data
construct query: Construct
  templates:
    object:
      var name: qLabel
    predicate: label
    subject:
      var name: q
  templates:
    object:
      var name: qtComment
    predicate: comment
    subject:
      var name: q
  templates:
    object:
      var name: qtOrigin
    predicate: has-origin-type
    subject:
      var name: q
  text: # 1 - construct question info for links CONSTRUCT { ?q rdfs:label ?qLabel . ?q rdfs:comment ?qtComment . ?q form:has-origin-type ?qtOrigin . } WHERE { # bind link questions ?q form:has-template ?qt ; form:is-clone-of-question ?qCloned . ?qt rdfs:label ?qtLabel . ?qt form:has-template-origin ?qtOrigin . # TODO comment should be part of templates as well -> remove optional OPTIONAL { ?qt rdfs:comment ?qtComment . } # TODO !!!!!!! # BIND(concat("Link to '", ?qtLabel, "'") as ?qLabel) BIND(?qtLabel as ?qLabel) }
  where:
    object:
      var name: qt
    predicate: has-template
    subject:
      var name: q
  where:
    object:
      var name: qCloned
    predicate: is-clone-of-question
    subject:
      var name: q
  where:
    object:
      var name: qtLabel
    predicate: label
    subject:
      var name: qt
  where:
    object:
      var name: qtOrigin
    predicate: has-template-origin
    subject:
      var name: qt
  where: Optional
    elements:
      object:
        var name: qtComment
      predicate: comment
      subject:
        var name: qt
  where: Bind
    expression:
      var name: qtLabel
    variable:
      var name: qLabel
  comment: 1 - construct question info for links
construct query: Construct
  templates:
    object:
      var name: qtLabel
    predicate: label
    subject:
      var name: q
  templates:
    object:
      var name: qtComment
    predicate: comment
    subject:
      var name: q
  templates:
    object:
      var name: qtOrigin
    predicate: has-origin-type
    subject:
      var name: q
  text: # 0 - construct question info for normal questions CONSTRUCT { ?q rdfs:label ?qtLabel . ?q rdfs:comment ?qtComment . ?q form:has-origin-type ?qtOrigin . } WHERE { # bind qt template ?q form:has-template ?qt . ?qt rdfs:label ?qtLabel . ?qt form:has-template-origin ?qtOrigin . # TODO comment should be part of templates as well -> remove optional OPTIONAL { ?qt rdfs:comment ?qtComment . } FILTER NOT EXISTS { ?q form:is-clone-of-question ?qCloned . } }
  where:
    object:
      var name: qt
    predicate: has-template
    subject:
      var name: q
  where:
    object:
      var name: qtLabel
    predicate: label
    subject:
      var name: qt
  where:
    object:
      var name: qtOrigin
    predicate: has-template-origin
    subject:
      var name: qt
  where: Optional
    elements:
      object:
        var name: qtComment
      predicate: comment
      subject:
        var name: qt
  where: Filter
    expression: notExists
      elements:
        predicate: is-clone-of-question
  comment: 0 - construct question info for normal questions
replace: true

!!TMP Assign question possible values
type: ApplyConstruct
construct query: Construct
  templates:
    object:
      var name: value
    predicate: has-possible-value
    subject:
      var name: question
  templates:
    object:
      var name: label
    predicate: label
    subject:
      var name: value
  templates:
    object:
      var name: explanation
    predicate: comment
    subject:
      var name: value
  text: # TODO attach form generator to it CONSTRUCT { ?question form:has-possible-value ?value . ?value rdfs:label ?label . ?value rdfs:comment ?explanation . } WHERE { ?question a doc:question . ?question form:has-template ?questionTemplate . ?questionTemplate form:has-template-origin ?eccAttribute . SERVICE ?eccairsSchemaServiceUri { ?eccAttribute a e-m:attribute . ?eccAttribute e-m:has-child+ ?value . ?value rdfs:label ?label . ?value e-m:has-explanation ?explanation . # TODO remove !!!!!!!!!!! # FILTER(?eccAttribute = <http://onto.fel.cvut.cz/ontologies/eccairs/aviation-3.4.0.2/a-454>) } }
  where:
    object: question
    predicate: type
    subject:
      var name: question
  where:
    object:
      var name: questionTemplate
    predicate: has-template
    subject:
      var name: question
  where:
    object:
      var name: eccAttribute
    predicate: has-template-origin
    subject:
      var name: questionTemplate
  where: Service
    elements:
      object: attribute
      predicate: type
      subject:
        var name: eccAttribute
    elements: TriplePath
      object:
        var name: value
      path: ModPath
        mod max: -2
        mod min: 1
        sub path: has-child
      subject:
        var name: eccAttribute
    elements:
      object:
        var name: label
      predicate: label
      subject:
        var name: value
    elements:
      object:
        var name: explanation
      predicate: has-explanation
      subject:
        var name: value
    service URI:
      var name: eccairsSchemaServiceUri
  comment: TODO attach form generator to it
replace: true

!!! TMP question-template-merge
type: Merge

question-templates-cache-service-uri
type: BindWithConstant
next: Retrieve cached generated question templates
node x: 3135
node y: 195
output variable: questionTemplatesCacheServiceUri
value: create-sparql-service-url
  arg1:
    var name: repositoryUrl
  arg2:
    var name: questionTemplatesCacheUri

Recover question template from origin
type: ApplyConstruct
next: attach initial question
construct query: Construct
  templates:
    object:
      var name: qt
    predicate: has-template
    subject:
      var name: q
  text: # 1 - recover templates for questions created from input data CONSTRUCT { ?q form:has-template ?qt . } WHERE { ?q form:has-question-origin ?dataOrigin . ?dataOrigin form-ecc-gen-0.2:is-origin-of-question-template ?qt . }
  where:
    object:
      var name: dataOrigin
    predicate: has-question-origin
    subject:
      var name: q
  where:
    object:
      var name: qt
    predicate: is-origin-of-question-template
    subject:
      var name: dataOrigin
  comment: 1 - recover templates for questions created from input data
construct query: Construct
  templates:
    object:
      var name: qt
    predicate: has-template
    subject:
      var name: q
  text: # 2 - recover templates for questions created from directly templates (not input data) CONSTRUCT { ?q form:has-template ?qt . } WHERE { ?q form:has-question-origin ?templateOrigin . ?qt a form:question-template . # TODO not nice, not effective -- this should be rather pre-computed BIND(form-ecc-lib:create-qo(?qt) as ?qo) FILTER(?templateOrigin = ?qo) }
  where:
    object:
      var name: templateOrigin
    predicate: has-question-origin
    subject:
      var name: q
  where:
    object: question-template
    predicate: type
    subject:
      var name: qt
  where: Bind
    expression: create-qo
      arg1:
        var name: qt
    variable:
      var name: qo
  where: Filter
    expression: eq
      arg1:
        var name: templateOrigin
      arg2:
        var name: qo
  comment: 2 - recover templates for questions created from directly templates (not input data)
replace: false

assign-question-origins-to-templates
type: ApplyConstruct
has-output-graph-constraint: Ask
  text: # there is a question origin bound to two question template relations ASK WHERE { ?qo a form:question-origin ; form-ecc-gen-0.2:is-origin-of-question-templates-reification ?qtsReification1 ; form-ecc-gen-0.2:is-origin-of-question-templates-reification ?qtsReification2 . FILTER(?qtsReification1 != ?qtsReification2) }
  where:
    object: question-origin
    predicate: type
    subject:
      var name: qo
  where:
    object:
      var name: qtsReification1
    predicate: is-origin-of-question-templates-reification
    subject:
      var name: qo
  where:
    object:
      var name: qtsReification2
    predicate: is-origin-of-question-templates-reification
    subject:
      var name: qo
  where: Filter
    expression: ne
      arg1:
        var name: qtsReification1
      arg2:
        var name: qtsReification2
  comment: there is a question origin bound to two question template relations
has-output-graph-constraint: Ask
  text: # there is a question origin bound to two question templates ASK WHERE { ?qo a form:question-origin ; form-ecc-gen-0.2:is-origin-of-question-template ?oQT1 ; form-ecc-gen-0.2:is-origin-of-question-template ?oQT2 . FILTER(?oQT1 != ?oQT2) }
  where:
    object: question-origin
    predicate: type
    subject:
      var name: qo
  where:
    object:
      var name: oQT1
    predicate: is-origin-of-question-template
    subject:
      var name: qo
  where:
    object:
      var name: oQT2
    predicate: is-origin-of-question-template
    subject:
      var name: qo
  where: Filter
    expression: ne
      arg1:
        var name: oQT1
      arg2:
        var name: oQT2
  comment: there is a question origin bound to two question templates
has-output-graph-constraint: Ask
  text: # there is a question origin that is not bound to question template ASK WHERE { ?qo a form:question-origin . FILTER NOT EXISTS { ?qo form-ecc-gen-0.2:is-origin-of-question-template ?oQT . } }
  where:
    object: question-origin
    predicate: type
    subject:
      var name: qo
  where: Filter
    expression: notExists
      elements:
        predicate: is-origin-of-question-template
  comment: there is a question origin that is not bound to question template
has-output-graph-constraint: Ask
  text: # there is a question origin that is not bound to question template reification ASK WHERE { ?qo a form:question-origin . FILTER NOT EXISTS { ?qo form-ecc-gen-0.2:is-origin-of-question-templates-reification ?qtsReification . } }
  where:
    object: question-origin
    predicate: type
    subject:
      var name: qo
  where: Filter
    expression: notExists
      elements:
        predicate: is-origin-of-question-templates-reification
  comment: there is a question origin that is not bound to question template reification
next: Construct imported questions
construct query: Construct
  templates:
    object:
      var name: oQT
    predicate: is-origin-of-question-template
    subject:
      var name: qo
  templates:
    object:
      var name: qtsReification
    predicate: is-origin-of-question-templates-reification
    subject:
      var name: qo
  templates:
    object:
      var name: qoLabel
    predicate: label
    subject:
      var name: qo
  text: # construct question templates and its reifications relevant to origins CONSTRUCT { ?qo form-ecc-gen-0.2:is-origin-of-question-template ?oQT ; form-ecc-gen-0.2:is-origin-of-question-templates-reification ?qtsReification ; rdfs:label ?qoLabel . } WHERE { # bind question origin ?qo a form:question-origin ; rdf:object ?o . ?o a ?o_type . # bind template ?oQT form:has-template-origin ?oTOrigin . ?o a ?oTOrigin . # bind template reification ?qtsReification rdf:object ?oQT . OPTIONAL { ?qo rdf:subject ?s . } OPTIONAL { ?qtsReification rdf:subject ?sQT . ?sQT form:has-template-origin ?sTOrigin . ?s a ?sTOrigin . } FILTER( (bound(?s) && bound(?sQT)) || (!bound(?s) && !bound(?sQT))) # bind label for origin ?qtsReification rdfs:label ?qtsReificationLabel . BIND(concat("Origin of '", ?qtsReificationLabel, "'") as ?qoLabel) }
  where:
    object: question-origin
    predicate: type
    subject:
      var name: qo
  where:
    object:
      var name: o
    predicate: object
    subject:
      var name: qo
  where:
    object:
      var name: o_type
    predicate: type
    subject:
      var name: o
  where:
    object:
      var name: oTOrigin
    predicate: has-template-origin
    subject:
      var name: oQT
  where:
    object:
      var name: oTOrigin
    predicate: type
    subject:
      var name: o
  where:
    object:
      var name: oQT
    predicate: object
    subject:
      var name: qtsReification
  where: Optional
    elements:
      object:
        var name: s
      predicate: subject
      subject:
        var name: qo
  where: Optional
    elements:
      object:
        var name: sQT
      predicate: subject
      subject:
        var name: qtsReification
    elements:
      object:
        var name: sTOrigin
      predicate: has-template-origin
      subject:
        var name: sQT
    elements:
      object:
        var name: sTOrigin
      predicate: type
      subject:
        var name: s
  where: Filter
    expression: or
      arg1: and
        arg1: bound
        arg2: bound
      arg2: and
        arg1: not
        arg2: not
  where:
    object:
      var name: qtsReificationLabel
    predicate: label
    subject:
      var name: qtsReification
  where: Bind
    expression: concat
      arg1: Origin of '
      arg2:
        var name: qtsReificationLabel
      arg3: '
    variable:
      var name: qoLabel
  comment: construct question templates and its reifications relevant to origins

Named graph id of a report
type: DatatypeProperty
comment: Context with actual state of report that is saved by RT thus including saved Q&A model. Q&A data are empty here in case when report is opened for the first time in RT.
range: string

Repository url
type: DatatypeProperty
range: string

Retrieve cached generated question templates
type: ApplyConstruct
next: Attach attribute-based event-type filter to templates
next: Recover question template from origin
next: assign-question-origins-to-templates
construct query: Construct
  templates:
    object:
      var name: o
    predicate:
      var name: p
    subject:
      var name: s
  text: # CACHE -- instead of "filter irrelevant templates" CONSTRUCT { ?s ?p ?o . } WHERE { SERVICE ?questionTemplatesCacheServiceUri { ?s ?p ?o . } }
  where: Service
    elements:
      object:
        var name: o
      predicate:
        var name: p
      subject:
        var name: s
    service URI:
      var name: questionTemplatesCacheServiceUri
  comment: CACHE -- instead of "filter irrelevant templates"
replace: true

Resource
query: Construct
  templates:
    object:
      var name: o
    predicate:
      var name: p
    subject:
      var name: s
  text: #http://dev.inbas.cz/rdf4j-server/repositories/eccairs-aviation-3.4.0.2?query= CONSTRUCT { ?s ?p ?o . } WHERE { GRAPH <http://onto.fel.cvut.cz/ontologies/eccairs/aviation-3.4.0.2> { ?s ?p ?o . } . }
  where: NamedGraph
    elements:
      object:
        var name: o
      predicate:
        var name: p
      subject:
        var name: s
    graph name node: aviation-3.4.0.2
  comment: http://dev.inbas.cz/rdf4j-server/repositories/eccairs-aviation-3.4.0.2
comment: #SELECT ?eccTerm INSERT { graph <http://onto.fel.cvut.cz/ontologies/aviation/eccairs-form-generated> { ?formItem rdfs:label ?label ; rdfs:comment ?comment ; } } WHERE { GRAPH <http://onto.fel.cvut.cz/ontologies/aviation/eccairs-form-generated> { { ?formItem a form:section . ?formItem <http://onto.fel.cvut.cz/ontologies/form/origin> ?eccTerm . } UNION { ?formItem a form:question . ?formItem <http://onto.fel.cvut.cz/ontologies/form/origin> ?eccTerm . } } GRAPH <http://onto.fel.cvut.cz/ontologies/eccairs-3.4.0.2-v-2016-02-23> { ?eccTerm <http://onto.fel.cvut.cz/ontologies/eccairs/model/has-description> ?label. ?eccTerm <http://onto.fel.cvut.cz/ontologies/eccairs/model/has-explanation> ?comment. } }
comment: INSERT { GRAPH <http://onto.fel.cvut.cz/ontologies/aviation/eccairs-form-generated> { ?section form:has-question ?question . ?section a owl:NamedIndividual . ?question a owl:NamedIndividual . ?section a form:section . ?question a form:question . ?question <http://onto.fel.cvut.cz/ontologies/form/origin> ?attribute . ?section <http://onto.fel.cvut.cz/ontologies/form/origin> ?entity . } } WHERE { GRAPH <http://onto.fel.cvut.cz/ontologies/eccairs-3.4.0.2> { ?entity <http://onto.fel.cvut.cz/ontologies/eccairs/model/has-child> ?attribute . BIND("http://onto.fel.cvut.cz/ontologies/aviation/eccairs-form/" AS ?eccairsFormIRI) BIND( afn:localname(?entity) AS ?entityName) BIND(iri(concat(?eccairsFormIRI, ?entityName)) AS ?section) } GRAPH <http://onto.fel.cvut.cz/ontologies/aviation/mapping-ans-eccairs-events-and-attributes> { ?event <http://onto.fel.cvut.cz/ontologies/documentation/has_question> ?attribute . BIND("http://onto.fel.cvut.cz/ontologies/aviation/eccairs-form/" AS ?eccairsFormIRI) BIND( afn:localname(?attribute) AS ?attributeName) BIND(iri(concat(?eccairsFormIRI, ?attributeName)) AS ?question) } }

var name: rootQT

bound
arg1:
  var name: rootQT

var name: rootQuestion

var name: superQuestion

var name: superQuestion

var name: a

var name: q

var name: qPath

var name: a

var name: parent_qt

var name: r_qt_relation

var name: r_qt_relation

var name: child_qt

var name: r_qt_relation

var name: section_qt

var name: r_qt_relation

var name: r_qt_relation

var name: child_qt

var name: r_qt_relation

object:
  var name: section
predicate: has child
subject:
  var name: topic

object:
  var name: attr
predicate: allattributes
subject:
  var name: section

object:
  var name: sectionLabel
predicate: label
subject:
  var name: section

var name: operationalFullServiceUri

Bind
expression: md5
  arg1: concat
    arg1: str
      arg1:
        var name: r_qt_relation
    arg2: -
    arg3: str
      arg1:
        var name: section
variable:
  var name: r_new_qt_relation_id

Bind
expression: iri
  arg1: concat
    arg1: str
      arg1:
        var name: ent
    arg2: -
    arg3:
      var name: r_new_qt_relation_id
    arg4: -qts-relation
variable:
  var name: r_ent_sec_qt_relation

Bind
expression: iri
  arg1: concat
    arg1: str
      arg1:
        var name: section
    arg2: -
    arg3:
      var name: r_new_qt_relation_id
    arg4: -qts-relation
variable:
  var name: r_sec_attr_qt_relation

Bind
expression: create-qt
  arg1:
    var name: section
variable:
  var name: section_qt

Bind
expression: lower-case
  arg1: replace
    arg1:
      var name: sectionLabel
    arg2: _
variable:
  var name: sectionLabelFixed

var name: label

var name: qt

var name: questionTemplate

var name: question

var name: origin

var name: question

var name: savedQAExists

var name: questionOrigin

var name: q

var name: savedQAExists

var name: parentQTRelation

str
arg1:
  var name: childOrigin

var name: executionId

var name: secQ

object:
  var name: secQT
predicate: has-template
subject:
  var name: secQ

object: imported-question
predicate: is-relevant-if
subject:
  var name: secQ

object: section-question
predicate: is-relevant-if
subject:
  var name: secQ

object:
  var name: attrQ
predicate: has related question
subject:
  var name: secQ

object: question
predicate: type
subject:
  var name: attrQ

object:
  var name: attrOrigin
predicate: has-question-origin
subject:
  var name: attrQ

object:
  var name: attrQT
predicate: has-template
subject:
  var name: attrQ

object: imported-question
predicate: is-relevant-if
subject:
  var name: attrQ

object: part-of-view-question
predicate: is-relevant-if
subject:
  var name: attrQ

object:
  var name: isLinkFlag
predicate: is-relevant-if
subject:
  var name: attrQ

object:
  var name: secLabel
predicate: altLabel
subject:
  var name: secQ

object:
  var name: attrLabel
predicate: altLabel
subject:
  var name: attrQ

Filter
expression: not
  arg1: bound
    arg1:
      var name: savedQAExists

object: question
predicate: type
subject:
  var name: entQ

object:
  var name: entOrigin
predicate: has-question-origin
subject:
  var name: entQ

object:
  var name: entQT
predicate: has-template
subject:
  var name: entQ

object:
  var name: entQTRelation
predicate: is-origin-of-question-templates-reification
subject:
  var name: entOrigin

Filter
expression: notExists
  elements:
    object: is-link
    predicate: is-relevant-if
    subject:
      var name: entQTRelation

object:
  var name: attrQT
predicate: is-origin-of-question-template
subject:
  var name: attrOrigin

object:
  var name: entObject
predicate: subject
subject:
  var name: attrOrigin

object:
  var name: entObject
predicate: object
subject:
  var name: entOrigin

object:
  var name: secQT
predicate: has-subtemplate
subject:
  var name: entQT

object:
  var name: attrQT
predicate: has-subtemplate
subject:
  var name: secQT

object:
  var name: section
predicate: has-template-origin
subject:
  var name: secQT

object: section
predicate: has-origin-type
subject:
  var name: secQT

Bind
expression: md5
  arg1: concat
    arg1: str
      arg1:
        var name: entOrigin
    arg2: str
      arg1:
        var name: section
    arg3:
      var name: executionId
variable:
  var name: secId

Bind
expression: create-qo
  arg1:
    var name: secQT
variable:
  var name: secOrigin

Bind
expression: create-q
  arg1: concat
    arg1: str
      arg1:
        var name: section
    arg2: -
    arg3:
      var name: secId
variable:
  var name: secQ

Bind
expression: md5
  arg1: concat
    arg1: str
      arg1:
        var name: section
    arg2: str
      arg1:
        var name: attrOrigin
    arg3:
      var name: executionId
variable:
  var name: attrId

Bind
expression: create-q
  arg1: concat
    arg1: str
      arg1:
        var name: attrOrigin
    arg2: -
    arg3:
      var name: attrId
variable:
  var name: attrQ

object:
  var name: secLabel
predicate: label
subject:
  var name: secQT

object:
  var name: attrLabel
predicate: label
subject:
  var name: attrQT

var name: path

var name: q

var name: eccairsSchemaServiceUri

var name: eccAttribute

var name: qtLabel

var name: qtsRelationLabel

var name: eventTypeMatcher

var name: qt

var name: eventType

bound
arg1:
  var name: isIdempotent

ne
arg1: str
  arg1:
    var name: isIdempotent
arg2: true

str
arg1:
  var name: isIdempotent

var name: reportKey

var name: executionId

var name: isIdempotent

var name: event

var name: isIdempotentStr

concat
arg1: str
  arg1:
    var name: reportKey
arg2:
  var name: eventStr

var name: savedQAExists

var name: a

var name: q

var name: ao

var name: a

var name: savedQAExists

var name: codeComment

var name: codeValue

var name: savedQAExists

str
arg1:
  var name: qOrigin

var name: executionId

var name: rootEntity

var name: root_i

var name: rootEntity

var name: root_i

var name: questionOrigin

var name: o

var name: questionOrigin

md5
arg1: str
  arg1:
    var name: s

var name: subjectHash

Bind
expression: create-qo
  arg1: concat
    arg1: str
      arg1:
        var name: o
    arg2:
      var name: subjectHash
variable:
  var name: r_so

Bind
expression:
  var name: s
variable:
  var name: boundS

Optional
elements:
  object:
    var name: sLabel
  predicate: label
  subject:
    var name: boundS

var name: rootEntity

var name: origin

var name: question

var name: questionTemplate

var name: question

var name: rootQT

var name: rootQNotBound

str
arg1:
  var name: importedOrigin

str
arg1:
  var name: rootQT

var name: executionId

var name: s

var name: reification

var name: reification

var name: o

var name: reification

bound
arg1:
  var name: reification

object:
  var name: o
predicate: has-child
subject:
  var name: notBoundParent

str
arg1:
  var name: o

var name: isLinkFlag

var name: reification

var name: isLinkFlag

str
arg1:
  var name: reification

var name: s

object:
  var name: sLabel
predicate: label
subject:
  var name: s

object:
  var name: sDescription
predicate: has-explanation
subject:
  var name: s

Filter
expression: in
  arg1:
    var name: type
  arg2: entity
  arg3: attribute

var name: eccairsSchemaServiceUri

Bind
expression: create-qt
  arg1:
    var name: s
variable:
  var name: s_qt

var name: childQT

var name: q

object: is-link
predicate: is-relevant-if
subject:
  var name: parentQTRelation

object:
  var name: parentQ
predicate: has related question
subject:
  var name: grantParentQ

str
arg1:
  var name: parentQ

str
arg1:
  var name: childQT

var name: executionId

str
arg1:
  var name: childQT

var name: childId

var name: childQNotBound

var name: parentQ

var name: childQT

var name: childQNotBound

var name: label

eq
arg1:
  var name: isLink1
arg2: is-link

eq
arg1:
  var name: isLink2
arg2: is-link

var name: r_hardlink_qt_relation

var name: r_symlink_qt_relation

var name: r_symlink_qt_relation

object:
  var name: r_hardlink_qt_relation
predicate: is-link-template-of
subject:
  var name: r_bad_qt_relation

Construct
templates:
  object:
    var name: r_hardlink_qt_relation
  predicate: is-link-template-of
  subject:
    var name: r_symlink_qt_relation
text: # 0 - construct symlinks if explicitely stated CONSTRUCT { ?r_symlink_qt_relation form:is-link-template-of ?r_hardlink_qt_relation . } WHERE { ?parent1_qt form:has-subtemplate ?child_qt . ?parent2_qt form:has-subtemplate ?child_qt . ?r_symlink_qt_relation rdf:subject ?parent1_qt ; rdf:predicate form:has-subtemplate ; rdf:object ?child_qt ; form:is-relevant-if "is-link" . ?r_hardlink_qt_relation rdf:subject ?parent2_qt ; rdf:predicate form:has-subtemplate ; rdf:object ?child_qt . FILTER(?r_hardlink_qt_relation != ?r_symlink_qt_relation) FILTER NOT EXISTS { ?r_hardlink_qt_relation form:is-relevant-if "is-link" . } }
where:
  object:
    var name: child_qt
  predicate: has-subtemplate
  subject:
    var name: parent1_qt
where:
  object:
    var name: child_qt
  predicate: has-subtemplate
  subject:
    var name: parent2_qt
where:
  object:
    var name: parent1_qt
  predicate: subject
  subject:
    var name: r_symlink_qt_relation
where:
  object: has-subtemplate
  predicate: predicate
  subject:
    var name: r_symlink_qt_relation
where:
  object:
    var name: child_qt
  predicate: object
  subject:
    var name: r_symlink_qt_relation
where:
  object: is-link
  predicate: is-relevant-if
  subject:
    var name: r_symlink_qt_relation
where:
  object:
    var name: parent2_qt
  predicate: subject
  subject:
    var name: r_hardlink_qt_relation
where:
  object: has-subtemplate
  predicate: predicate
  subject:
    var name: r_hardlink_qt_relation
where:
  object:
    var name: child_qt
  predicate: object
  subject:
    var name: r_hardlink_qt_relation
where: Filter
  expression: ne
    arg1:
      var name: r_hardlink_qt_relation
    arg2:
      var name: r_symlink_qt_relation
where: Filter
  expression: notExists
    elements:
      object: is-link
      predicate: is-relevant-if
      subject:
        var name: r_hardlink_qt_relation
comment: 0 - construct symlinks if explicitely stated

Construct
templates:
  object:
    var name: r_hardlink_qt_relation
  predicate: is-link-template-of
  subject:
    var name: r_symlink_qt_relation
templates:
  object: is-link
  predicate: is-relevant-if
  subject:
    var name: r_symlink_qt_relation
text: # 1 - construct symlinks if sections are based on same eccairs entity and its attribute CONSTRUCT { # TODO -- make it not eccairs specific, make it work with more than one level of sections, make it work if more than two sections share same attribute ?r_symlink_qt_relation form:is-link-template-of ?r_hardlink_qt_relation ; form:is-relevant-if "is-link" . } WHERE { # pick relation that is minimal w.r.t. ordering of labels ?parent_qt form:has-subtemplate ?section1_qt . ?section1_qt form:has-subtemplate ?child_qt ; form:has-origin-type e-mv:section ; rdfs:label ?section1_label . ?r_hardlink_qt_relation rdf:subject ?section1_qt ; rdf:predicate form:has-subtemplate ; rdf:object ?child_qt . ## section1_label must be minimal w.r.t. ordering of question template labels FILTER NOT EXISTS { ?parent_qt form:has-subtemplate ?sectionNotBound_qt ; form:has-origin-type e-mv:section ; rdfs:label ?sectionNotBound_label . ?sectionNotBound_qt form:has-subtemplate ?child_qt . FILTER(?sectionNotBound_qt != ?section1_qt) FILTER(?sectionNotBound_label < ?section1_label) } # pick any other relation ?parent_qt form:has-subtemplate ?section2_qt . ?section2_qt form:has-subtemplate ?child_qt ; form:has-origin-type e-mv:section ; rdfs:label ?section2_label . ?r_symlink_qt_relation rdf:subject ?section2_qt ; rdf:predicate form:has-subtemplate ; rdf:object ?child_qt . FILTER(?section1_qt != ?section2_qt) FILTER(str(?section1_label) < str(?section2_label)) }
where:
  object:
    var name: section1_qt
  predicate: has-subtemplate
  subject:
    var name: parent_qt
where:
  object:
    var name: child_qt
  predicate: has-subtemplate
  subject:
    var name: section1_qt
where:
  object: section
  predicate: has-origin-type
  subject:
    var name: section1_qt
where:
  object:
    var name: section1_label
  predicate: label
  subject:
    var name: section1_qt
where:
  object:
    var name: section1_qt
  predicate: subject
  subject:
    var name: r_hardlink_qt_relation
where:
  object: has-subtemplate
  predicate: predicate
  subject:
    var name: r_hardlink_qt_relation
where:
  object:
    var name: child_qt
  predicate: object
  subject:
    var name: r_hardlink_qt_relation
where: Filter
  expression: notExists
    elements:
      object:
        var name: sectionNotBound_qt
      predicate: has-subtemplate
      subject:
        var name: parent_qt
    elements:
      object: section
      predicate: has-origin-type
      subject:
        var name: parent_qt
    elements:
      object:
        var name: sectionNotBound_label
      predicate: label
      subject:
        var name: parent_qt
    elements:
      object:
        var name: child_qt
      predicate: has-subtemplate
      subject:
        var name: sectionNotBound_qt
    elements: Filter
      expression: ne
    elements: Filter
      expression: lt
where:
  object:
    var name: section2_qt
  predicate: has-subtemplate
  subject:
    var name: parent_qt
where:
  object:
    var name: child_qt
  predicate: has-subtemplate
  subject:
    var name: section2_qt
where:
  object: section
  predicate: has-origin-type
  subject:
    var name: section2_qt
where:
  object:
    var name: section2_label
  predicate: label
  subject:
    var name: section2_qt
where:
  object:
    var name: section2_qt
  predicate: subject
  subject:
    var name: r_symlink_qt_relation
where:
  object: has-subtemplate
  predicate: predicate
  subject:
    var name: r_symlink_qt_relation
where:
  object:
    var name: child_qt
  predicate: object
  subject:
    var name: r_symlink_qt_relation
where: Filter
  expression: ne
    arg1:
      var name: section1_qt
    arg2:
      var name: section2_qt
where: Filter
  expression: lt
    arg1: str
      arg1:
        var name: section1_label
    arg2: str
      arg1:
        var name: section2_label
comment: 1 - construct symlinks if sections are based on same eccairs entity and its attribute

var name: sectionNotBound_qt

var name: section1_qt

var name: sectionNotBound_label

var name: section1_label

var name: reification

var name: savedQAExists

var name: childQ

var name: q

var name: qTRelation

var name: qOrigin

var name: qTRelation

var name: root_q1

var name: notBoundq1

var name: root_q2

var name: notBoundq2

ModPath
mod max: -2
mod min: 0
sub path: has related question

ModPath
mod max: -2
mod min: 0
sub path: has answer

var name: s

contains
arg1: str
  arg1:
    var name: s
arg2: http://onto.fel.cvut.cz/ontologies/eccairs/model/instance

var name: subQuestion

var name: rootQuestion

var name: label

var name: question

var name: origin

var name: question

var name: subQ

var name: sectionQ

var name: s

var name: qCloned

var name: q

var name: oQT

var name: qo

var name: qtsReification

var name: qo

bound
arg1:
  var name: s

bound
arg1:
  var name: sQT

not
arg1: bound
  arg1:
    var name: s

not
arg1: bound
  arg1:
    var name: sQT