Example usage for java.util List clear

List of usage examples for java.util List clear

Introduction

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

Prototype

void clear();

Source Link

Document

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

Usage

From source file:org.codhaus.groovy.grails.validation.ext.ConstrainedPropertyGunn.java

public static void removeConstraint(String name) {
    Assert.hasLength(name, "Argument [name] cannot be null");

    List<Object> objects = getOrInitializeConstraint(name);
    objects.clear();
}

From source file:no.kantega.kwashc.server.controller.TestController.java

@RequestMapping("/site/{siteId}/executeAll")
public String executeTests(@PathVariable Long siteId) {
    Site site = siteRepository.findOne(siteId);

    Map<String, AbstractTest> tests = TestRepository.getTests();

    List<TestResult> results = site.getTestResults();

    // remove old tests
    results.clear();

    for (AbstractTest test : tests.values()) {
        TestResult testResult = test.testSite(site);
        results.add(testResult);//from   w  w w .  j a  v  a2s . c  om

        // save the run:
        TestRun testRun = new TestRun(testResult);
        testRunRepository.save(testRun);
    }

    site.setTestResults(results);
    siteRepository.save(site);

    return "redirect:/site/" + siteId + "/";
}

From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.InlineAssignIntoAggregateRule.java

private boolean inlined(Mutable<ILogicalOperator> r) throws AlgebricksException {
    AbstractLogicalOperator op1 = (AbstractLogicalOperator) r.getValue();
    if (op1.getOperatorTag() != LogicalOperatorTag.AGGREGATE) {
        return false;
    }/*  w  ww.ja v a  2s .c o  m*/
    AbstractLogicalOperator op2 = (AbstractLogicalOperator) op1.getInputs().get(0).getValue();
    if (op2.getOperatorTag() != LogicalOperatorTag.ASSIGN) {
        return false;
    }
    AggregateOperator agg = (AggregateOperator) op1;
    AssignOperator assign = (AssignOperator) op2;
    VarExprSubstitution ves = new VarExprSubstitution(assign.getVariables(), assign.getExpressions());
    for (Mutable<ILogicalExpression> exprRef : agg.getExpressions()) {
        ILogicalExpression expr = exprRef.getValue();
        Pair<Boolean, ILogicalExpression> p = expr.accept(ves, null);
        if (p.first == true) {
            exprRef.setValue(p.second);
        }
        // AbstractLogicalExpression ale = (AbstractLogicalExpression) expr;
        // ale.accept(ves, null);
    }
    List<Mutable<ILogicalOperator>> op1InpList = op1.getInputs();
    op1InpList.clear();
    op1InpList.add(op2.getInputs().get(0));
    return true;
}

From source file:com.sonatype.security.ldap.AbstractMockLdapConnectorTest.java

protected void resetLdapConnectors() throws Exception {
    List<LdapConnector> connectors = this.ldapManager.getLdapConnectors();

    connectors.clear();
    connectors.addAll(this.getLdapConnectors());
}

From source file:com.healthmarketscience.jackcess.util.ImportUtil.java

/**
 * Copy an existing JDBC ResultSet into a new (or optionally existing) table
 * in this database./*from  w  w  w.  jav  a 2s . co  m*/
 * 
 * @param name Name of the new table to create
 * @param source ResultSet to copy from
 * @param filter valid import filter
 * @param useExistingTable if {@code true} use current table if it already
 *                         exists, otherwise, create new table with unique
 *                         name
 *
 * @return the name of the imported table
 * 
 * @see Builder
 */
