Example usage for org.apache.commons.collections15.set ListOrderedSet ListOrderedSet

List of usage examples for org.apache.commons.collections15.set ListOrderedSet ListOrderedSet

Introduction

In this page you can find the example usage for org.apache.commons.collections15.set ListOrderedSet ListOrderedSet.

Prototype

public ListOrderedSet() 

Source Link

Document

Constructs a new empty ListOrderedSet using a HashSet and an ArrayList internally.

Usage

From source file:org.isatools.isacreator.api.utils.SpreadsheetUtils.java

public static Set<String> getDataInColumn(Spreadsheet targetSheet, int tableViewIndex) {
    int rowCount = targetSheet.getTable().getRowCount();

    Set<String> columnContents = new ListOrderedSet<String>();

    if (tableViewIndex < targetSheet.getTable().getColumnCount()) {
        for (int rowNo = 0; rowNo < rowCount; rowNo++) {
            columnContents.add(targetSheet.getTable().getValueAt(rowNo, tableViewIndex).toString());
        }/*from   w ww  . j av  a2  s  .co  m*/
    }

    return columnContents;
}

From source file:org.isatools.isacreator.common.filterableTree.TreeFilterModel.java

/**
 * Add an element to the Map of items, and then refilter the list in case the new item is being shown when it
 * shouldn't be./*w w  w .j  ava2  s  .c  om*/
 *
 * @param key  - where the item should be added
 * @param item - the item to be added
 */
public void addElement(T key, V item) {
    if (!items.containsKey(key)) {
        items.put(key, new ListOrderedSet<V>());
    }
    items.get(key).add(item);
    refilter();
}

From source file:org.isatools.isacreator.common.filterableTree.TreeFilterModel.java

/**
 * Refilter method clears the previously filtered items and then using the value typed into
 * the FilterField JTextField, items which contain the value typed into the field are added to
 * the filterItems list of terms./*from  w  w  w  .java2  s.  com*/
 */
public void refilter() {
    filterItems.clear();

    String term = targetJTree.getFilterField().getText().toLowerCase();

    for (T key : items.keySet()) {

        for (V value : items.get(key)) {
            if (value.toString().toLowerCase().contains(term)) {
                if (!filterItems.containsKey(key)) {
                    filterItems.put(key, new ListOrderedSet<V>());
                }
                filterItems.get(key).add(value);
            }
        }
        targetJTree.clearSelection();
    }
    rebuildTree();

}

From source file:org.isatools.isacreator.model.ISASection.java

public void addToReferenceObject(OrderedMap<InvestigationFileSection, Set<String>> sectionFields) {
    for (InvestigationFileSection section : sectionFields.keySet()) {
        if (!referenceObject.getSectionDefinition().containsKey(section)) {
            referenceObject.getSectionDefinition().put(section, new ListOrderedSet<String>());
        }/*w w  w.  j a  va  2  s  .  c  om*/
        referenceObject.getSectionDefinition().get(section).addAll(sectionFields.get(section));
    }
}

From source file:org.isatools.isacreator.spreadsheet.SpreadsheetFunctions.java

public Set<String> getValuesInSelectedRowsForColumn(String columnName) {
    int[] selectedRows = spreadsheet.getTable().getSelectedRows();

    Set<String> values = new ListOrderedSet<String>();
    for (int columnIndex = 0; columnIndex < spreadsheet.getColumnCount(); columnIndex++) {
        String colName = spreadsheet.spreadsheetModel.getColumnName(columnIndex);

        if (colName.equals(columnName)) {

            // add all values for this column.
            for (int row : selectedRows) {
                values.add(spreadsheet.spreadsheetModel.getValueAt(row, columnIndex).toString());
            }/*from   www. j av a 2  s .com*/
            break;
        }
    }

    return values;
}

From source file:org.isatools.isacreator.wizard.CreationAlgorithm.java

protected void runAlgorithm() {
    // Retrieve a list of string values dictating where elements are supposed to occur in a table.
    System.out.println("Running algorithm");
    tableStructure = buildingModel.getTableStructure();
    headers = new ArrayList<String>();
    colsToUse = new ListOrderedSet<Integer>();
    int count = tableStructure.size() + 1;
    for (int i = 0; i < tableStructure.size(); i++) {
        // modify this to only add those factors which appear in temp factors.
        if (tableStructure.get(i)[0].toLowerCase().equals("factors")) {
            for (PropertyType factor : factorsToAdd) {
                String newFactor = "Factor Value[" + factor.getPropertyName().trim() + "]";
                addFactor(count, newFactor, factor, i);
            }//  ww  w  . j ava2s  .  c om
        } else if (tableStructure.get(i)[0].toLowerCase().contains("factor value[")) {
            // doing nothing with this factor
        } else if (tableStructure.get(i)[0].toLowerCase().contains("characteristics[")) {

            String newChar = tableStructure.get(i)[0];

            headers.add(newChar);
            colsToUse.add(i);

        } else {
            headers.add(tableStructure.get(i)[0]);
            colsToUse.add(i);
        }
    }

    performAssayCentricTask();
}

