Example usage for java.util SortedSet clear

List of usage examples for java.util SortedSet clear

Introduction

In this page you can find the example usage for java.util SortedSet clear.

Prototype

void clear();

Source Link

Document

Removes all of the elements from this set (optional operation).

Usage

From source file:org.alfresco.repo.domain.node.AbstractNodeDAOImpl.java

private void cacheNodesBatch(List<Long> nodeIds) {
    int batchSize = 256;
    SortedSet<Long> batch = new TreeSet<Long>();
    for (Long nodeId : nodeIds) {
        batch.add(nodeId);//  w w  w . j  a  va  2  s. c  o  m
        if (batch.size() >= batchSize) {
            // Preload
            List<Node> nodes = selectNodesByIds(batch);
            cacheNodesNoBatch(nodes);
            batch.clear();
        }
    }
    // Load any remaining nodes
    if (batch.size() > 0) {
        List<Node> nodes = selectNodesByIds(batch);
        cacheNodesNoBatch(nodes);
    }
}

From source file:org.alfresco.repo.domain.node.AbstractNodeDAOImpl.java

/**
 * Loads the nodes into cache using batching.
 *//*  ww  w .j av  a  2  s  .c  o m*/
private void cacheNodes(StoreRef storeRef, List<String> uuids) {
    StoreEntity store = getStoreNotNull(storeRef);
    Long storeId = store.getId();

    int batchSize = 256;
    SortedSet<String> batch = new TreeSet<String>();
    for (String uuid : uuids) {
        batch.add(uuid);
        if (batch.size() >= batchSize) {
            // Preload
            List<Node> nodes = selectNodesByUuids(storeId, batch);
            cacheNodesNoBatch(nodes);
            batch.clear();
        }
    }
    // Load any remaining nodes
    if (batch.size() > 0) {
        List<Node> nodes = selectNodesByUuids(storeId, batch);
        cacheNodesNoBatch(nodes);
    }
}

From source file:au.org.ala.delta.editor.slotfile.model.VOCharacterAdaptor.java

