Example usage for java.util Set remove

List of usage examples for java.util Set remove

Introduction

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

Prototype

boolean remove(Object o);

Source Link

Document

Removes the specified element from this set if it is present (optional operation).

Usage

From source file:com.espertech.esper.epl.variable.VariableServiceImpl.java

public void unregisterCallback(int variableNumber, VariableChangeCallback variableChangeCallback) {
    Set<VariableChangeCallback> callbacks = changeCallbacks.get(variableNumber);
    if (callbacks != null) {
        callbacks.remove(variableChangeCallback);
    }/*from  w  w  w. j  ava  2 s . c  o m*/
}

From source file:com.almende.dht.rpc.DHT.java

/**
 * Delete a specific value from this key.
 *
 * @param key/* w w  w .j  a  v  a2 s  .  c  o  m*/
 *            the key
 * @param value
 *            the value
 * @param remote
 *            the remote
 * @param sender
 *            the sender
 */
@Access(AccessType.PUBLIC)
public void delete(@Name("key") Key key, @Name("value") ObjectNode value, @Name("me") Key remote,
        @Sender URI sender) {
    rt.seenNode(new Node(remote, sender));
    if (values.containsKey(key)) {
        Set<TimedValue> current = values.remove(key);
        TimedValue tv = new TimedValue(value);

        current.remove(tv);
        if (current.size() > 0) {
            values.put(key, current);
        }
    }

}

From source file:com.gst.accounting.rule.service.AccountingRuleWritePlatformServiceJpaRepositoryImpl.java

private Set<String> determineCreditTagToAddAndRemoveOldTags(final String[] creditOrDebitTags,
        final JournalEntryType type, final AccountingRule accountingRule) {

    final Set<String> incomingTags = new HashSet<>(Arrays.asList(creditOrDebitTags));
    final Set<AccountingTagRule> existingTags = accountingRule.getAccountingTagRulesByType(type);
    final Set<String> existingTagIds = retrieveExistingTagIds(existingTags);
    final Set<String> tagsToAdd = new HashSet<>();
    final Set<String> tagsToRemove = existingTagIds;
    final Map<Long, AccountingTagRule> accountsToRemove = new HashMap<>();

    for (final String tagId : incomingTags) {
        if (existingTagIds.contains(tagId)) {
            tagsToRemove.remove(tagId);
        } else {//from  w  w  w  .  j av  a 2s . c o  m
            tagsToAdd.add(tagId);
        }
    }

    if (!tagsToRemove.isEmpty()) {
        for (final String tagId : tagsToRemove) {
            for (final AccountingTagRule accountingTagRule : existingTags) {
                if (tagId.equals(accountingTagRule.getTagId().toString())) {
                    accountsToRemove.put(accountingTagRule.getId(), accountingTagRule);
                }
            }
        }
        accountingRule.removeOldTags(new ArrayList<>(accountsToRemove.values()));
    }
    return tagsToAdd;
}

From source file:com.gargoylesoftware.htmlunit.general.HostTestsTest.java

/**
 * @throws Exception if an error occurs/*w w  w  .j a  v  a 2 s.  c o  m*/
 */
@Test
public void test() throws Exception {
    final Set<String> set = new HashSet<>();
    final File testRoot = new File("src/test/java");
    collectionObjectNames(testRoot, set);

    // Remove all Prototypes, as we plan to have test cases separate for them soon
    // TODO: add Prototype tests (e.g. alert(Element.prototype)
    for (final Iterator<String> it = set.iterator(); it.hasNext();) {
        if (it.next().endsWith("Prototype")) {
            it.remove();
        }
    }
    if (set.contains("Arguments")) {
        set.remove("Arguments");
        set.add("arguments");
    }
    set.remove("DedicatedWorkerGlobalScope");
    set.remove("WorkerGlobalScope");

    ensure(new File(testRoot, HostClassNameTest.class.getName().replace('.', '/') + ".java"), set);
    ensure(new File(testRoot, HostTypeOfTest.class.getName().replace('.', '/') + ".java"), set);
}

From source file:com.netflix.genie.core.jpa.services.JpaClusterServiceImpl.java

