Example usage for java.util Set toString

List of usage examples for java.util Set toString

Introduction

In this page you can find the example usage for java.util Set toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.apache.sentry.policy.search.AbstractTestSearchPolicyEngine.java

@Test
public void testAnalyst() throws Exception {
    Set<String> expected = Sets.newTreeSet(Sets.newHashSet(ANALYST_PURCHASES_UPDATE, ANALYST_ANALYST1_ALL,
            ANALYST_JRANALYST1_ACTION_ALL, ANALYST_TMPCOLLECTION_UPDATE, ANALYST_TMPCOLLECTION_QUERY));
    Assert.assertEquals(expected.toString(),
            new TreeSet<String>(policy.getPrivileges(set("analyst"), ActiveRoleSet.ALL)).toString());
}

From source file:ubic.pubmedgate.resolve.focusedAnalysis.FindUnMappedNeuroNamesForNIF.java

public void populate() throws Exception {
    MakeLexiconRDFModel lexiconModel = new MakeLexiconRDFModel();
    lexiconModel.addNIFSTDNodes();//w  w  w. j  ava2s .c  o  m

    boolean reason = true;
    ResolutionRDFModel resolutionModel = new ResolutionRDFModel(lexiconModel.getModel(), reason);

    resolutionModel.loadManualMatches();
    resolutionModel.loadManualEvaluations();

    ResolutionRDFModel resolutionForNeuroNames = new ResolutionRDFModel();
    resolutionForNeuroNames.getStats();

    Set<Resource> allTerms = resolutionModel.getTerms(); // for speed
    Set<Resource> allConcepts = resolutionModel.getConcepts(); // for speed

    RDFResolver resolver;
    resolver = new BagOfStemsRDFMatcher(resolutionModel.getTerms());
    resolver.addMentionEditor(new DirectionSplittingMentionEditor());
    resolver.addMentionEditor(new HemisphereStripMentionEditor());
    resolver.addMentionEditor(new BracketRemoverMentionEditor());
    resolver.addMentionEditor(new OfTheRemoverMentionEditor());
    resolver.addMentionEditor(new CytoPrefixMentionEditor());
    resolver.addMentionEditor(new RegionSuffixRemover());

    int rejectedMatches = 0;
    int resolved = 0;
    int row = 1;
    Set<Resource> allNNConcepts = resolutionForNeuroNames.getNNConcepts(); // for speed
    for (Resource NNConcept : allNNConcepts) {
        String NNConceptLabel = JenaUtil.getLabel(NNConcept);
        if (row % 100 == 0)
            log.info("Row:" + row);
        Set<Resource> NNTerms = resolutionForNeuroNames.getTermsFromConcepts(NNConcept);
        for (Resource NNTerm : NNTerms) {
            String NNTermString = JenaUtil.getLabel(NNTerm);
            Set<Resource> regionResolves = resolutionModel.resolveToTerms(NNTermString, resolver, allTerms);

            StringToStringSetMap URItoTerms = new StringToStringSetMap();
            Set<Resource> allResolvedConcepts = new HashSet<Resource>();

            for (Resource resolvedTerm : regionResolves) {
                Set<Resource> concepts = resolutionModel.getConceptsFromTerms(resolvedTerm, allConcepts);
                for (Resource regionConcept : concepts) {
                    if (resolutionModel.rejected(resolvedTerm, regionConcept)) {
                        log.info("Rejected match");
                        rejectedMatches++;
                        continue;
                    }

                    allResolvedConcepts.add(regionConcept);
                    URItoTerms.put(regionConcept.getURI(), JenaUtil.getLabel(resolvedTerm));
                }
            }
            // can match to more than one NIFSTD concept, present each on new row?
            if (allResolvedConcepts.isEmpty()) {
                ExcelUtil.setValue(spreadsheet, row, schema.getPosition("NeuronameTerm"), NNTermString);
                ExcelUtil.setValue(spreadsheet, row, schema.getPosition("NeuronameConceptLabel"),
                        NNConceptLabel);
                ExcelUtil.setValue(spreadsheet, row, schema.getPosition("NeuronameConceptURI"),
                        NNConcept.getURI());
                row++;
            } else {
                resolved++;
                // for ( Resource resolvedTerm : regionResolves ) {
                // Set<Resource> concepts = resolutionModel.getConceptsFromTerms( resolvedTerm, NIFConcepts );
                for (Resource regionConcept : allResolvedConcepts) {
                    ExcelUtil.setValue(spreadsheet, row, schema.getPosition("NeuronameTerm"), NNTermString);
                    ExcelUtil.setValue(spreadsheet, row, schema.getPosition("NeuronameConceptLabel"),
                            NNConceptLabel);
                    ExcelUtil.setValue(spreadsheet, row, schema.getPosition("NeuronameConceptURI"),
                            NNConcept.getURI());

                    // ExcelUtil.setValue( spreadsheet, row, schema.getPosition( "database" ), source );
                    // ExcelUtil.setValue( spreadsheet, row, schema.getPosition( "con_from_abb" ), line[1] );
                    // ExcelUtil.setValue( spreadsheet, row, schema.getPosition( "con_from" ), line[2] );
                    // ExcelUtil.setValue( spreadsheet, row, schema.getPosition( "RegionName" ), regionName );

                    Set<String> matchedTerms = URItoTerms.get(regionConcept.getURI());
                    String matchedTermsString = matchedTerms.toString();
                    matchedTermsString = matchedTermsString.substring(1, matchedTermsString.length() - 1);

                    String resolvedRegionLabel = JenaUtil.getLabel(regionConcept);

                    ExcelUtil.setValue(spreadsheet, row, schema.getPosition("MatchedTerm"), matchedTermsString);
                    ExcelUtil.setValue(spreadsheet, row, schema.getPosition("NIFSTDConceptLabel"),
                            resolvedRegionLabel);
                    ExcelUtil.setValue(spreadsheet, row, schema.getPosition("ExactMatch"), matchedTermsString);
                    ExcelUtil.setValue(spreadsheet, row, schema.getPosition("NIFSTDURI"),
                            regionConcept.getURI());

                    boolean exactMatch = false;
                    for (String termString : matchedTerms) {
                        if (NNTermString.equalsIgnoreCase(termString)) {
                            exactMatch = true;
                            break;
                        }
                    }

                    ExcelUtil.setValue(spreadsheet, row, schema.getPosition("ExactMatch"), exactMatch + "");

                    row++;
                }

            }

        }
    }
    log.info("Rejected matches:" + rejectedMatches);
    log.info("Resolved:" + resolved);

}