public static String importResultSet(ResultSet source, Database db, String name, ImportFilter filter,
        boolean useExistingTable) throws SQLException, IOException {
    ResultSetMetaData md = source.getMetaData();

    name = TableBuilder.escapeIdentifier(name);
    Table table = null;
    if (!useExistingTable || ((table = db.getTable(name)) == null)) {
        List<ColumnBuilder> columns = toColumns(md);
        table = createUniqueTable(db, name, columns, md, filter);
    }

    List<Object[]> rows = new ArrayList<Object[]>(COPY_TABLE_BATCH_SIZE);
    int numColumns = md.getColumnCount();

    while (source.next()) {
        Object[] row = new Object[numColumns];
        for (int i = 0; i < row.length; i++) {
            row[i] = source.getObject(i + 1);
        }
        row = filter.filterRow(row);
        if (row == null) {
            continue;
        }
        rows.add(row);
        if (rows.size() == COPY_TABLE_BATCH_SIZE) {
            table.addRows(rows);
            rows.clear();
        }
    }
    if (rows.size() > 0) {
        table.addRows(rows);
    }

    return table.getName();
}

From source file:com.healthmarketscience.jackcess.ImportUtil.java

/**
 * Copy an existing JDBC ResultSet into a new (or optionally existing) table
 * in this database.// w w  w.  j av  a 2  s. c o  m
 * 
 * @param name Name of the new table to create
 * @param source ResultSet to copy from
 * @param filter valid import filter
 * @param useExistingTable if {@code true} use current table if it already
 *                         exists, otherwise, create new table with unique
 *                         name
 *
 * @return the name of the imported table
 * 
 * @see Builder
 */
public static String importResultSet(ResultSet source, Database db, String name, ImportFilter filter,
        boolean useExistingTable) throws SQLException, IOException {
    ResultSetMetaData md = source.getMetaData();

    name = Database.escapeIdentifier(name);
    Table table = null;
    if (!useExistingTable || ((table = db.getTable(name)) == null)) {

        List<Column> columns = new LinkedList<Column>();
        for (int i = 1; i <= md.getColumnCount(); i++) {
            Column column = new Column();
            column.setName(Database.escapeIdentifier(md.getColumnName(i)));
            int lengthInUnits = md.getColumnDisplaySize(i);
            column.setSQLType(md.getColumnType(i), lengthInUnits);
            DataType type = column.getType();
            // we check for isTrueVariableLength here to avoid setting the length
            // for a NUMERIC column, which pretends to be var-len, even though it
            // isn't
            if (type.isTrueVariableLength() && !type.isLongValue()) {
                column.setLengthInUnits((short) lengthInUnits);
            }
            if (type.getHasScalePrecision()) {
                int scale = md.getScale(i);
                int precision = md.getPrecision(i);
                if (type.isValidScale(scale)) {
                    column.setScale((byte) scale);
                }
                if (type.isValidPrecision(precision)) {
                    column.setPrecision((byte) precision);
                }
            }
            columns.add(column);
        }

        table = createUniqueTable(db, name, columns, md, filter);
    }

    List<Object[]> rows = new ArrayList<Object[]>(COPY_TABLE_BATCH_SIZE);
    int numColumns = md.getColumnCount();

    while (source.next()) {
        Object[] row = new Object[numColumns];
        for (int i = 0; i < row.length; i++) {
            row[i] = source.getObject(i + 1);
        }
        row = filter.filterRow(row);
        if (row == null) {
            continue;
        }
        rows.add(row);
        if (rows.size() == COPY_TABLE_BATCH_SIZE) {
            table.addRows(rows);
            rows.clear();
        }
    }
    if (rows.size() > 0) {
        table.addRows(rows);
    }

    return table.getName();
}

From source file:com.bb.extensions.plugin.unittests.internal.utilities.FileUtils.java

/**
 * Finds all the files in the given folder with the given extensions.
 * //from  w w  w .  j  a v a2s.  c o m
 * @param folder
 *            The folder to search
 * @param extensions
 *            The extensions to look for.
 * @return The list of files found.
 */
public static List<IFile> findFiles(IFolder folder, final List<String> extensions) {
    final List<IFile> files = new ArrayList<IFile>();

    try {
        folder.accept(new IResourceVisitor() {
            /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.core.resources.IResourceVisitor#visit(org
             * .eclipse .core.resources.IResource)
             */
            @Override
            public boolean visit(IResource res) throws CoreException {
                if (res.getType() == IResource.FILE) {
                    if (extensions.contains(res.getFileExtension())) {
                        files.add((IFile) res);
                    }
                    return false;
                }
                return true;
            }

        });
    } catch (CoreException e1) {
        // on exception, return nothing
        files.clear();
    }

    return files;
}

