@@ -0,0 +1,3122 @@
+package org.adaptlab.chpir.android.participanttracker.models;%0A%0Aimport org.adaptlab.chpir.android.activerecordcloudsync.ReceiveModel;%0Aimport org.json.JSONException;%0Aimport org.json.JSONObject;%0A%0Aimport com.activeandroid.annotation.Column;%0Aimport com.activeandroid.annotation.Table;%0Aimport com.activeandroid.query.Select;%0A%0Aimport android.util.Log;%0A%0A@Table(name = %22RelationshipType%22)%0Apublic class RelationshipType extends ReceiveModel %7B%0A    private static final String TAG = %22RelationshipType%22;%0A%0A    @Column(name = %22RemoteId%22, unique = true, onUniqueConflict = Column.ConflictAction.REPLACE)%0A    private Long mRemoteId;%0A    @Column(name = %22Label%22)%0A    private String mLabel;%0A    @Column(name = %22OwnerParticipantType%22)%0A    private ParticipantType mOwnerParticipantType;%0A    @Column(name = %22RelatedParticipantType%22)%0A    private ParticipantType mRelatedParticipantType;%0A%0A    public RelationshipType() %7B%0A        super();%0A    %7D%0A    %0A    @Override%0A    public void createObjectFromJSON(JSONObject jsonObject) %7B%0A        try %7B%0A            Long remoteId = jsonObject.getLong(%22id%22);%0A            RelationshipType relationshipType = RelationshipType.findByRemoteId(remoteId);%0A            if (relationshipType == null) %7B%0A                relationshipType = this;%0A            %7D%0A            %0A            Log.i(TAG, %22Creating object from JSON Object: %22 + jsonObject);%0A            relationshipType.setRemoteId(remoteId);%0A            relationshipType.setOwnerParticipantType(ParticipantType.findByRemoteId(jsonObject.getLong(%22participant_type_owner_id%22)));%0A            relationshipType.setRelatedParticipantType(ParticipantType.findByRemoteId(jsonObject.getLong(%22participant_type_related_id%22)));%0A            relationshipType.setLabel(jsonObject.getString(%22label%22));%0A            if (jsonObject.isNull(%22deleted_at%22)) %7B%0A                relationshipType.save();%0A            %7D else %7B%0A                RelationshipType rt = RelationshipType.findByRemoteId(remoteId);%0A                if (rt != null) %7B%0A                    rt.delete();%0A                %7D%0A            %7D%0A            %0A        %7D catch (JSONException je) %7B%0A            Log.e(TAG, %22Error parsing object json%22, je);%0A        %7D  %0A    %7D%0A    %0A    public static RelationshipType findByRemoteId(Long id) %7B%0A        return new Select().from(RelationshipType.class).where(%22RemoteId = ?%22, id).executeSingle();%0A    %7D%0A    %0A    %0A    public Long getRemoteId() %7B%0A        return mRemoteId;%0A    %7D%0A%0A    private void setRemoteId(Long remoteId) %7B%0A        mRemoteId = remoteId;%0A    %7D%0A%0A    public String getLabel() %7B%0A        return mLabel;%0A    %7D%0A%0A    private void setLabel(String label) %7B%0A        mLabel = label;%0A    %7D%0A%0A    public ParticipantType getOwnerParticipantType() %7B%0A        return mOwnerParticipantType;%0A    %7D%0A%0A    private void setOwnerParticipantType(ParticipantType ownerParticipantType) %7B%0A        mOwnerParticipantType = ownerParticipantType;%0A    %7D%0A%0A    public ParticipantType getRelatedParticipantType() %7B%0A        return mRelatedParticipantType;%0A    %7D%0A%0A    private void setRelatedParticipantType(ParticipantType relatedParticipantType) %7B%0A        mRelatedParticipantType = relatedParticipantType;%0A    %7D%0A%0A%7D%0A

Add relationship type model