From source file:org.slc.sli.api.security.context.validator.StaffToStudentValidator.java

@Override
public Set<String> getValid(String entityType, Set<String> studentIds) {
    LOG.trace(">>>StaffToStudentValidator.getValid(?)", entityType);
    LOG.debug("  studentIds: {}", (studentIds == null) ? "null" : studentIds.toString());

    // first check if the entire set is valid. if not, check id by id.
    //return (validate(entityType, studentIds)) ? studentIds : super.getValid(entityType, studentIds);
    return validate(entityType, studentIds);
}

From source file:com.opengamma.integration.viewer.status.impl.ViewStatusCalculationWorker.java

public ViewStatusCalculationWorker(final ToolContext toolContext, UniqueId portfolioId,
        final ViewStatusOption option, final ExecutorService executorService) {
    ArgumentChecker.notNull(toolContext, "toolContex");
    ArgumentChecker.notNull(portfolioId, "portfolioId");
    ArgumentChecker.notNull(option, "option");
    ArgumentChecker.notNull(option.getUser(), "option.user");
    ArgumentChecker.notNull(option.getMarketDataSpecification(), "option.marketDataSpecification");
    ArgumentChecker.notNull(executorService, "executorService");

    validateComponentsInToolContext(toolContext);
    _portfolioId = portfolioId;/*from   w w w  .ja  v a 2s .  c  o m*/
    _user = option.getUser();
    _marketDataSpecification = option.getMarketDataSpecification();
    Map<String, Collection<String>> valueRequirementBySecType = scanValueRequirementBySecType(portfolioId,
            toolContext);
    if (s_logger.isDebugEnabled()) {
        StringBuilder strBuf = new StringBuilder();
        for (String securityType : Sets.newTreeSet(valueRequirementBySecType.keySet())) {
            Set<String> valueNames = Sets.newTreeSet(valueRequirementBySecType.get(securityType));
            strBuf.append(
                    String.format("%s\t%s\n", StringUtils.rightPad(securityType, 40), valueNames.toString()));
        }
        s_logger.debug("\n{}\n", strBuf.toString());
    }
    _toolContext = toolContext;
    _executor = executorService;
    _valueRequirementBySecType = valueRequirementBySecType;
}