From source file:com.haulmont.cuba.core.app.EntityRestoreServiceBean.java

protected void fillProperties(MetaClass metaClass, List<MetaProperty> properties, String annotationName) {
    properties.clear();
    MetaProperty[] metaProperties = (MetaProperty[]) metaClass.getAnnotations().get(annotationName);
    if (metaProperties != null)
        properties.addAll(Arrays.asList(metaProperties));
    for (MetaClass aClass : metaClass.getAncestors()) {
        metaProperties = (MetaProperty[]) aClass.getAnnotations().get(annotationName);
        if (metaProperties != null)
            properties.addAll(Arrays.asList(metaProperties));
    }/*from  w  ww .  j  ava  2s. c  om*/
}

From source file:com.legstar.coxb.gen.CoxbGenAntSamplesTest.java

/**
 * Generate the sample ant scripts.//from   w  w w  . j  a  v a  2 s  . c o m
 * 
 * @throws Exception if ant cannot be generated
 */
public void testBuildCoxb() throws Exception {

    List<String> jaxbRootClassNames = new ArrayList<String>();
    File script = null;

    jaxbRootClassNames.clear();
    jaxbRootClassNames.add("Dfhcommarea");
    script = buildCoxbAntScript("lsfileae", "com.legstar.test.coxb.lsfileae", jaxbRootClassNames);
    assertNotNull(script);

    jaxbRootClassNames.clear();
    jaxbRootClassNames.add("JvmQueryRequest");
    jaxbRootClassNames.add("JvmQueryReply");
    script = buildCoxbAntScript("jvmquery", "com.legstar.test.coxb.jvmquery", jaxbRootClassNames);
    assertNotNull(script);

    jaxbRootClassNames.clear();
    jaxbRootClassNames.add("GetInfo");
    jaxbRootClassNames.add("GetInfoResponse");
    script = buildCoxbAntScript("cultureinfo", "com.legstar.test.coxb.cultureinfo", jaxbRootClassNames);
    assertNotNull(script);

}

From source file:fr.cls.atoll.motu.processor.wps.TestServiceMetadata.java

