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; }