List of usage examples for org.apache.commons.collections15 OrderedMap put
V put(K key, V value);
From source file:org.isatools.isacreator.gui.formelements.SubForm.java
public Map<String, String> getRecord(int recordNumber) { OrderedMap<String, String> record = new ListOrderedMap<String, String>(); int index = 0; for (SubFormField field : fields) { Object value = defaultTableModel.getValueAt(index, recordNumber); String fieldName = field.getFieldName(); if (aliasesToRealNames.containsKey(field.getFieldName())) { fieldName = aliasesToRealNames.get(fieldName); }// www. j a va 2 s .co m record.put(fieldName, value == null ? "" : value.toString()); index++; } return record; }
From source file:org.isatools.isacreator.io.importisa.InvestigationImport.java
/** * imports the Investigation file into a Map data structure. * * @param investigationFile- File object representing Investigation file to be loaded. * @return Map is formatted like so:/*from w w w . j a v a 2s .c om*/ * (Main section name) e.g. Investigation-1 * -> Section name e.g. InvestigationFileSection e.g. InvestigationFileSection.ONTOLOGY_SECTION * -> Label for the ontology section e.g. Term Source Name * -> Values for the given section/label e.g. OBI * EFO * etc */ public Pair<Boolean, OrderedMap<String, OrderedMap<InvestigationFileSection, OrderedMap<String, List<String>>>>> importInvestigationFile( File investigationFile) throws IOException { OrderedMap<String, OrderedMap<InvestigationFileSection, OrderedMap<String, List<String>>>> importedInvestigationFile = new ListOrderedMap<String, OrderedMap<InvestigationFileSection, OrderedMap<String, List<String>>>>(); List<String[]> investigationFileContents = loadFile(investigationFile); String currentMajorSection = "Investigation-1"; int studyCount = 1; importedInvestigationFile.put(currentMajorSection, new ListOrderedMap<InvestigationFileSection, OrderedMap<String, List<String>>>()); InvestigationFileSection currentMinorSection = null; for (String[] line : investigationFileContents) { InvestigationFileSection tmpSection; if ((tmpSection = InvestigationFileSection.convertToInstance(line[0])) != null) { currentMinorSection = tmpSection; if (currentMinorSection == InvestigationFileSection.STUDY_SECTION) { currentMajorSection = "Study-" + studyCount; studyCount++; importedInvestigationFile.put(currentMajorSection, new ListOrderedMap<InvestigationFileSection, OrderedMap<String, List<String>>>()); } importedInvestigationFile.get(currentMajorSection).put(currentMinorSection, new ListOrderedMap<String, List<String>>()); } else { String lineLabel = line[0].trim(); if (!StringUtils.isEmpty(lineLabel)) { String valueToTitleCase = lineLabel; if (lineLabel.contains("Comment")) valueToTitleCase = StringProcessing.removeSpaceFromQualifiedField( StringProcessing.convertStringToTitleCase(lineLabel)); //System.out.println(valueToTitleCase); if (!importedInvestigationFile.get(currentMajorSection).get(currentMinorSection) .containsKey(valueToTitleCase)) { importedInvestigationFile.get(currentMajorSection).get(currentMinorSection) .put(valueToTitleCase, new ArrayList<String>()); } if (line.length > 1) { for (int index = 1; index < line.length; index++) { importedInvestigationFile.get(currentMajorSection).get(currentMinorSection) .get(valueToTitleCase).add(line[index]); } } } } } return new Pair<Boolean, OrderedMap<String, OrderedMap<InvestigationFileSection, OrderedMap<String, List<String>>>>>( isValidInvestigationSections(importedInvestigationFile), importedInvestigationFile); }
From source file:org.isatools.isacreator.io.importisa.StructureToInvestigationMapper.java
private Investigation processInvestigation( OrderedMap<InvestigationFileSection, OrderedMap<String, List<String>>> investigationSections) { Set<OntologySourceRefObject> ontologySources = new HashSet<OntologySourceRefObject>(); List<Contact> contacts = new ArrayList<Contact>(); List<Publication> publications = new ArrayList<Publication>(); Investigation tmpInvestigation = null; OrderedMap<InvestigationFileSection, Set<String>> sectionFields = new ListOrderedMap<InvestigationFileSection, Set<String>>(); for (InvestigationFileSection investigationSection : investigationSections.keySet()) { if (investigationSection == InvestigationFileSection.INVESTIGATION_SECTION) { Pair<Set<String>, Investigation> processedInvestigationSection = processInvestigationSection( investigationSections.get(investigationSection)); sectionFields.put(investigationSection, processedInvestigationSection.fst); tmpInvestigation = processedInvestigationSection.snd; } else if (investigationSection == InvestigationFileSection.ONTOLOGY_SECTION) { Pair<Set<String>, List<OntologySourceRefObject>> processedOntologySection = processOntologySourceReferences( investigationSections.get(investigationSection)); sectionFields.put(investigationSection, processedOntologySection.fst); ontologySources = new HashSet<OntologySourceRefObject>(processedOntologySection.snd); } else if (investigationSection == InvestigationFileSection.INVESTIGATION_PUBLICATIONS_SECTION) { Pair<Set<String>, List<Publication>> processedPublicationSection = processPublication( investigationSection, investigationSections.get(investigationSection)); sectionFields.put(investigationSection, processedPublicationSection.fst); publications = processedPublicationSection.snd; } else if (investigationSection == InvestigationFileSection.INVESTIGATION_CONTACTS_SECTION) { Pair<Set<String>, List<Contact>> processedContactSection = processContacts(investigationSection, investigationSections.get(investigationSection)); sectionFields.put(investigationSection, processedContactSection.fst); contacts = processedContactSection.snd; }/* w ww .j a v a2 s .c om*/ } if (tmpInvestigation != null) { OntologyManager.setOntologySources(ontologySources); tmpInvestigation.addToPublications(publications); tmpInvestigation.addToContacts(contacts); tmpInvestigation.addToReferenceObject(sectionFields); } return tmpInvestigation; }
From source file:org.isatools.isacreator.io.importisa.StructureToInvestigationMapper.java
private Study processStudy( OrderedMap<InvestigationFileSection, OrderedMap<String, List<String>>> studySections) { Study study = null;/* w ww .j av a 2s. com*/ List<Protocol> protocols = new ArrayList<Protocol>(); List<Factor> factors = new ArrayList<Factor>(); List<Contact> contacts = new ArrayList<Contact>(); List<Publication> publications = new ArrayList<Publication>(); List<Assay> assays = new ArrayList<Assay>(); List<StudyDesign> studyDesigns = new ArrayList<StudyDesign>(); OrderedMap<InvestigationFileSection, Set<String>> sectionFields = new ListOrderedMap<InvestigationFileSection, Set<String>>(); for (InvestigationFileSection studySection : studySections.keySet()) { if (studySection == InvestigationFileSection.STUDY_SECTION) { Pair<Set<String>, Study> processedStudySection = processStudySection( studySections.get(studySection)); study = processedStudySection.snd; sectionFields.put(studySection, processedStudySection.fst); } else if (studySection == InvestigationFileSection.STUDY_FACTORS) { Pair<Set<String>, List<Factor>> processedFactorsSection = processFactors( studySections.get(studySection)); sectionFields.put(studySection, processedFactorsSection.fst); factors = processedFactorsSection.snd; } else if (studySection == InvestigationFileSection.STUDY_DESIGN_SECTION) { Pair<Set<String>, List<StudyDesign>> processedStudyDesignSection = processStudyDesigns( studySections.get(studySection)); sectionFields.put(studySection, processedStudyDesignSection.fst); studyDesigns = processedStudyDesignSection.snd; } else if (studySection == InvestigationFileSection.STUDY_ASSAYS) { Pair<Set<String>, List<Assay>> processedAssaySection = processAssay( studySections.get(studySection)); sectionFields.put(studySection, processedAssaySection.fst); assays = processedAssaySection.snd; } else if (studySection == InvestigationFileSection.STUDY_PUBLICATIONS) { Pair<Set<String>, List<Publication>> processedPublicationSection = processPublication(studySection, studySections.get(studySection)); sectionFields.put(studySection, processedPublicationSection.fst); publications = processedPublicationSection.snd; } else if (studySection == InvestigationFileSection.STUDY_PROTOCOLS) { Pair<Set<String>, List<Protocol>> processedProtocolSection = processProtocol( studySections.get(studySection)); sectionFields.put(studySection, processedProtocolSection.fst); protocols = processedProtocolSection.snd; } else if (studySection == InvestigationFileSection.STUDY_CONTACTS) { Pair<Set<String>, List<Contact>> processedContactSection = processContacts(studySection, studySections.get(studySection)); sectionFields.put(studySection, processedContactSection.fst); contacts = processedContactSection.snd; } } if (study != null) { study.addToAssays(assays); study.setProtocols(protocols); study.setContacts(contacts); study.setStudyDesigns(studyDesigns); study.setFactors(factors); study.setPublications(publications); // we want to add new fields, but want to keep the general working of the configuration. So we do just that. // new fields (unknown) will be treated as Strings, other known values will acquire the properties // specified of them in the configuration XML. study.addToReferenceObject(sectionFields); } return study; }
From source file:org.isatools.isacreator.io.importisa.StructureToInvestigationMapper.java
private Map<String, String> getRecord(Map<String, List<String>> records, int recordIndex) { OrderedMap<String, String> fields = new ListOrderedMap<String, String>(); for (String fieldName : records.keySet()) { String value = ""; if (recordIndex < records.get(fieldName).size()) { value = records.get(fieldName).get(recordIndex); }/*from w w w.jav a2s . co m*/ fields.put(fieldName, value); } return fields; }