public static void testIso19139Operations() {
    //        //  www  . j  av a 2s  . c  om
    // JAXBElement<?> element = testdom4j();
    // if (element == null) {
    // return;
    // }

    try {
        ServiceMetadata serviceMetadata = new ServiceMetadata();
        URL url = null;
        Set<SVOperationMetadataType> listOperation = new HashSet<SVOperationMetadataType>();
        // url = new
        // URL("file:///c:/Documents and Settings/dearith/Mes documents/Atoll/SchemaIso/TestServiceMetadataOK.xml");
        url = Organizer.findResource("fmpp/src/ServiceMetadataOpendap.xml");
        serviceMetadata.getOperations(url, listOperation);
        ServiceMetadata.dump(listOperation);
        List<String> listOperationNamesUnique = new ArrayList<String>();

        serviceMetadata.getOperationsNameUnique(listOperation, listOperationNamesUnique);

        for (String name : listOperationNamesUnique) {

            System.out.println("==================");
            if (name == null) {
                continue;
            }
            System.out.println(name);
        }
        listOperationNamesUnique.clear();
        serviceMetadata.getOperationsInvocationNameUnique(listOperation, listOperationNamesUnique);
        for (String name : listOperationNamesUnique) {

            System.out.println("------+++++==================");
            if (name == null) {
                continue;
            }
            System.out.println(name);
        }

        List<SVOperationMetadataType> listOperationUnique = new ArrayList<SVOperationMetadataType>();

        serviceMetadata.getOperationsUnique(listOperation, listOperationUnique);
        for (SVOperationMetadataType operationMetadataType : listOperationUnique) {

            System.out.println("---------------------------------------------");
            if (operationMetadataType == null) {
                continue;
            }
            System.out.println(operationMetadataType.getOperationName().getCharacterString().getValue());
        }

        OperationRelationshipEdge<String> edge = new OperationRelationshipEdge<String>();
        DirectedGraph<OperationMetadata, OperationRelationshipEdge<String>> directedGraph = new DefaultDirectedGraph<OperationMetadata, OperationRelationshipEdge<String>>(
                (Class<? extends OperationRelationshipEdge<String>>) edge.getClass());
        serviceMetadata.getOperations(url, directedGraph);

        StrongConnectivityInspector<OperationMetadata, OperationRelationshipEdge<String>> sci = new StrongConnectivityInspector<OperationMetadata, OperationRelationshipEdge<String>>(
                directedGraph);
        List<DirectedSubgraph<OperationMetadata, OperationRelationshipEdge<String>>> stronglyConnectedSubgraphs = sci
                .stronglyConnectedSubgraphs();
        sci.stronglyConnectedSets();
        System.out.println(sci.isStronglyConnected());

        // prints the strongly connected components
        System.out.println("Strongly connected components:");
        for (int i = 0; i < stronglyConnectedSubgraphs.size(); i++) {
            System.out.println(stronglyConnectedSubgraphs.get(i));
        }
        System.out.println();

        System.out.println(directedGraph.edgeSet());

        ConnectivityInspector<OperationMetadata, OperationRelationshipEdge<String>> ci = new ConnectivityInspector<OperationMetadata, OperationRelationshipEdge<String>>(
                directedGraph);
        System.out.println(ci.isGraphConnected());

        DirectedNeighborIndex<OperationMetadata, OperationRelationshipEdge<String>> ni = new DirectedNeighborIndex<OperationMetadata, OperationRelationshipEdge<String>>(
                directedGraph);

        List<OperationMetadata> sourceOperations = new ArrayList<OperationMetadata>();
        List<OperationMetadata> sinkOperations = new ArrayList<OperationMetadata>();

        ServiceMetadata.getSourceOperations(directedGraph, sourceOperations);
        ServiceMetadata.getSinkOperations(directedGraph, sinkOperations);

        System.out.println("%%%%%%%% SOURCE %%%%%%%%%%%%");
        System.out.println(sourceOperations);
        System.out.println("%%%%%%%% SINK %%%%%%%%%%%%");
        System.out.println(sinkOperations);

        for (OperationMetadata source : sourceOperations) {
            System.out.print("%%%%%%%% PATHS FROM  %%%%%%%%%%%%");
            System.out.println(source);
            KShortestPaths<OperationMetadata, OperationRelationshipEdge<String>> paths = ServiceMetadata
                    .getOperationPaths(directedGraph, source, 10);

            for (OperationMetadata sink : sinkOperations) {
                System.out.print(" %%%%%%%%%%%% TO ");
                System.out.println(sink);
                List<GraphPath<OperationMetadata, OperationRelationshipEdge<String>>> listPath = ServiceMetadata
                        .getOperationPaths(paths, sink);
                for (GraphPath<OperationMetadata, OperationRelationshipEdge<String>> gp : listPath) {
                    System.out.println(gp.getEdgeList());
                }
            }

        }

        // // Prints the shortest path from vertex i to vertex c. This certainly
        // // exists for our particular directed graph.
        // System.out.println("Shortest path from i to c:");
        // List path = DijkstraShortestPath.findPathBetween(directedGraph, "i", "c");
        // System.out.println(path + "\n");

        // // Prints the shortest path from vertex c to vertex i. This path does
        // // NOT exist for our particular directed graph. Hence the path is
        // // empty and the variable "path" must be null.
        // System.out.println("Shortest path from c to i:");
        // path = DijkstraShortestPath.findPathBetween(directedGraph, "c", "i");
        // System.out.println(path);

    } catch (MotuException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (MotuMarshallException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}