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.sshdemo.common.report.manage.service.ChartReportService.java

@Override
public void delChartReport(Long chartReportId) {
    ChartReport chartReport = chartReportDAO.get(chartReportId);
    Assert.notNull(chartReport);//from w  w w  .j  a v  a  2s.c  o  m
    List<CategoryReport> categories = chartReportDAO.findCategoryReportByChartReportId(chartReportId);
    if (categories != null && !categories.isEmpty()) {
        for (CategoryReport categoryReport : categories) {
            Set<ChartReport> chartReports = categoryReport.getCharts();
            if (chartReports.isEmpty())
                continue;
            chartReports.remove(chartReport);
            categoryReport.setCharts(chartReports);
            categorReportDAO.merge(categoryReport);
        }
    }
    List<EwcmsJobReport> ewcmsJobReports = chartReportDAO.findEwcmsJobReportByChartReportId(chartReportId);
    if (ewcmsJobReports != null && !ewcmsJobReports.isEmpty()) {
        for (EwcmsJobReport ewcmsJobReport : ewcmsJobReports) {
            if (ewcmsJobReport.getTextReport() == null) {
                ewcmsJobReportDAO.remove(ewcmsJobReport);
            } else {
                ewcmsJobReport.setChartReport(null);
                ewcmsJobReportDAO.merge(ewcmsJobReport);
            }
        }
    }
    chartReportDAO.removeByPK(chartReportId);
}

From source file:de.dal33t.powerfolder.util.collection.CompositeSet.java

/**
 * If a <code>CollectionMutator</code> is defined for this CompositeSet then
 * this method will be called anyway./*from   w  w w. ja v a2  s  .  c  o m*/
 *
 * @param obj
 *            Object to be removed
 * @return true if the object is removed, false otherwise
 */
public boolean remove(Object obj) {
    for (Iterator i = this.getCollections().iterator(); i.hasNext();) {
        Set set = (Set) i.next();
        if (set.contains(obj))
            return set.remove(obj);
    }
    return false;
}

From source file:org.ambraproject.journal.JournalServiceImpl.java

/**
 * Get the set of all the known journals.
 *
 * @return all the journals, or the empty set if there are none
 *///from   www  . ja v a2  s .  c om
@Transactional(readOnly = true)
public Set<Journal> getAllJournals() {
    Set<Journal> res = new HashSet<Journal>();
    for (String jName : getAllJournalNames())
        res.add(getJournal(jName));

    res.remove(null); // in case something got deleted from under us
    return res;
}

From source file:com.thoughtworks.go.buildsession.ExecCommandExecutor.java

@Override
public boolean execute(BuildCommand command, BuildSession buildSession) {
    File workingDir = buildSession.resolveRelativeDir(command.getWorkingDirectory());
    if (!workingDir.isDirectory()) {
        String message = "Working directory \"" + workingDir.getAbsolutePath() + "\" is not a directory!";
        LOG.error(message);/*from  ww w . jav a 2s. c om*/
        buildSession.println(message);
        return false;
    }

    String cmd = command.getStringArg("command");
    String[] args = command.getArrayArg("args");

    Map<String, String> secrets = buildSession.getSecretSubstitutions();
    Set<String> leftSecrets = new HashSet<>(secrets.keySet());

    CommandLine commandLine = createCommandLine(cmd);

    for (String arg : args) {
        if (secrets.containsKey(arg)) {
            leftSecrets.remove(arg);
            commandLine.withArg(new SubstitutableCommandArgument(arg, secrets.get(arg)));
        } else {
            commandLine.withArg(arg);
        }
    }

    for (String secret : leftSecrets) {
        commandLine.withNonArgSecret(new SecretSubstitution(secret, secrets.get(secret)));
    }

    commandLine.withWorkingDir(workingDir);
    commandLine.withEnv(buildSession.getEnvs());

    return executeCommandLine(buildSession, commandLine) == 0;
}

From source file:org.magnum.mobilecloud.video.MainController_HW_2.java

@RequestMapping(value = "/video/{id}/unlike", method = RequestMethod.POST)
public @ResponseBody ResponseEntity<Void> unlikeVideo(@PathVariable("id") long id, Principal p) {

    if (videos.findOne(id) == null) {
        return new ResponseEntity<Void>(HttpStatus.BAD_REQUEST);
    }//ww w  . j a v  a  2  s.  c  om

    String username = p.getName();
    Video v = videos.findOne(id);
    Set<String> likesUsernames = (Set<String>) v.getLikesUsernames();

    // Checks if the user has already liked the video.
    if (likesUsernames.contains(username)) {
        likesUsernames.remove(username);
        v.setLikesUsernames(likesUsernames);
        v.setLikes(likesUsernames.size());
        videos.save(v);

        return new ResponseEntity<Void>(HttpStatus.OK);
    }
    //videos.save(v);
    return new ResponseEntity<Void>(HttpStatus.BAD_REQUEST);
}