/**
 * {@inheritDoc}/*from www  .j  av a 2s.  c  o  m*/
 */
@Override
public void deleteCluster(@NotBlank(message = "No id entered unable to delete.") final String id)
        throws GenieException {
    log.debug("Called");
    final ClusterEntity clusterEntity = this.findCluster(id);
    final List<CommandEntity> commandEntities = clusterEntity.getCommands();
    if (commandEntities != null) {
        for (final CommandEntity commandEntity : commandEntities) {
            final Set<ClusterEntity> clusterEntities = commandEntity.getClusters();
            if (clusterEntities != null) {
                clusterEntities.remove(clusterEntity);
            }
            this.commandRepo.save(commandEntity);
        }
    }
    this.clusterRepo.delete(clusterEntity);
}

From source file:io.syndesis.controllers.integration.IntegrationController.java

void callStatusChangeHandler(StatusChangeHandlerProvider.StatusChangeHandler handler,
        String integrationId) {/*from  ww w. j  a  v  a 2s .  co  m*/
    executor.submit(() -> {
        Integration integration = dataManager.fetch(Integration.class, integrationId);
        String checkKey = getIntegrationMarkerKey(integration);
        scheduledChecks.add(checkKey);

        if (stale(handler, integration)) {
            scheduledChecks.remove(checkKey);
            return;
        }

        try {
            LOG.info("Integration {} : Start processing integration with {}", integrationId,
                    handler.getClass().getSimpleName());
            StatusChangeHandlerProvider.StatusChangeHandler.StatusUpdate update = handler.execute(integration);
            if (update != null) {
                if (LOG.isInfoEnabled()) {
                    LOG.info("{} : Setting status to {}{}", getLabel(integration), update.getStatus(),
                            (update.getStatusMessage() != null ? " (" + update.getStatusMessage() + ")" : ""));
                }

                // handler.execute might block for while so refresh our copy of the integration
                // data before we update the current status

                // TODO: do this in a single TX.
                Date now = new Date();
                Integration current = dataManager.fetch(Integration.class, integrationId);
                Integration updated = new Integration.Builder().createFrom(current)
                        .currentStatus(update.getStatus()) // Status must not be null
                        .statusMessage(Optional.ofNullable(update.getStatusMessage()))
                        .stepsDone(update.getStepsPerformed())
                        .createdDate(Integration.Status.Activated.equals(update.getStatus()) ? now
                                : integration.getCreatedDate().get())
                        .lastUpdated(new Date()).build();

                Set<IntegrationRevision> revisions = new HashSet<>(integration.getRevisions());
                IntegrationRevision revision = IntegrationRevision.deployedRevision(integration)
                        .withCurrentState(IntegrationRevisionState.from(update.getStatus()));

                //replace revision
                revisions.remove(revision);

                final IntegrationRevision last = integration.lastRevision();
                if (IntegrationRevisionState.from(update.getStatus()).equals(last.getCurrentState())) {
                    revision = new IntegrationRevision.Builder().createFrom(revision).version(last.getVersion())
                            .parentVersion(last.getParentVersion()).build();
                }
                revisions.add(revision);

                dataManager.update(new Integration.Builder().createFrom(updated).revisions(revisions).build());
            }

        } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") Exception e) {
            LOG.error("Error while processing integration status for integration {}", integrationId, e);
            // Something went wrong.. lets note it.
            Integration current = dataManager.fetch(Integration.class, integrationId);
            dataManager.update(new Integration.Builder().createFrom(current).statusMessage("Error: " + e)
                    .lastUpdated(new Date()).build());

        } finally {
            // Add a next check for the next interval
            reschedule(integrationId);
        }

    });
}

From source file:com.fastbootmobile.encore.framework.ListenLogger.java

private void removeLikingImpl(Song song, String entrySet) {
    SharedPreferences.Editor editor = mPrefs.edit();
    Set<String> entries = new TreeSet<>(mPrefs.getStringSet(entrySet, new TreeSet<String>()));

    JSONObject jsonRoot = new JSONObject();
    try {//from  ww w . ja  v  a 2s .  c om
        jsonRoot.put(KEY_SONG_REF, song.getRef());
        jsonRoot.put(KEY_PROVIDER, song.getProvider().serialize());
    } catch (JSONException ignore) {
    }

    entries.remove(jsonRoot.toString());
    editor.putStringSet(entrySet, entries);
    editor.apply();
}

