use of org.hisp.dhis.relationship.RelationshipItem in project dhis2-core by dhis2.
the class RelationshipStoreTest method setUpTest.
@Override
public void setUpTest() {
relationshipType = createRelationshipType('A');
relationshipTypeService.addRelationshipType(relationshipType);
organisationUnit = createOrganisationUnit("testOU");
organisationUnitService.addOrganisationUnit(organisationUnit);
trackedEntityInstanceA = createTrackedEntityInstance(organisationUnit);
trackedEntityInstanceB = createTrackedEntityInstance(organisationUnit);
trackedEntityInstanceService.addTrackedEntityInstance(trackedEntityInstanceA);
trackedEntityInstanceService.addTrackedEntityInstance(trackedEntityInstanceB);
relationship = new Relationship();
RelationshipItem relationshipItemFrom = new RelationshipItem();
RelationshipItem relationshipItemTo = new RelationshipItem();
relationshipItemFrom.setTrackedEntityInstance(trackedEntityInstanceA);
relationshipItemTo.setTrackedEntityInstance(trackedEntityInstanceB);
relationship.setRelationshipType(relationshipType);
relationship.setFrom(relationshipItemFrom);
relationship.setTo(relationshipItemTo);
relationship.setKey(RelationshipUtils.generateRelationshipKey(relationship));
relationship.setInvertedKey(RelationshipUtils.generateRelationshipInvertedKey(relationship));
relationshipService.addRelationship(relationship);
}
use of org.hisp.dhis.relationship.RelationshipItem in project dhis2-core by dhis2.
the class DhisConvenienceTest method createTeiToTeiRelationship.
public static Relationship createTeiToTeiRelationship(TrackedEntityInstance from, TrackedEntityInstance to, RelationshipType relationshipType) {
Relationship relationship = new Relationship();
RelationshipItem _from = new RelationshipItem();
RelationshipItem _to = new RelationshipItem();
_from.setTrackedEntityInstance(from);
_to.setTrackedEntityInstance(to);
relationship.setRelationshipType(relationshipType);
relationship.setFrom(_from);
relationship.setTo(_to);
relationship.setKey(RelationshipUtils.generateRelationshipKey(relationship));
relationship.setInvertedKey(RelationshipUtils.generateRelationshipInvertedKey(relationship));
relationship.setAutoFields();
return relationship;
}
use of org.hisp.dhis.relationship.RelationshipItem in project dhis2-core by dhis2.
the class TrackerRelationshipsExportControllerTest method relationship.
private Relationship relationship(RelationshipType type, ProgramStageInstance from, TrackedEntityInstance to) {
Relationship r = new Relationship();
RelationshipItem rItem1 = new RelationshipItem();
rItem1.setProgramStageInstance(from);
RelationshipItem rItem2 = new RelationshipItem();
rItem2.setTrackedEntityInstance(to);
r.setFrom(rItem1);
r.setTo(rItem2);
r.setRelationshipType(type);
r.setKey(type.getUid());
r.setInvertedKey(type.getUid());
r.setAutoFields();
manager.save(r);
return r;
}
use of org.hisp.dhis.relationship.RelationshipItem in project dhis2-core by dhis2.
the class TrackerRelationshipsExportControllerTest method relationship.
private Relationship relationship(RelationshipType type, ProgramInstance from, TrackedEntityInstance to) {
Relationship r = new Relationship();
RelationshipItem rItem1 = new RelationshipItem();
rItem1.setProgramInstance(from);
RelationshipItem rItem2 = new RelationshipItem();
rItem2.setTrackedEntityInstance(to);
r.setFrom(rItem1);
r.setTo(rItem2);
r.setRelationshipType(type);
r.setKey(type.getUid());
r.setInvertedKey(type.getUid());
r.setAutoFields();
manager.save(r);
return r;
}
use of org.hisp.dhis.relationship.RelationshipItem in project dhis2-core by dhis2.
the class TrackerTest method persistRelationship.
public Relationship persistRelationship(TrackedEntityInstance tei, ProgramStageInstance psi) {
RelationshipItem from = new RelationshipItem();
from.setTrackedEntityInstance(tei);
RelationshipItem to = new RelationshipItem();
to.setProgramStageInstance(psi);
return _persistRelationship(from, to);
}
Aggregations