@prefix ex: <http://example.org/>.
@prefix mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix sh: <http://www.w3.org/ns/shacl#>.
@prefix shn: <https://schemas.link/shacl-next#>.
@prefix sht: <http://www.w3.org/ns/shacl-test#>.

ex:APGARObservationShape a sh:NodeShape;
  sh:property ex:APGARObservationShape-related;
  sh:targetNode ex:Observation1.

ex:APGARObservationShape-related
  sh:path ex:related;
  sh:qualifiedMaxCount 3;
  sh:qualifiedMinCount 3;
  sh:qualifiedValueShape ex:APGARObservationShape-related-a.

ex:APGARObservationShape-related-a
  sh:property ex:APGARObservationShape-related-a-a.

ex:APGARObservationShape-related-a-a
  sh:path ex:related_target;
  sh:node ex:APGARObservationShape-related-a-a-a.

ex:APGARObservationShape-related-a-a-a
  sh:property ex:APGARObservationShape-related-a-a-a-a.

ex:APGARObservationShape-related-a-a-a-a
  sh:path ex:reference;
  sh:hasValue ex:something.

ex:Observation1 a ex:Observation;
  ex:related
    ex:Observation1a,
    ex:Observation1b,
    ex:Observation1c;
  sh:nodeShape ex:APGARObservationShape.

ex:Observation1a
  ex:related_target ex:Observation1a-a;
  ex:related_type "has-component"^^ex:code.

ex:Observation1a-a
  ex:reference ex:something.

ex:Observation1b
  ex:related_target ex:Observation1b-a;
  ex:related_type "has-component"^^ex:code.

ex:Observation1b-a
  ex:reference ex:something.

ex:Observation1c
  ex:related_target ex:Observation1c-a;
  ex:related_type "has-component"^^ex:code.

ex:Observation1c-a
  ex:reference ex:unrelated.

<> a mf:Manifest;
  mf:entries (<qualified-value-shape-details>).

<qualified-value-shape-details> a sht:Validate;
  rdfs:label "Test of sh:qualifiedValueShape with details";
  mf:action [
    sht:dataGraph <>;
    sht:shapesGraph <>
  ];
  mf:result [ a sh:ValidationReport;
    sh:conforms false;
    sh:result [ a sh:ValidationResult;
      sh:detail [ a sh:ValidationResult;
        sh:detail [ a sh:ValidationResult;
          sh:focusNode ex:Observation1b-a;
          sh:resultPath ex:reference;
          sh:resultSeverity shn:Debug;
          sh:sourceConstraintComponent sh:HasValueConstraintComponent;
          sh:sourceShape ex:APGARObservationShape-related-a-a-a-a;
          sh:value ex:Observation1b-a
        ];
        sh:focusNode ex:Observation1b;
        sh:resultPath ex:related_target;
        sh:resultSeverity shn:Debug;
        sh:sourceConstraintComponent sh:NodeConstraintComponent;
        sh:sourceShape ex:APGARObservationShape-related-a-a;
        sh:value ex:Observation1b-a
      ], [ a sh:ValidationResult;
        sh:detail [ a sh:ValidationResult;
          sh:focusNode ex:Observation1a-a;
          sh:resultPath ex:reference;
          sh:resultSeverity shn:Debug;
          sh:sourceConstraintComponent sh:HasValueConstraintComponent;
          sh:sourceShape ex:APGARObservationShape-related-a-a-a-a;
          sh:value ex:Observation1a-a
        ];
        sh:focusNode ex:Observation1a;
        sh:resultPath ex:related_target;
        sh:resultSeverity shn:Debug;
        sh:sourceConstraintComponent sh:NodeConstraintComponent;
        sh:sourceShape ex:APGARObservationShape-related-a-a;
        sh:value ex:Observation1a-a
      ], [ a sh:ValidationResult;
        sh:detail [ a sh:ValidationResult;
          sh:focusNode ex:Observation1c-a;
          sh:resultPath ex:reference;
          sh:resultSeverity sh:Violation;
          sh:sourceConstraintComponent sh:HasValueConstraintComponent;
          sh:sourceShape ex:APGARObservationShape-related-a-a-a-a;
          sh:value ex:Observation1c-a
        ];
        sh:focusNode ex:Observation1c;
        sh:resultPath ex:related_target;
        sh:resultSeverity sh:Violation;
        sh:sourceConstraintComponent sh:NodeConstraintComponent;
        sh:sourceShape ex:APGARObservationShape-related-a-a;
        sh:value ex:Observation1c-a
      ];
      sh:focusNode ex:Observation1;
      sh:resultPath ex:related;
      sh:resultSeverity sh:Violation;
      sh:sourceConstraintComponent sh:QualifiedMinCountConstraintComponent;
      sh:sourceShape ex:APGARObservationShape-related
    ], [ a sh:ValidationResult;
      sh:detail [ a sh:ValidationResult;
        sh:detail [ a sh:ValidationResult;
          sh:focusNode ex:Observation1a-a;
          sh:resultPath ex:reference;
          sh:resultSeverity shn:Debug;
          sh:sourceConstraintComponent sh:HasValueConstraintComponent;
          sh:sourceShape ex:APGARObservationShape-related-a-a-a-a;
          sh:value ex:Observation1a-a
        ];
        sh:focusNode ex:Observation1a;
        sh:resultPath ex:related_target;
        sh:resultSeverity shn:Debug;
        sh:sourceConstraintComponent sh:NodeConstraintComponent;
        sh:sourceShape ex:APGARObservationShape-related-a-a;
        sh:value ex:Observation1a-a
      ], [ a sh:ValidationResult;
        sh:detail [ a sh:ValidationResult;
          sh:focusNode ex:Observation1c-a;
          sh:resultPath ex:reference;
          sh:resultSeverity sh:Violation;
          sh:sourceConstraintComponent sh:HasValueConstraintComponent;
          sh:sourceShape ex:APGARObservationShape-related-a-a-a-a;
          sh:value ex:Observation1c-a
        ];
        sh:focusNode ex:Observation1c;
        sh:resultPath ex:related_target;
        sh:resultSeverity sh:Violation;
        sh:sourceConstraintComponent sh:NodeConstraintComponent;
        sh:sourceShape ex:APGARObservationShape-related-a-a;
        sh:value ex:Observation1c-a
      ], [ a sh:ValidationResult;
        sh:detail [ a sh:ValidationResult;
          sh:focusNode ex:Observation1b-a;
          sh:resultPath ex:reference;
          sh:resultSeverity shn:Debug;
          sh:sourceConstraintComponent sh:HasValueConstraintComponent;
          sh:sourceShape ex:APGARObservationShape-related-a-a-a-a;
          sh:value ex:Observation1b-a
        ];
        sh:focusNode ex:Observation1b;
        sh:resultPath ex:related_target;
        sh:resultSeverity shn:Debug;
        sh:sourceConstraintComponent sh:NodeConstraintComponent;
        sh:sourceShape ex:APGARObservationShape-related-a-a;
        sh:value ex:Observation1b-a
      ];
      sh:focusNode ex:Observation1;
      sh:resultPath ex:related;
      sh:resultSeverity shn:Debug;
      sh:sourceConstraintComponent sh:QualifiedMaxCountConstraintComponent;
      sh:sourceShape ex:APGARObservationShape-related
    ]
  ].