From source file:herddb.model.Transaction.java

public synchronized void registerInsertOnTable(String tableName, Bytes key, Bytes value,
        CommitLogResult writeResult) {//from  w w w.  ja v a2s .co  m
    if (updateLastSequenceNumber(writeResult)) {
        return;
    }

    Set<Bytes> deleted = deletedRecords.get(tableName);
    if (deleted != null) {
        boolean removed = deleted.remove(key);
        if (removed) {
            // special pattern:
            // DELETE - INSERT
            // it can be converted to an UPDATE in memory
            registerRecordUpdate(tableName, key, value, writeResult);
            return;
        }
    }

    Map<Bytes, Record> ll = newRecords.get(tableName);
    if (ll == null) {
        ll = new HashMap<>();
        newRecords.put(tableName, ll);
    }
    ll.put(key, new Record(key, value));

}

From source file:org.schedoscope.metascope.controller.MetascopeTableController.java

/**
 * Detail view of a table; path = '/table'
 *
 * @param request the HTTPServletRequest from the client
 * @return the table detail view//w  w w  .j av a2s  .c o  m
 */
@RequestMapping(value = "/table", method = RequestMethod.GET)
@Transactional
public ModelAndView getTable(HttpServletRequest request) {
    ModelAndView mav = new ModelAndView("body/table/table");

    /* load table from repository */
    String fqdn = getParameter(request, "fqdn");
    MetascopeTable tableEntity = metascopeTableService.findByFqdn(fqdn);
    if (tableEntity == null) {
        return new ModelAndView(new RedirectView("/notfound"));
    }

    /* retrieve requested page for partitions section */
    String partitionPageParameter = getParameter(request, "partitionPage");
    int partitionPage = 1;
    if (partitionPageParameter != null) {
        Integer p = ParseUtil.tryParse(partitionPageParameter);
        if (p != null && p > 0) {
            partitionPage = p;
        }
    }

    /* get all taxonomies */
    Iterable<MetascopeTaxonomy> taxonomies = metascopeTaxonomyService.getTaxonomies();
    List<String> taxonomyNames = new ArrayList<String>();
    for (MetascopeTaxonomy taxonomyEntity : taxonomies) {
        taxonomyNames.add(taxonomyEntity.getName());
    }

    Map<String, Map<String, List<MetascopeField>>> fieldDeps = metascopeTableService
            .getFieldDependencies(tableEntity);
    Map<String, Map<String, List<MetascopeField>>> fieldSucs = metascopeTableService
            .getFieldSuccessors(tableEntity);

    Map<String, CategoryMap> tableTaxonomies = metascopeTableService.getTableTaxonomies(tableEntity);

    /* get all users for user management and owner auto completion */
    Iterable<MetascopeUser> users = metascopeUserService.getAllUser();

    /* get all registered table owners for auto completion */
    Set<String> owner = metascopeTableService.getAllOwner();
    owner.remove(null);
    for (MetascopeUser user : users) {
        if (!owner.contains(user.getFullname())) {
            owner.add(user.getFullname());
        }
    }

    /* check data distribution calculation status */
    MetascopeDataDistributionService.Status dataDistStatus = metascopeDataDistributionService
            .checkStatus(tableEntity);
    if (dataDistStatus.equals(MetascopeDataDistributionService.Status.Finished)) {
        mav.addObject("ddMap", metascopeDataDistributionService.getDataDistribution(tableEntity));
    }

    /* check if this user is an admin */
    boolean isAdmin = metascopeUserService.isAdmin();

    /* check if this table is favourised */
    boolean isFavourite = metascopeUserService.isFavourite(tableEntity);

    boolean transitive = getParameter(request, "transitive") != null;
    if (transitive) {
        /* get transitive dependencies and successors */
        List<MetascopeTable> transitiveDependencies = metascopeTableService
                .getTransitiveDependencies(tableEntity);
        List<MetascopeTable> transitiveSuccessors = metascopeTableService.getTransitiveSuccessors(tableEntity);
        mav.addObject("transitiveDependencies", transitiveDependencies);
        mav.addObject("transitiveSuccessors", transitiveSuccessors);
    }

    /*
     * if table is partitioned, get the first parameter (see 'Data Distribution'
     * section)
     */
    Set<MetascopeField> parameters = tableEntity.getParameters();
    if (parameters.size() > 0) {
        mav.addObject("firstParam", parameters.iterator().next().getFieldName());
    }

    /* check if a draft autosave is available */
    boolean metascopeAutoSave = metascopeDocumentationService.checkForDraft(tableEntity,
            metascopeUserService.getUser());

    /* check if the responsible person has been changed */
    String personResponsible = getParameter(request, "personResponsible");

    /* check if the docuemntation has been changed */
    String documentation = getParameter(request, "documentation");

    /* check if a comment has been created/edited/deleted */
    String comment = getParameter(request, "comment");

    /* check if the taxonomy has been changed */
    String taxonomy = getParameter(request, "taxonomy");

    /*
     * local parameter indicates if the css and javascript should be containted
     * in the html. this can be useful when displaying views in third party
     * sites and apps
     */
    boolean local = getParameter(request, "local") != null;

    /* search result breadcrumb */
    String referer = request.getHeader("Referer");
    String searchResultBreadcrumb = null;
    if (referer != null) {
        String refererSplit[] = request.getHeader("Referer").split("\\?");
        if (refererSplit.length == 2 && refererSplit[0].contains("home")
                && hasSearchParameters(refererSplit[1])) {
            searchResultBreadcrumb = referer;
        }
    }

    /* make objects accessible for thymeleaf to render final view */
    mav.addObject("table", tableEntity);
    mav.addObject("userEntityService", metascopeUserService);
    mav.addObject("util", htmlUtil);
    mav.addObject("local", local);
    mav.addObject("partitionPage", partitionPage);
    mav.addObject("users", users);
    mav.addObject("owner", owner);
    mav.addObject("fieldDependencyMap", fieldDeps);
    mav.addObject("fieldSuccessorMap", fieldSucs);
    mav.addObject("taxonomies", taxonomies);
    mav.addObject("taxonomyNames", taxonomyNames);
    mav.addObject("tableTaxonomies", tableTaxonomies);
    mav.addObject("admin", isAdmin);
    mav.addObject("draft", metascopeAutoSave);
    mav.addObject("isFavourite", isFavourite);
    mav.addObject("personResponsible", personResponsible);
    mav.addObject("documentation", documentation);
    mav.addObject("comment", comment);
    mav.addObject("taxonomy", taxonomy);
    mav.addObject("dataDistStatus", dataDistStatus.name().toLowerCase());
    mav.addObject("searchResultBreadcrumb", searchResultBreadcrumb);
    mav.addObject("userMgmnt", config.withUserManagement());

    return mav;
}

From source file:org.jahia.modules.bootstrap.rules.BootstrapCompiler.java

public void compileBootstrapWithVariables(JCRSiteNode site, String variables)
        throws RepositoryException, IOException, LessException {
    if (module == null) {
        return;/*from   ww  w.  j  a v  a 2 s  . c  om*/
    }

    Set<JahiaTemplatesPackage> packages = new TreeSet<JahiaTemplatesPackage>(
            TemplatePackageRegistry.TEMPLATE_PACKAGE_COMPARATOR);
    for (String s : site.getInstalledModulesWithAllDependencies()) {
        packages.add(jahiaTemplateManagerService.getTemplatePackageById(s));
    }
    packages.remove(module);
    ArrayList<Resource> lessResources = new ArrayList<Resource>();
    for (JahiaTemplatesPackage aPackage : packages) {
        lessResources.addAll(Arrays.asList(aPackage.getResources(LESS_RESOURCES_FOLDER)));
    }
    lessResources.addAll(Arrays.asList(module.getResources(LESS_RESOURCES_FOLDER)));
    compileBootstrap(site, lessResources, variables);
}