/* * (non-Javadoc) * * @see ca.unb.cs.pcsf.db.DBAccessService#getParticipantById(java.lang.String) */ public Participant getParticipantById(String participantId) { logger.debug(LOGPRE + "getParticipantById() start" + LOGPRE); Participant participant = new Participant(); String selectRequest = "select * from `" + DOMAIN_PARTICIPANT + "`"; List<Item> items = this.getDataFromDomain(selectRequest); Item findItem = new Item(); if (!items.isEmpty()) { for (Item item : items) { if (item.getName().equals(participantId)) { findItem = item; break; } } } if (findItem != null) { participant.setId(findItem.getName()); for (Attribute attribute : findItem.getAttributes()) { if (attribute.getName().equals(PARTICIPANT_ATTRIBUTE_NAME)) participant.setName(attribute.getValue()); if (attribute.getName().equals(PARTICIPANT_ATTRIBUTE_EMAIL)) participant.setEmail(attribute.getValue()); if (attribute.getName().equals(PARTICIPANT_ATTRIBUTE_COLLABORATION_ID)) participant.setCollaborationId(attribute.getValue()); if (attribute.getName().equals(PARTICIPANT_ATTRIBUTE_IS_REG)) participant.setIsReg(attribute.getValue()); } } logger.debug(LOGPRE + "getParticipantById() end" + LOGPRE); return participant; }
public static void copyParticipantInfo(Participant src, Participant dest) { dest.setId(src.getId()); dest.setBirthDate(src.getBirthDate()); dest.setAge(src.getAge(null)); dest.setEducation(src.getEducation()); dest.setGroup(src.getGroup()); dest.setLanguage(src.getLanguage()); dest.setName(src.getName()); dest.setRole(src.getRole()); dest.setSES(src.getSES()); dest.setSex(src.getSex()); }
/** * Get a participant record from the data base by name and collaboration id. * * @param participantName * @param collaborationId * @return a participant */ private Participant getParticipantByNameAndCollaborationId( String participantName, String collaborationId) { logger.debug(LOGPRE + "getParticipantByNameAndCollaborationId() start" + LOGPRE); Participant participant = new Participant(); String selectRequest = "select * from `" + DOMAIN_PARTICIPANT + "` where " + PARTICIPANT_ATTRIBUTE_NAME + " = '" + participantName + "' AND " + PARTICIPANT_ATTRIBUTE_COLLABORATION_ID + "='" + collaborationId + "'"; List<Item> items = this.getDataFromDomain(selectRequest); if (items != null) { Item item = items.get(0); participant.setId(item.getName()); for (Attribute attribute : item.getAttributes()) { if (attribute.getName().equals(PARTICIPANT_ATTRIBUTE_NAME)) participant.setName(attribute.getValue()); if (attribute.getName().equals(PARTICIPANT_ATTRIBUTE_EMAIL)) participant.setEmail(attribute.getValue()); if (attribute.getName().equals(PARTICIPANT_ATTRIBUTE_COLLABORATION_ID)) participant.setCollaborationId(attribute.getValue()); if (attribute.getName().equals(PARTICIPANT_ATTRIBUTE_IS_REG)) participant.setIsReg(attribute.getValue()); } } logger.debug(LOGPRE + "getParticipantByNameAndCollaborationId() end" + LOGPRE); return participant; }
public Participant fromJaxb(psidev.psi.mi.xml254.jaxb.Participant jParticipant) throws ConverterException { if (jParticipant == null) { throw new IllegalArgumentException("You must give a non null JAXB Participant."); } checkDependencies(); Participant mParticipant = new Participant(); // Initialise the model reading the Jaxb object // 1. set attributes mParticipant.setId(jParticipant.getId()); // 2. set encapsulated objects // interactor/interaction Interactor mInteractor = null; Interaction mInteraction = null; boolean foundInteractor = false; if (jParticipant.getInteractorRef() != null) { foundInteractor = true; mInteractor = factory.getInteractorDAO().retreive(jParticipant.getInteractorRef()); if (mInteractor == null) { mParticipant.setInteractorRef(new InteractorRef(jParticipant.getInteractorRef())); } else { mParticipant.setInteractor(mInteractor); } } else if (jParticipant.getInteractor() != null) { foundInteractor = true; mInteractor = interactorConverter.fromJaxb(jParticipant.getInteractor()); mParticipant.setInteractor(mInteractor); } else if (jParticipant.getInteractionRef() != null) { foundInteractor = true; mInteraction = factory.getInteractionDAO().retreive(jParticipant.getInteractionRef()); if (mInteraction == null) { mParticipant.setInteractionRef(new InteractionRef(jParticipant.getInteractionRef())); } else { mParticipant.setInteraction(mInteraction); } } if (!foundInteractor) { throw new ConverterException( "Could not find either an interactor or an interaction for participant (id=" + jParticipant.getId() + ")."); } // BiologigicalRoles if (jParticipant.getBiologicalRole() != null) { mParticipant.setBiologicalRole( cvTypeConverter.fromJaxb(jParticipant.getBiologicalRole(), BiologicalRole.class)); } // Names if (jParticipant.getNames() != null) { mParticipant.setNames(namesConverter.fromJaxb(jParticipant.getNames())); } // Xrefs if (jParticipant.getXref() != null) { mParticipant.setXref(xrefConverter.fromJaxb(jParticipant.getXref())); } // ConfidenceList if (jParticipant.getConfidenceList() != null) { for (psidev.psi.mi.xml254.jaxb.Confidence jConfidence : jParticipant.getConfidenceList().getConfidences()) { mParticipant.getConfidenceList().add(confidenceConverter.fromJaxb(jConfidence)); } } // ExperimentalInteractor if (jParticipant.getExperimentalInteractorList() != null) { for (psidev.psi.mi.xml254.jaxb.ExperimentalInteractor jExperimentalInteractor : jParticipant.getExperimentalInteractorList().getExperimentalInteractors()) { mParticipant .getExperimentalInteractors() .add(experimentalInteractorConverter.fromJaxb(jExperimentalInteractor)); } } // ExperimentalPreparations if (jParticipant.getExperimentalPreparationList() != null) { for (psidev.psi.mi.xml254.jaxb.ExperimentalPreparation jExperimentalPreparation : jParticipant.getExperimentalPreparationList().getExperimentalPreparations()) { mParticipant .getExperimentalPreparations() .add(experimentalPreparationConverter.fromJaxb(jExperimentalPreparation)); } } // ExperimentalRoles if (jParticipant.getExperimentalRoleList() != null) { for (psidev.psi.mi.xml254.jaxb.ExperimentalRole jExperimentalRole : jParticipant.getExperimentalRoleList().getExperimentalRoles()) { mParticipant .getExperimentalRoles() .add(experimentalRoleConverter.fromJaxb(jExperimentalRole)); } } // Features if (jParticipant.getFeatureList() != null) { for (psidev.psi.mi.xml254.jaxb.Feature jFeature : jParticipant.getFeatureList().getFeatures()) { mParticipant.getFeatures().add(featureConverter.fromJaxb(jFeature)); } } // HostOrganisms if (jParticipant.getHostOrganismList() != null) { for (psidev.psi.mi.xml254.jaxb.HostOrganism jOrganism : jParticipant.getHostOrganismList().getHostOrganisms()) { mParticipant.getHostOrganisms().add(hostOrganismConverter.fromJaxb(jOrganism)); } } // Parameters // We handle interaction's and participant's parameters as they may be different JAXB Type. // psidev.psi.mi.xml254.jaxb.Parameter // psidev.psi.mi.xml254.jaxb.InteractionElementType.ParameterList.Parameter // TODO once the schema is fixed, revert to a single converter. if (jParticipant.getParameterList() != null) { for (psidev.psi.mi.xml254.jaxb.Parameter jParameter : jParticipant.getParameterList().getParameters()) { mParticipant.getParameters().add(parameterConverter.fromJaxb(jParameter)); } } // ParticipantIdentificationMethod if (jParticipant.getParticipantIdentificationMethodList() != null) { for (psidev.psi.mi.xml254.jaxb.ParticipantIdentificationMethod jParticipantIdentificationMethod : jParticipant .getParticipantIdentificationMethodList() .getParticipantIdentificationMethods()) { mParticipant .getParticipantIdentificationMethods() .add( participantIdentificationMethodConverter.fromJaxb( jParticipantIdentificationMethod)); } } // attributes if (jParticipant.getAttributeList() != null) { for (psidev.psi.mi.xml254.jaxb.Attribute attribute : jParticipant.getAttributeList().getAttributes()) { mParticipant.getAttributes().add(attributeConverter.fromJaxb(attribute)); } } // store the participant via DAO PsiDAO<Participant> participantDAO = factory.getParticipantDAO(); participantDAO.store(mParticipant); return mParticipant; }