Example usage for java.util Map clear

List of usage examples for java.util Map clear

Introduction

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

Prototype

void clear();

Source Link

Document

Removes all of the mappings from this map (optional operation).

Usage

From source file:com.photon.phresco.framework.actions.applications.Applications.java

private void deleteConfigurations(String type, String configName) throws PhrescoException {
    try {/*from   w ww. ja  v a2s  .  c om*/
        String[] items = configName.split(",");
        List<String> deleteConfigNames = Arrays.asList(items);
        ProjectAdministrator administrator = PhrescoFrameworkFactory.getProjectAdministrator();
        Project project = administrator.getProject(projectCode);
        Map<String, List<String>> deleteConfigs = new HashMap<String, List<String>>();
        List<String> configNames = new ArrayList<String>();
        List<SettingsInfo> configurations = administrator.configurations(type, project);
        if (CollectionUtils.isNotEmpty(configurations)) {
            for (SettingsInfo config : configurations) {
                deleteConfigs.clear();
                configNames.clear();
                PropertyInfo serverType = config.getPropertyInfo(Constants.SERVER_TYPE);
                for (String deleteConfigName : deleteConfigNames) {
                    if (serverType.getValue().equalsIgnoreCase(deleteConfigName)) {
                        configNames.add(config.getName());
                        deleteConfigs.put(config.getEnvName(), configNames);
                        administrator.deleteConfigurations(deleteConfigs, project);
                    }
                }
            }
        }
    } catch (Exception e) {
        throw new PhrescoException(e);
    }
}

From source file:com.photon.phresco.framework.actions.applications.Applications.java

public String checkForRespectiveConfig() throws PhrescoException {
    try {// w w  w  . j av a2 s.co  m
        ProjectAdministrator administrator = PhrescoFrameworkFactory.getProjectAdministrator();
        Project project = administrator.getProject(projectCode);
        Map<String, List<String>> deleteConfigs = new HashMap<String, List<String>>();
        List<String> configNames = new ArrayList<String>();
        List<SettingsInfo> configurations = administrator.configurations(selectedAttrType, project);
        if (CollectionUtils.isNotEmpty(configurations)) {
            for (SettingsInfo config : configurations) {
                deleteConfigs.clear();
                configNames.clear();
                PropertyInfo serverType = config.getPropertyInfo(Constants.SERVER_TYPE);
                if (serverType.getValue().equalsIgnoreCase(selectedParamName)) {
                    setHasConfiguration(true);
                }
            }
        }
    } catch (Exception e) {
        throw new PhrescoException(e);
    }

    return SUCCESS;
}

From source file:com.espertech.esper.epl.core.ResultSetProcessorRowPerGroupRollup.java

private void resetEventPerGroupBuf() {
    for (Map<Object, EventBean> anEventPerGroupBuf : eventPerGroupBuf) {
        anEventPerGroupBuf.clear();
    }//w  ww  .j  av a2  s  .  c o  m
}

From source file:com.espertech.esper.epl.core.ResultSetProcessorRowPerGroupRollup.java

private void resetEventPerGroupJoinBuf() {
    for (Map<Object, EventBean[]> anEventPerGroupBuf : eventPerGroupJoinBuf) {
        anEventPerGroupBuf.clear();
    }//from  w w w  . j ava  2  s.  c  o  m
}

From source file:com.gst.portfolio.shareaccounts.service.ShareAccountWritePlatformServiceJpaRepositoryImpl.java

@Override
public CommandProcessingResult redeemShares(Long accountId, JsonCommand jsonCommand) {
    try {/* w w w  .  ja va  2s  .  c o m*/
        ShareAccount account = this.shareAccountRepository.findOneWithNotFoundDetection(accountId);
        Map<String, Object> changes = this.accountDataSerializer.validateAndRedeemShares(jsonCommand, account);
        if (!changes.isEmpty()) {
            this.shareAccountRepository.save(account);
            ShareAccountTransaction transaction = (ShareAccountTransaction) changes
                    .get(ShareAccountApiConstants.requestedshares_paramname);
            // after saving, entity will have different object. So need to retrieve the entity object
            transaction = account.getShareAccountTransaction(transaction);
            Long redeemShares = transaction.getTotalShares();
            ShareProduct shareProduct = account.getShareProduct();
            //remove the redeem shares from total subscribed shares 
            shareProduct.removeSubscribedShares(redeemShares);
            this.shareProductRepository.save(shareProduct);

            Set<ShareAccountTransaction> transactions = new HashSet<>();
            transactions.add(transaction);
            this.journalEntryWritePlatformService
                    .createJournalEntriesForShares(populateJournalEntries(account, transactions));
            changes.clear();
            changes.put(ShareAccountApiConstants.requestedshares_paramname, transaction.getId());

        }
        return new CommandProcessingResultBuilder() //
                .withCommandId(jsonCommand.commandId()) //
                .withEntityId(accountId) //
                .with(changes) //
                .build();
    } catch (DataIntegrityViolationException dve) {
        handleDataIntegrityIssues(jsonCommand, dve.getMostSpecificCause(), dve);
        return CommandProcessingResult.empty();
    }
}