From source file:com.google.enterprise.connector.ldap.LdapConnectorConfig.java

/**
 * Assigns value to schemavalue from config form. Adds DN_ATTRIBUTE if not
 * present already./* w  w w . j av  a2s. c o m*/
 * 
 * @param config Config values entered on the form
 * @return SchemaValue in as String
 */
static String getSchemaValueFromConfig(Map<String, String> config) {

    String configSchemaValue = null;
    LOG.fine("Original SchemaValue - " + config.get(ConfigName.SCHEMAVALUE.toString()));

    Set<String> schemaValue = new TreeSet<String>();
    LOG.fine("Trying to recover attributes from schema checkboxes");
    StringBuffer schemaKey = new StringBuffer();
    schemaKey.append(ConfigName.SCHEMA.toString()).append("_").append("\\d");
    Pattern keyPattern = Pattern.compile(schemaKey.toString());
    Set<String> configKeySet = config.keySet();

    for (String configKey : configKeySet) {
        Matcher matcher = keyPattern.matcher(configKey);
        if (matcher.find()) {
            String schemaAttribute = config.get(configKey);
            if (schemaAttribute != null && schemaAttribute.trim().length() != 0) {
                schemaValue.add(config.get(configKey));
            }
        }
    }

    // always add dn attribute to schema. 'dn' checkbox is hidden so can't be 
    // read and added to schemaValue in the code above.
    schemaValue.add(LdapHandler.DN_ATTRIBUTE);

    try {
        configSchemaValue = (new JSONArray(schemaValue.toString())).toString();
        LOG.fine("From config SchemaValue - " + configSchemaValue);

    } catch (JSONException e) {
        LOG.log(Level.WARNING, "JSONException trace:", e);
    }

    return configSchemaValue;
}

From source file:org.eurekastreams.server.persistence.mappers.cache.SaveOrganizationCoordinatorIdsToCache.java

/**
 * Save a set of coordinator person ids for an organization in cache.
 * /*w  ww. java  2  s.  c o m*/
 * @param inRequest
 *            the SaveOrganizationCoordinatorIdsToCacheRequest
 * @return True if successful.
 */
@Override
public Boolean execute(final OrganizationCacheUpdaterRequest inRequest) {
    Long orgId = inRequest.getOrganizationId();
    Set<Long> coordIds = inRequest.getCoordinatorIds();
    Set<Long> origCoordIds = inRequest.getOriginalCoordinatorIds() == null ? new HashSet<Long>(0)
            : inRequest.getOriginalCoordinatorIds();

    log.info("Saving org #" + orgId + "'s cordinators to cache - coordinator ids: " + coordIds.toString());
    getCache().set(CacheKeys.ORGANIZATION_COORDINATORS_BY_ORG_ID + inRequest.getOrganizationId(),
            inRequest.getCoordinatorIds());

    // update orgs directly coordinated by people cache keys.
    // do additions
    for (Long newId : coordIds) {
        if (!origCoordIds.contains(newId)) {
            getCache().addToSet(CacheKeys.ORG_IDS_DIRECTLY_COORD_BY_PERSON + newId, orgId);
        }
    }

    // do removes
    for (Long origId : origCoordIds) {
        if (!coordIds.contains(origId)) {
            getCache().removeFromSet(CacheKeys.ORG_IDS_DIRECTLY_COORD_BY_PERSON + origId, orgId);
        }
    }

    return true;
}

From source file:com.abixen.platform.module.chart.service.impl.AbstractDatabaseService.java

private String buildQueryForChartData(DatabaseDataSource databaseDataSource, Set<String> chartColumnsSet) {
    StringBuilder stringBuilder = new StringBuilder("SELECT ");
    stringBuilder.append(chartColumnsSet.toString().substring(1, chartColumnsSet.toString().length() - 1));
    stringBuilder.append(" FROM ");
    stringBuilder.append(databaseDataSource.getTable());
    return stringBuilder.toString();
}

From source file:org.jasig.cas.remoting.server.RemoteCentralAuthenticationService.java

/**
 * Check for errors by asking the validator to review each credential.
 *
 * @param credentials the credentials/*from  ww  w  . ja v a  2 s.co  m*/
 */
