use of org.hisp.dhis.smscompression.models.RelationshipSmsSubmission in project dhis2-core by dhis2.
the class RelationshipSMSListenerTest method createRelationshipSubmission.
private RelationshipSmsSubmission createRelationshipSubmission() {
RelationshipSmsSubmission subm = new RelationshipSmsSubmission();
subm.setUserId(user.getUid());
subm.setRelationshipType(relationshipType.getUid());
subm.setRelationship("uf3svrmpzOj");
subm.setFrom(programInstance.getUid());
subm.setTo(programInstance.getUid());
subm.setSubmissionId(1);
return subm;
}
use of org.hisp.dhis.smscompression.models.RelationshipSmsSubmission in project dhis2-core by dhis2.
the class RelationshipSMSListener method postProcess.
@Override
protected SmsResponse postProcess(IncomingSms sms, SmsSubmission submission) throws SMSProcessingException {
RelationshipSmsSubmission subm = (RelationshipSmsSubmission) submission;
Uid fromid = subm.getFrom();
Uid toid = subm.getTo();
Uid typeid = subm.getRelationshipType();
RelationshipType relType = relationshipTypeService.getRelationshipType(typeid.getUid());
if (relType == null) {
throw new SMSProcessingException(SmsResponse.INVALID_RELTYPE.set(typeid));
}
RelationshipItem fromItem = createRelationshipItem(relType, RelationshipDir.FROM, fromid);
RelationshipItem toItem = createRelationshipItem(relType, RelationshipDir.TO, toid);
Relationship rel = new Relationship();
// auto-generated
if (subm.getRelationship() != null) {
rel.setUid(subm.getRelationship().getUid());
}
rel.setRelationshipType(relType);
rel.setFrom(fromItem);
rel.setTo(toItem);
rel.setCreated(new Date());
rel.setLastUpdated(new Date());
// TODO: Are there values we need to account for in relationships?
relationshipService.addRelationship(rel);
return SmsResponse.SUCCESS;
}
Aggregations