From source file:com.espertech.esper.epl.core.ResultSetProcessorRowPerGroupRollup.java

private UniformPair<EventBean[]> handleOutputLimitFirstView(List<UniformPair<EventBean[]>> viewEventsList,
        boolean generateSynthetic) {

    for (Map<Object, EventBean[]> aGroupRepsView : outputLimitGroupRepsPerLevel) {
        aGroupRepsView.clear();
    }/* ww  w. j  a  v a2 s . com*/

    rstreamEventSortArrayPair.reset();

    int oldEventCount;
    if (prototype.getPerLevelExpression().getOptionalHavingNodes() == null) {
        oldEventCount = handleOutputLimitFirstViewNoHaving(viewEventsList, generateSynthetic,
                rstreamEventSortArrayPair.getEventsPerLevel(), rstreamEventSortArrayPair.getSortKeyPerLevel());
    } else {
        oldEventCount = handleOutputLimitFirstViewHaving(viewEventsList, generateSynthetic,
                rstreamEventSortArrayPair.getEventsPerLevel(), rstreamEventSortArrayPair.getSortKeyPerLevel());
    }

    return generateAndSort(outputLimitGroupRepsPerLevel, generateSynthetic, oldEventCount);
}

From source file:com.espertech.esper.epl.core.ResultSetProcessorRowPerGroupRollup.java

private UniformPair<EventBean[]> handleOutputLimitFirstJoin(
        List<UniformPair<Set<MultiKey<EventBean>>>> joinEventsSet, boolean generateSynthetic) {

    for (Map<Object, EventBean[]> aGroupRepsView : outputLimitGroupRepsPerLevel) {
        aGroupRepsView.clear();
    }/* ww  w .  j  a  v a  2  s.c  om*/

    rstreamEventSortArrayPair.reset();

    int oldEventCount;
    if (prototype.getPerLevelExpression().getOptionalHavingNodes() == null) {
        oldEventCount = handleOutputLimitFirstJoinNoHaving(joinEventsSet, generateSynthetic,
                rstreamEventSortArrayPair.getEventsPerLevel(), rstreamEventSortArrayPair.getSortKeyPerLevel());
    } else {
        oldEventCount = handleOutputLimitFirstJoinHaving(joinEventsSet, generateSynthetic,
                rstreamEventSortArrayPair.getEventsPerLevel(), rstreamEventSortArrayPair.getSortKeyPerLevel());
    }

    return generateAndSort(outputLimitGroupRepsPerLevel, generateSynthetic, oldEventCount);
}

From source file:org.nuxeo.ecm.core.opencmis.impl.CmisSuiteSession.java

@Test
public void testUpdate() throws Exception {
    Document doc;/* ww  w.j  a va  2s  . co  m*/

    doc = (Document) session.getObjectByPath("/testfolder1/testfile1");
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("dc:title", "new title");
    map.put("dc:subjects", Arrays.asList("a", "b", "c"));
    doc.updateProperties(map);

    doc = (Document) session.getObjectByPath("/testfolder1/testfile1");
    assertEquals("new title", doc.getPropertyValue("dc:title"));
    assertEquals(Arrays.asList("a", "b", "c"), doc.getPropertyValue("dc:subjects"));

    // TODO test transient object API
    map.clear();
    map.put("dc:title", "other title");
    map.put("dc:subjects", Arrays.asList("foo"));
    doc.updateProperties(map);
    doc.refresh(); // reload
    assertEquals("other title", doc.getPropertyValue("dc:title"));
    assertEquals(Arrays.asList("foo"), doc.getPropertyValue("dc:subjects"));
}

From source file:at.kc.tugraz.ss.serv.job.dataexport.impl.SSDataExportImpl.java

