Example usage for org.apache.commons.collections.keyvalue MultiKey MultiKey

List of usage examples for org.apache.commons.collections.keyvalue MultiKey MultiKey

Introduction

In this page you can find the example usage for org.apache.commons.collections.keyvalue MultiKey MultiKey.

Prototype

public MultiKey(Object[] keys, boolean makeClone) 

Source Link

Document

Constructor taking an array of keys, optionally choosing whether to clone.

Usage

From source file:org.perfrepo.web.controller.reports.parametrized.TestExecutionTable.java

public Value getValue(String metricName, MultiKey parameters) {
    MultiKey colKey = new MultiKey(jobId, metricName);
    return table.get(parameters, colKey);
}

From source file:org.shw.process.SHWOrderLineInoutLineCreate.java

/**
 *    Create new Order/*from  w ww  . j  a v a 2s .  c  om*/
 *   @param rLine request line
 *   @param C_BPartner_ID b.partner
 *    @throws Exception
 */
private void newOrder(MRequisitionLine rLine, int C_BPartner_ID) throws Exception {
    if (m_order != null) {
        closeOrder();
    }

    //   Order
    Timestamp DateRequired = rLine.getDateRequired();
    MultiKey key = new MultiKey(rLine.getC_BPartner_ID(), DateRequired);
    m_order = m_cacheOrders.get(key);
    if (m_order == null) {
        m_order = new MOrder(getCtx(), 0, get_TrxName());
        m_order.setAD_Org_ID(rLine.getParent().getM_Warehouse().getAD_Org_ID());
        m_order.setM_Warehouse_ID(rLine.getParent().getM_Warehouse_ID());
        if (p_dateOrdered == null)
            m_order.setDatePromised(DateRequired);
        else
            m_order.setDatePromised(p_dateOrdered);
        m_order.setIsSOTrx(false);
        if (p_C_Doctype_ID > 0)
            m_order.setC_DocTypeTarget_ID(p_C_Doctype_ID);
        else
            m_order.setC_DocTypeTarget_ID();

        if (p_C_OrderSource_ID > 0)
            m_order.setC_OrderSource_ID(p_C_OrderSource_ID);
        if (!p_POReference.equals(""))
            m_order.setPOReference(p_POReference);
        m_bpartner = new MBPartner(getCtx(), rLine.getC_BPartner_ID(), get_TrxName());
        m_order.setBPartner(m_bpartner);
        int M_PriceList_ID = m_bpartner.getPO_PriceList_ID();
        if (M_PriceList_ID <= 0)
            M_PriceList_ID = rLine.getParent().getM_PriceList_ID();
        if (M_PriceList_ID <= 0)
            M_PriceList_ID = MPriceList.getDefault(getCtx(), false).getM_PriceList_ID();
        m_order.setM_PriceList_ID(M_PriceList_ID);
        m_order.setSalesRep_ID(rLine.getCreatedBy());
        m_order.setDescription(rLine.getParent().getDescription());
        m_order.setDatePromised(rLine.getParent().getDateRequired());
        m_order.setDocAction(MOrder.DOCACTION_Complete);
        //   default po document type
        if (!p_ConsolidateDocument) {
            m_order.setDescription(
                    Msg.getElement(getCtx(), "M_Requisition_ID") + ": " + rLine.getParent().getDocumentNo());
        }
        //   Prepare Save
        m_order.saveEx();
        // Put to cache
        m_cacheOrders.put(key, m_order);
    }
    m_M_Requisition_ID = rLine.getM_Requisition_ID();
}

From source file:org.talend.repository.localprovider.model.LocalRepositoryFactory.java

private <K, T> void addItemToContainer(Container<K, T> container, IRepositoryViewObject objectToAdd,
        boolean onlyLastVersion) throws PersistenceException {
    if (objectToAdd != null) {
        K key;/*  w  w w.  j  av  a2 s  .  c om*/
        String currentVersion = null;
        try {
            currentVersion = objectToAdd.getVersion();
        } catch (Exception e) {
            // e.printStackTrace();
            ExceptionHandler.process(e);
        }
        if (onlyLastVersion) {
            key = (K) objectToAdd.getId();
        } else {
            key = (K) new MultiKey(objectToAdd.getId(), currentVersion);
        }

        try {
            if (onlyLastVersion) {
                // Version :
                T old = container.getMember(key);

                if (old == null) {
                    container.addMember(key, (T) objectToAdd);
                } else {
                    String oldVersion = ((IRepositoryViewObject) old).getVersion();
                    if (VersionUtils.compareTo(oldVersion, currentVersion) < 0) {
                        container.addMember(key, (T) objectToAdd);
                    }
                }
            } else {
                container.addMember(key, (T) objectToAdd);
            }
        } catch (BusinessException e) {
            throw new PersistenceException(e);
        }
    }

}