From source file:org.isatools.isacreator.wizard.StudySampleCreationAlgorithm.java

public void runAlgorithm() {
    // need to create table reference object for study sample file first.
    tableStructure = buildingModel.getTableStructure();

    headers = new ArrayList<String>();

    FieldObject newFo;//w  ww . ja  v  a 2 s .  c  o  m

    int count = tableStructure.size() + 1;
    rowFormat = "";

    for (int columnIndex = 0; columnIndex < tableStructure.size(); columnIndex++) {

        String fieldName = tableStructure.get(columnIndex)[0];
        if (fieldName != null) {

            if (colsToUse == null) {
                colsToUse = new ListOrderedSet<Integer>();
            }

            if (fieldName.toLowerCase().equals("characteristics")) {

                // SHOULD CHECK IF ONE is available
                newFo = buildingModel.getFieldByName("Characteristics[Organism]");
                headers.add("Characteristics[Organism]");
                if (newFo == null) {
                    newFo = new FieldObject(count, "Characteristics[Organism]", "The organism being studied",
                            DataTypes.ONTOLOGY_TERM, "", false, false, false);
                    buildingModel.addField(newFo);
                }

                count++;
                rowFormat += (organism + "\t");

                newFo = buildingModel.getFieldByName("Characteristics[Organism Part]");
                headers.add("Characteristics[Organism Part]");
                if (newFo == null) {
                    newFo = new FieldObject(count, "Characteristics[Organism Part]",
                            "Part of the organism being studied", DataTypes.ONTOLOGY_TERM, "", false, false,
                            false);
                    buildingModel.addField(newFo);
                }

                count++;
                rowFormat += "[ORGANISM_PART]\t";

            } else if (fieldName.toLowerCase().contains("characteristics[")) {
                // then a check needs to be done to ensure the characteristic isn't added if it is already there!
                String value = fieldName.toLowerCase();
                if (!value.contains("organism") && !value.contains("organism part")) {
                    headers.add(fieldName);
                    colsToUse.add(columnIndex);
                    rowFormat += " \t";
                }
            } else if (fieldName.toLowerCase().equals("factors")) {
                for (PropertyType tf : factorsToAdd) {

                    headers.add("Factor Value[" + tf.getPropertyName().trim() + "]");

                    boolean unitAdded = false;

                    for (PropertyValue tup : tf.getValuesAndUnits()) {
                        if (!tup.getUnit().trim().equals("")) {
                            headers.add("Unit");
                            unitAdded = true;

                            break;
                        }
                    }

                    if (unitAdded) {
                        // add factor column field first
                        newFo = new FieldObject(count, "Factor Value[" + tf.getPropertyName().trim() + "]",
                                "Factor", DataTypes.STRING, "", false, false, false);
                        buildingModel.addField(newFo);
                        count++;

                        newFo = new FieldObject(count, "Unit", "Unit to give meaning to its associated value",
                                DataTypes.ONTOLOGY_TERM, "", false, false, false);
                        buildingModel.addField(newFo);
                        count++;
                    } else {
                        newFo = new FieldObject(count, "Factor Value[" + tf.getPropertyName().trim() + "]",
                                "Factor", DataTypes.ONTOLOGY_TERM, "", false, false, false);
                        buildingModel.addField(newFo);
                        count++;
                    }
                }

                rowFormat += "[FACTORS]";

            } else if (fieldName.toLowerCase().contains("factor value[")) {
                if (!checkForFactorExistence(fieldName)) {
                    headers.add(fieldName);
                    colsToUse.add(columnIndex);
                    rowFormat += " \t";
                }
            } else if (fieldName.equals(GeneralFieldTypes.PROTOCOL_REF.name)) {
                // we have a protocol. Do two things: set value to its default value and add it to the study protocols
                headers.add(fieldName);
                colsToUse.add(columnIndex);
                rowFormat += buildingModel.getDefaultValue(columnIndex + 1) + "\t";
            } else {

                headers.add(fieldName);

                if (fieldName.equalsIgnoreCase("source name")) {
                    rowFormat += (SOURCE_NAME_PLACE_HOLDER + "\t");
                } else if (fieldName.equalsIgnoreCase("sample name")) {
                    rowFormat += SAMPLE_NAMES_PLACE_HOLDER + "\t";
                } else {
                    rowFormat += " \t";
                }
            }
        }
    }

    Vector<String> headersForReferenceObject = new Vector<String>();
    String[] headersAsArray = new String[headers.size()];
    headersForReferenceObject.add(TableReferenceObject.ROW_NO_TEXT);

    for (int i = 0; i < headers.size(); i++) {
        headersForReferenceObject.add(headers.get(i));
        headersAsArray[i] = headers.get(i);
    }

    buildingModel.setPreDefinedHeaders(headersForReferenceObject);

    addRowsToModel(headersAsArray);

    TableReferenceObjectWrapper troAdapter = new TableReferenceObjectWrapper(buildingModel);
    troAdapter.setConstructProtocolsWithDefaultValues(true);
    List<Protocol> protocols = troAdapter.findProtocols();

    study.getProtocols().addAll(protocols);

    studySample.setTableReferenceObject(buildingModel);
}