protected ControllingInfo checkApplicability(VOItemDesc item, VOCharBaseDesc charBase, int recurseLevel,
        List<Integer> testedControlledChars) {

    int controllingId = 0;
    if (item == null || charBase == null || charBase.getNControlling() == 0) {
        return new ControllingInfo();
    }/*from w w w .  j  a  v  a 2 s .  com*/

    boolean unknownOk = false;
    List<Integer> controlling = charBase.readControllingInfo();

    if (controlling != null && controlling.size() > 1) {
        Collections.sort(controlling, new CompareCharNos(false));
    }

    List<Integer> controllingChars = new ArrayList<Integer>();
    SortedSet<Integer> controllingStates = new TreeSet<Integer>();
    List<Integer> newContStates = new ArrayList<Integer>();
    int testCharId = VOUID_NULL;

    controlling.add(VOUID_NULL); // Append dummy value, to ease handling of
                                 // the last element
                                 // Loop through all controlling attributes which directly control this
                                 // character...
    for (Integer i : controlling) {
        int newContCharId = 0;
        if (i == VOUID_NULL) {
            newContCharId = VOUID_NULL;
        } else {
            VOControllingDesc contAttrDesc = (VOControllingDesc) ((DeltaVOP) charBase.getVOP())
                    .getDescFromId(i);
            newContStates = contAttrDesc.readStateIds();
            Collections.sort(newContStates);
            newContCharId = contAttrDesc.getCharId();
        }

        if (newContCharId == testCharId) {
            // / Build up all relevant controlling attributes under the
            // control of a
            // / single controlling character, merging the state lists as we
            // go....
            controllingStates.addAll(newContStates);
        } else {
            // Do checks when changing controlling state
            if (testCharId != VOUID_NULL) {
                VOCharBaseDesc testCharBase = getDescFromId(testCharId);

                if (!CharType.isMultistate(testCharBase.getCharType())) {
                    throw new RuntimeException("Controlling characters must be multistate!");
                }
                controllingId = testCharId;

                // If the controlling character is coded, see whether it
                // makes us inapplicable

                if (item.hasAttribute(controllingId)) {
                    Attribute attrib = item.readAttribute(controllingId);
                    List<Integer> codedStates = new ArrayList<Integer>();
                    short[] pseudoValues = new short[] { 0 };
                    attrib.getEncodedStates(testCharBase, codedStates, pseudoValues);

                    // If controlling character is "variable", we are NOT
                    // controlled
                    if ((pseudoValues[0] & VOItemDesc.PSEUDO_VARIABLE) == 0) {
                        if (codedStates.isEmpty()) {
                            // If there are no states for the controlling
                            // character,
                            // but it is explicitly coded with the "unknown"
                            // pseudo-value,
                            // allow the controlled character to also be
                            // unknown.
                            if ((pseudoValues[0] & VOItemDesc.PSEUDO_UNKNOWN) != 0) {
                                unknownOk = true;
                            } else {
                                return new ControllingInfo(ControlledStateType.Inapplicable, controllingId);
                            }
                        } else if (controllingStates.containsAll(codedStates)) {
                            return new ControllingInfo(ControlledStateType.Inapplicable, controllingId);
                        }
                    }
                } else if (testCharBase.getUncodedImplicit() != VOCharBaseDesc.STATEID_NULL) {
                    // if the controlling character is not encoded, see if
                    // there is an implicit value for it
                    if (controllingStates.contains(testCharBase.getUncodedImplicit())) {
                        return new ControllingInfo(ControlledStateType.Inapplicable, controllingId);
                    }
                } else {
                    return new ControllingInfo(ControlledStateType.Inapplicable, controllingId);
                    // /// This should probably be handled as a somewhat
                    // special case,
                    // /// so the user can be pointed in the right direction
                }
            }
            controllingId = VOUID_NULL;
            testCharId = newContCharId;
            if (testCharId != VOUID_NULL) {
                controllingChars.add(testCharId);
            }
            controllingStates.clear();
            controllingStates.addAll(newContStates);
        }
    }

    // Up to this point, nothing has made this character inapplicable.
    // But it is possible that one of the controlling characters has itself
    // been made inapplicable.

    // Is this check really necessary? I suppose it is, but it slows things
    // down...
    for (int j : controllingChars) {

        if (++recurseLevel >= getDeltaMaster().getNContAttrs()) {
            try {
                List<Integer> contChars = new ArrayList<Integer>();
                getControlledChars(testedControlledChars, _charDesc, contChars, true);
            } catch (CircularDependencyException ex) {
                return new ControllingInfo(ControlledStateType.Inapplicable, controllingId);
            }
        }
        VOCharBaseDesc testCharBase = getDescFromId(j);
        ControllingInfo info = checkApplicability(item, testCharBase, recurseLevel, testedControlledChars);
        if (info.isInapplicable()) {
            return info;
        }
    }
    return unknownOk ? new ControllingInfo(ControlledStateType.InapplicableOrUnknown, controllingId)
            : new ControllingInfo();
}

From source file:br.gov.jfrj.siga.ex.bl.ExBL.java

private void cancelarAlteracao() throws AplicacaoException {
    ExDao.rollbackTransacao();//ww  w.  j a v  a  2  s. c  o m
    SortedSet<ExMobil> set = threadAlteracaoParcial.get();
    if (set != null)
        set.clear();
}

From source file:br.gov.jfrj.siga.ex.bl.ExBL.java

private void concluirAlteracao(ExDocumento doc) throws Exception {
    if (doc != null) {
        atualizarMarcas(doc);/* w w  w.j  a v  a 2  s . c o  m*/
        atualizarVariaveisDenormalizadas(doc);
    }
    ExDao.commitTransacao();
    // if (doc != null)
    // atualizarWorkflow(doc, null);

    SortedSet<ExMobil> set = threadAlteracaoParcial.get();
    if (set != null && set.size() > 0) {
        for (ExMobil mob : set) {
            atualizarWorkflow(mob.doc(), null);
        }
        set.clear();
    } else {
        if (doc != null) {
            atualizarWorkflow(doc, null);
        }

    }
}