private void checkForErrors(final Credential... credentials) {
    if (credentials == null) {
        return;
    }

    for (final Credential c : credentials) {
        final Set<ConstraintViolation<Credential>> errors = this.validator.validate(c);
        if (!errors.isEmpty()) {
            throw new IllegalArgumentException("Error validating credentials: " + errors.toString());
        }
    }
}

From source file:com.mapr.synth.samplers.FlattenSamplerTest.java

@Test
public void testEmptyPrefix() throws IOException {
    SchemaSampler s = new SchemaSampler(
            Resources.asCharSource(Resources.getResource("schema023.json"), Charsets.UTF_8).read());
    JsonNode v = s.sample();/*from   w  w w. ja va2 s .c o  m*/
    Set<String> names = Sets.newTreeSet();
    Iterators.addAll(names, v.fieldNames());
    assertEquals(
            "[city, decommisioned, estimatedPopulation, latitude, location, locationType, longitude, state, "
                    + "taxReturnsFiled, totalWages, zip, zipType]",
            names.toString());
}

From source file:org.deeplearning4j.nn.modelimport.keras.layers.convolutional.KerasConvolution.java

/**
 * Set weights for layer./*from w w w. ja v  a2s.c om*/
 *
 * @param weights   Map from parameter name to INDArray.
 */
@Override
public void setWeights(Map<String, INDArray> weights) throws InvalidKerasConfigurationException {
    this.weights = new HashMap<String, INDArray>();
    if (weights.containsKey(conf.getKERAS_PARAM_NAME_W())) {
        /* Theano and TensorFlow backends store convolutional weights
         * with a different dimensional ordering than DL4J so we need
         * to permute them to match.
         *
         * DL4J: (# outputs, # inputs, # rows, # cols)
         */
        INDArray kerasParamValue = weights.get(conf.getKERAS_PARAM_NAME_W());
        INDArray paramValue;
        switch (this.getDimOrder()) {
        case TENSORFLOW:
            /* TensorFlow convolutional weights: # rows, # cols, # inputs, # outputs */
            paramValue = kerasParamValue.permute(3, 2, 0, 1);
            break;
        case THEANO:
            /* Theano convolutional weights match DL4J: # outputs, # inputs, # rows, # cols
             * Theano's default behavior is to rotate filters by 180 degree before application.
             */
            paramValue = kerasParamValue.dup();
            for (int i = 0; i < paramValue.tensorssAlongDimension(2, 3); i++) {
                //dup required since we only want data from the view not the whole array
                INDArray copyFilter = paramValue.tensorAlongDimension(i, 2, 3).dup();
                double[] flattenedFilter = copyFilter.ravel().data().asDouble();
                ArrayUtils.reverse(flattenedFilter);
                INDArray newFilter = Nd4j.create(flattenedFilter, copyFilter.shape());
                //manipulating weights in place to save memory
                INDArray inPlaceFilter = paramValue.tensorAlongDimension(i, 2, 3);
                inPlaceFilter.muli(0).addi(newFilter);
            }
            break;
        default:
            throw new InvalidKerasConfigurationException("Unknown keras backend " + this.getDimOrder());
        }
        this.weights.put(ConvolutionParamInitializer.WEIGHT_KEY, paramValue);
    } else
        throw new InvalidKerasConfigurationException(
                "Parameter " + conf.getKERAS_PARAM_NAME_W() + " does not exist in weights");

    if (hasBias) {
        if (weights.containsKey(conf.getKERAS_PARAM_NAME_B()))
            this.weights.put(ConvolutionParamInitializer.BIAS_KEY, weights.get(conf.getKERAS_PARAM_NAME_B()));
        else
            throw new InvalidKerasConfigurationException(
                    "Parameter " + conf.getKERAS_PARAM_NAME_B() + " does not exist in weights");
    }
    if (weights.size() > 2) {
        Set<String> paramNames = weights.keySet();
        paramNames.remove(conf.getKERAS_PARAM_NAME_W());
        paramNames.remove(conf.getKERAS_PARAM_NAME_B());
        String unknownParamNames = paramNames.toString();
        log.warn("Attemping to set weights for unknown parameters: "
                + unknownParamNames.substring(1, unknownParamNames.length() - 1));
    }
}