From source file:org.wikipedia.nirvana.statistics.StatisticsFabric.java

@SuppressWarnings("unchecked")
static Statistics createReporter(NirvanaWiki wiki, String type, int year) {
    Statistics ob = null;/*w w w  .  ja  v  a 2  s  .c  o  m*/
    MultiKey multiKey = new MultiKey(type, new Integer(year));
    ob = (Statistics) reportersYear.get(multiKey);
    if (ob == null) {
        Class cl = reporterClass.get(type);
        if (cl == null)
            return null;
        try {
            Class params[] = new Class[] { NirvanaWiki.class, String.class, int.class };
            Constructor c = cl.getDeclaredConstructor(params);
            ob = (Statistics) c.newInstance(wiki, type, year);
            reportersYear.put(multiKey, ob);
        } catch (Exception e) {
            log.error(e.toString());
            e.printStackTrace();
        }
    }
    // NULL return value will tell about error         
    return ob;
}

From source file:org.wikipedia.nirvana.statistics.StatisticsFabric.java

static Statistics getReporter(String type, int year) {
    Statistics ob = null;/*w  ww .  ja  v  a 2 s. c  o m*/
    MultiKey multiKey = new MultiKey(type, new Integer(year));
    ob = (Statistics) reportersYear.get(multiKey);
    return ob;
}

From source file:org.wikipedia.nirvana.WikiBooster.java

/**
 * Check if a particular page contains a particular template.
 *
 * @param title the title of the page./*from  w ww  . j av a  2s . c o m*/
 * @param template the template name with namespace prefix.
 * @return <true> if asked page is using asked template
 * @see org.wikipedia.Wiki#hasTemplate(String[], String) 
 */
public boolean hasTemplate(String title, String template) throws IOException {
    if (templates == null) {
        throw new RuntimeException("This class is not prepared to be used with templates");
    }
    if (!pagesSet.contains(title)) {
        throw new IllegalStateException("The booster is not prepared for page: " + title);
    }
    if (!templatesSet.contains(template)) {
        throw new IllegalStateException("The booster is not prepared for template: " + template);
    }
    if (hasTemplatesCache == null) {
        log.debug("Request templates usage info for " + pages.size() + " pages and " + templates.size()
                + " templates");
        boolean[][] data = wiki.hasTemplates(pages.toArray(new String[pages.size()]),
                templates.toArray(new String[templates.size()]));
        hasTemplatesCache = new MultiKeyMap();
        for (int i = 0; i < pages.size(); i++) {
            for (int j = 0; j < templates.size(); j++) {
                MultiKey key = new MultiKey(pages.get(i), templates.get(j));
                hasTemplatesCache.put(key, data[i][j]);
            }
        }
    }
    Boolean result = (Boolean) hasTemplatesCache.get(title, template);
    if (result == null) {
        throw new IllegalStateException(
                "Info not found in cash about page: " + title + " and template: " + template);
    }
    return result;
}

From source file:pl.touk.ode.scopeEvaluator.MockExtVarManager.java

private MultiKey elementToKey(String name, Element key) {
    HashMap<String, String> ret = new HashMap<String, String>();
    for (String k : extVarKeyConfig.get(name)) {
        ret.put(k, key.getElementsByTagNameNS(extVarNSConfig.get(name), k).item(0).getTextContent());
    }// w w w  .j  a va 2s. com
    return new MultiKey(name, ret);
}

From source file:uk.ac.ebi.embl.api.validation.check.entry.DuplicateFeatureCheck.java