@Override
public void dataExportUserEntityTagCategoryTimestamps(final SSServPar parA) throws Exception {

    final SSDataExportUserEntityTagCategoryTimestampPar par = new SSDataExportUserEntityTagCategoryTimestampPar(
            parA);//from www  .  ja v a2 s  .co  m
    CSVWriter fileWriter = null;
    FileOutputStream out = null;
    OutputStreamWriter writer = null;

    try {

        final Map<String, List<SSUri>> usersResources = new HashMap<>();
        final Map<String, List<String>> tagsPerEntities = new HashMap<>();
        final Map<String, List<String>> categoriesPerEntities = new HashMap<>();
        final List<String> lineParts = new ArrayList<>();
        final List<String> allUsers;
        SSUri user;
        String resourceString;

        out = SSFileU.openOrCreateFileWithPathForWrite(SSFileU.dirWorkingDataCsv() + par.fileName);
        writer = new OutputStreamWriter(out, Charset.forName(SSEncodingU.utf8.toString()));
        fileWriter = new CSVWriter(writer, SSStrU.semiColon.charAt(0));

        try {
            allUsers = SSStrU.toStr(SSServCaller.userAll(false));
        } catch (SSErr error) {

            switch (error.code) {
            case notServerServiceForOpAvailable:
                SSLogU.warn(error.getMessage());
                return;
            default:
                SSServErrReg.regErrThrow(error);
                return;
            }
        }

        for (SSServContainerI serv : SSServReg.inst.getServsGatheringUsersResources()) {
            ((SSUsersResourcesGathererI) serv.serv()).getUsersResources(allUsers, usersResources);
        }

        for (Map.Entry<String, List<SSUri>> resourcesForUser : usersResources.entrySet()) {

            user = SSUri.get(resourcesForUser.getKey());

            tagsPerEntities.clear();
            categoriesPerEntities.clear();

            if (par.exportTags) {
                tagsPerEntities.putAll(SSDataExportFct.getTagsOfUserPerEntities(user,
                        resourcesForUser.getValue(), par.usePrivateTagsToo));
            }

            if (par.exportCategories) {
                categoriesPerEntities.putAll(SSDataExportFct.getCategoriesPerEntities(tagsPerEntities.size()));
            }

            for (SSUri resource : resourcesForUser.getValue()) {

                resourceString = SSStrU.toStr(resource);

                lineParts.clear();

                lineParts.add(SSStrU.toStr(user));
                lineParts.add(SSStrU.toStr(resource));
                lineParts.add(SSStrU.toStr(SSDateU.dateAsLong() / 1000)); //TODO: provide tag time stamps for tags

                if (tagsPerEntities.containsKey(resourceString)) {
                    lineParts.add(StringUtils.join(tagsPerEntities.get(resourceString), SSStrU.comma));
                } else {
                    lineParts.add(SSStrU.empty);
                }

                if (categoriesPerEntities.containsKey(resourceString)) {
                    lineParts.add(StringUtils.join(categoriesPerEntities.get(resourceString), SSStrU.comma));
                } else {
                    lineParts.add(SSStrU.empty);
                }

                fileWriter.writeNext((String[]) lineParts.toArray(new String[lineParts.size()]));
            }
        }
    } catch (Exception error) {
        SSServErrReg.regErrThrow(error);
    } finally {

        if (fileWriter != null) {
            fileWriter.close();
        } else {

            if (writer != null) {
                writer.close();
            } else {

                if (out != null) {
                    out.close();
                }
            }
        }
    }
}

From source file:fragment.web.SupportControllerTest.java

@Test
public void testListTicketsAsMasterUser() throws Exception {
    Tenant otherTenant = tenantDAO.find(2L);
    User otherMasterUser = otherTenant.getOwner();
    userDAO.save(otherMasterUser);/* w w w  .  ja va 2  s  .  c om*/
    asUser(otherMasterUser);
    Tenant systemTenant = controller.getCurrentUser().getTenant();
    createTestTicket(3, otherTenant, otherMasterUser);
    asUser(user);
    systemTenant = controller.getCurrentUser().getTenant();
    String view = controller.listTickets(systemTenant, tenant.getUuid(), "All", false, "", "", "", 1, null,
            map);

    List<TicketStatus> listTicketStatus = new ArrayList<Ticket.TicketStatus>();
    listTicketStatus.add(TicketStatus.NEW);
    listTicketStatus.add(TicketStatus.CLOSED);
    listTicketStatus.add(TicketStatus.ESCALATED);
    listTicketStatus.add(TicketStatus.WORKING);

    List<User> users = new ArrayList<User>();
    users.add(user);
    Map<String, String> responseAttribute = new HashMap<String, String>();
    responseAttribute.put("queryLocator", "xyz");

    List<Ticket> tickets = supportService.list(0, 0, listTicketStatus, users, "", "", responseAttribute);

    Assert.assertEquals("support.tickets", view);
    Assert.assertTrue(map.containsKey("tickets"));
    Assert.assertTrue(map.containsValue(tickets));

    @SuppressWarnings("unchecked")
    List<String> list = (List<String>) map.get("tickets");
    Assert.assertEquals(5, list.size());

    asUser(otherMasterUser);
    responseAttribute.clear();
    view = controller.listTickets(systemTenant, tenant.getUuid(), "All", false, "", "", "", 1, null, map);
    Assert.assertEquals("support.tickets", view);
    Assert.assertTrue(map.containsKey("tickets"));

    @SuppressWarnings("unchecked")
    List<String> list1 = (List<String>) map.get("tickets");
    Assert.assertEquals(14, list1.size());
}