From source file:de.hybris.platform.b2bacceleratorservices.company.impl.DefaultB2BCommerceUnitService.java

@Override
public B2BCustomerModel removeApproverFromUnit(final String unitUid, final String approverUid) {
    final B2BUnitModel unit = this.getUnitForUid(unitUid);
    final Set<B2BCustomerModel> approvers = new HashSet<B2BCustomerModel>(unit.getApprovers());
    final B2BCustomerModel approver = getCustomerForUid(approverUid);
    approvers.remove(approver);
    unit.setApprovers(approvers);/*from w  w w .  j a  v a  2  s .c om*/
    this.getModelService().saveAll(approver, unit);
    return approver;
}

From source file:org.duracloud.account.db.util.impl.RootAccountManagerServiceImpl.java

@Override
public void deleteUser(Long userId) {
    log.info("Deleting user with ID {}", userId);

    // Remove all user rights
    List<AccountRights> accountRights = getRightsRepo().findByUserId(userId);
    for (AccountRights right : accountRights) {
        this.userService.revokeUserRights(right.getAccount().getId(), userId);
    }/*from w  w  w  .j a  v  a2  s . co m*/

    // Remove user from all groups
    DuracloudUser user = repoMgr.getUserRepo().findOne(userId);
    DuracloudGroupRepo groupRepo = getGroupRepo();
    List<DuracloudGroup> allGroups = groupRepo.findAll();
    for (DuracloudGroup group : allGroups) {
        Set<DuracloudUser> groupUsers = group.getUsers();
        if (groupUsers.contains(user)) {
            groupUsers.remove(user);
            groupRepo.save(group);
        }
    }

    // Remove the user
    getUserRepo().delete(userId);

    notifyUserChange(accountRights);
}

From source file:de.hybris.platform.b2bacceleratorservices.company.impl.DefaultB2BCommerceUserService.java

@Override
public B2BCustomerModel removeApproverFromCustomer(final String user, final String approver) {
    final B2BCustomerModel customer = this.getCustomerForUid(user);
    final Set<B2BCustomerModel> approvers = new HashSet<B2BCustomerModel>(customer.getApprovers());
    final B2BCustomerModel approverModel = getCustomerForUid(approver);
    approvers.remove(approverModel);
    customer.setApprovers(approvers);//from  ww w  .j a  va 2s .  c o m
    this.getModelService().save(customer);
    return approverModel;
}

From source file:org.apache.brooklyn.entity.nosql.couchbase.CouchbaseNodeImpl.java

@Override
protected Collection<Integer> getRequiredOpenPorts() {
    // TODO this creates a huge list of inbound ports; much better to define on a security group using range syntax!
    int erlangRangeStart = getConfig(NODE_DATA_EXCHANGE_PORT_RANGE_START).iterator().next();
    int erlangRangeEnd = getConfig(NODE_DATA_EXCHANGE_PORT_RANGE_END).iterator().next();

    Set<Integer> newPorts = MutableSet.<Integer>copyOf(super.getRequiredOpenPorts());
    newPorts.remove(erlangRangeStart);
    newPorts.remove(erlangRangeEnd);//from w  ww  .j  a  v a2 s  .  com
    for (int i = erlangRangeStart; i <= erlangRangeEnd; i++)
        newPorts.add(i);
    return newPorts;
}

From source file:com.kazuki43zoo.jpetstore.JpetstoreApplicationTests.java

@Test
public void testViewHelp() {

    // Open the home page
    open("/");//from  w  w w .j av  a2  s. com
    assertThat(title()).isEqualTo("JPetStore Demo");

    String mainWindow = getWebDriver().getWindowHandle();

    // Move to the top page
    $(By.linkText("Enter the Store")).click();
    $(By.id("WelcomeContent")).shouldBe(text(""));

    // Move to help
    $(By.linkText("?")).click();

    Set<String> windows = new HashSet<>(getWebDriver().getWindowHandles());
    windows.remove(mainWindow);
    switchTo().window(windows.iterator().next());

    $(By.cssSelector("#Content h1")).shouldBe(text("JPetStore Demo"));

}