public ValidationResult check(Entry entry) {
    features = new ArrayList<Feature>();
    organismList = new ArrayList<String>();
    protein_idMap = new DualHashBidiMap();

    result = new ValidationResult();

    if (entry == null) {
        return result;
    }/* w w w . j  ava  2 s. co m*/
    featureMap = new HashMap<MultiKey, Feature>();
    features = entry.getFeatures();

    // System.out.println("protein_id map size:"+protein_idMap.size());
    for (Feature feature : features) {
        boolean duplicateOrganism = false;
        String organismValue = null;
        String featureName = feature.getName();
        if (featureName.equals(Feature.SOURCE_FEATURE_NAME)) {
            Qualifier organism = SequenceEntryUtils.getQualifier(Qualifier.ORGANISM_QUALIFIER_NAME, feature);
            if (organism != null)
                organismValue = organism.getValue();
            if (organismValue != null && !organismList.isEmpty() && organismList.contains(organismValue)) {
                duplicateOrganism = true;
            }
            if (organismValue != null)
                organismList.add(organismValue);
        }
        try {
            if (featureName.equals(Feature.CDS_FEATURE_NAME)) {
                String newProtein_id = ((CdsFeature) feature).getProteinAccession();
                if (newProtein_id != null && !protein_idMap.isEmpty()
                        && protein_idMap.containsValue(newProtein_id)) {
                    Feature oldFeature = (Feature) protein_idMap.getKey(newProtein_id);

                    ValidationMessage<Origin> message = reportError(feature.getOrigin(),
                            DUPLICATE_CDS_PROTEIN_MESSAGE_ID, newProtein_id);
                    message.append(feature.getOrigin());

                    FeatureValidationCheck.appendLocusTadAndGeneIDToMessage(oldFeature, message);
                    FeatureValidationCheck.appendLocusTadAndGeneIDToMessage(feature, message);
                } else if (newProtein_id != null)
                    protein_idMap.put(feature, newProtein_id);
            }
        } catch (ValidationException e) {
        }
        MultiKey key = new MultiKey(featureName, feature.getLocations());
        if (!featureMap.containsKey(key)) {
            addMultiKeyAndValue(key, feature);
        } else {
            Feature oldFeature = featureMap.get(key);
            if (featureName.equals(Feature.SOURCE_FEATURE_NAME)) {
                if (duplicateOrganism) {
                    ValidationMessage<Origin> message = reportError(oldFeature.getOrigin(),
                            DUPLICATE_SOURCE_ORGANISM_MESSAGE_ID, organismValue,
                            oldFeature.getLocations().getMinPosition(),
                            oldFeature.getLocations().getMaxPosition());
                    message.append(feature.getOrigin());
                    FeatureValidationCheck.appendLocusTadAndGeneIDToMessage(oldFeature, message);
                    FeatureValidationCheck.appendLocusTadAndGeneIDToMessage(feature, message);
                }

            } else if (feature.getName().equals(Feature.CDS_FEATURE_NAME)) {
                try {
                    Integer newCodon_start = 0;
                    Integer oldCodon_start = 0;
                    CdsFeature newcdsFeature = (CdsFeature) feature;
                    CdsFeature oldcdsFeature = (CdsFeature) oldFeature;
                    if (SequenceEntryUtils.isQualifierAvailable(Qualifier.CODON_START_QUALIFIER_NAME,
                            newcdsFeature))
                        newCodon_start = ((CdsFeature) feature).getStartCodon();
                    if (SequenceEntryUtils.isQualifierAvailable(Qualifier.CODON_START_QUALIFIER_NAME,
                            oldcdsFeature))
                        oldCodon_start = ((CdsFeature) oldFeature).getStartCodon();
                    if (newCodon_start.equals(oldCodon_start) || (oldCodon_start == 0 && newCodon_start == 1)
                            || (oldCodon_start == 1 && newCodon_start == 0)) {
                        ValidationMessage<Origin> message = reportError(oldFeature.getOrigin(),
                                DUPLICATE_CDS_CODON_START_MESSAGE_ID, oldCodon_start);
                        message.append(feature.getOrigin());

                        FeatureValidationCheck.appendLocusTadAndGeneIDToMessage(oldFeature, message);
                        FeatureValidationCheck.appendLocusTadAndGeneIDToMessage(feature, message);
                    }

                } catch (ValidationException e) {
                }
            }

            else {
                ValidationMessage<Origin> message = reportError(feature.getOrigin(), MESSAGE_ID,
                        feature.getName());
                message.append(oldFeature.getOrigin());

                FeatureValidationCheck.appendLocusTadAndGeneIDToMessage(feature, message);
                FeatureValidationCheck.appendLocusTadAndGeneIDToMessage(oldFeature, message);
            }
        }
    }
    // System.out.println("protein_id map size:"+protein_idMap.size());
    return result;
}