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.collabnet.ccf.pi.qc.v90.QCHandler.java

/**
 * Orders the values of the incoming HashMap according to its keys.
 * /*from  w w  w .j  a  va 2 s .c o  m*/
 * @param HashMap
 *            This hashMap contains the transactionIds as values indexed by
 *            their defectIds.
 * @return List<String> This list of strings is the ordering of the keys of
 *         the incoming HashMaps, which are the defectIds, according to the
 *         order of their transactionIds
 * 
 */
public List<String> orderByLatestTransactionIds(Map<String, String> defectIdTransactionIdMap) {

    List<String> mapKeys = new ArrayList<String>(defectIdTransactionIdMap.keySet());
    List<String> mapValues = new ArrayList<String>(defectIdTransactionIdMap.values());

    defectIdTransactionIdMap.clear();
    TreeSet<String> sortedSet = new TreeSet<String>(mapValues);
    Object[] sortedArray = sortedSet.toArray();
    int size = sortedArray.length;
    for (int i = 0; i < size; i++) {
        defectIdTransactionIdMap.put(mapKeys.get(mapValues.indexOf(sortedArray[i])), (String) sortedArray[i]);
    }

    List<String> orderedDefectList = new ArrayList<String>(defectIdTransactionIdMap.keySet());
    return orderedDefectList;
}

From source file:com.moviejukebox.plugin.DefaultImagePlugin.java

protected void fillOverlayKeywords(Map<String, ArrayList<String>> data, String keywordList) {
    data.clear();
    if (StringTools.isValidString(keywordList)) {
        for (String keyword : keywordList.split(" ; ")) {
            String[] keywordValues = keyword.split(Movie.SPACE_SLASH_SPACE);
            if (keywordValues.length > 1) {
                data.put(keywordValues[0], new ArrayList<>(Arrays.asList(keywordValues)));
            }/* w  w w.  j  a  v a  2s.  c o m*/
        }
    }
}

From source file:org.wso2.carbon.appmgt.gateway.handlers.security.saml2.SAML2AuthenticationHandler.java

private void sendSLOResponse(MessageContext messageContext) {

    org.apache.axis2.context.MessageContext axis2MessageContext = ((Axis2MessageContext) messageContext)
            .getAxis2MessageContext();
    Object headers = axis2MessageContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);

    if (headers != null && headers instanceof Map) {

        @SuppressWarnings("unchecked")
        Map<String, Object> headersMap = (Map<String, Object>) headers;

        headersMap.clear();/*from   w  w w.ja  va  2  s  .c om*/
        axis2MessageContext.setProperty("HTTP_SC", "200");
        axis2MessageContext.setProperty("NO_ENTITY_BODY", new Boolean("true"));
        messageContext.setProperty("RESPONSE", "true");
        messageContext.setTo(null);
        Axis2Sender.sendBack(messageContext);
    }
}

From source file:com.esd.ps.EmployerController.java

/**
 * ??(pack)json list/*from  ww w . j  av a2  s .  c  o  m*/
 * 
 * @param session
 * @param page
 * @param packStuts
 * @param packNameCondition
 * @return
 */
@RequestMapping(value = "/employer", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> employerPost(HttpSession session, int page, int packStuts, String packNameCondition,
        int unzip) {// listjson
    Map<String, Object> map = new HashMap<String, Object>();

    int userId = userService.getUserIdByUserName(session.getAttribute(Constants.USER_NAME).toString());
    int employerId = employerService.getEmployerIdByUserId(userId);
    logger.debug("employerId:{}", employerId);
    session.setAttribute(Constants.EMPLOYER_ID, employerId);
    SimpleDateFormat sdf = new SimpleDateFormat(Constants.DATETIME_FORMAT);
    List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
    int totle = packService.getCountLikePackName(packStuts, packNameCondition, employerId, unzip);
    if (totle == 0) {
        map.clear();
        map.put(Constants.TOTLE, totle);
        map.put(Constants.TOTLE_PAGE, Math.ceil((double) totle / (double) Constants.ROW));
        map.put(Constants.LIST, list);
        return map;
    }
    int pre = (int) System.currentTimeMillis();
    List<Map<String, Object>> listPack = packService.getEmployerPage(page, packStuts, packNameCondition,
            employerId, Constants.ROW, unzip);
    //int pre1 = (int) System.currentTimeMillis();
    //System.out.println("listPack:"+ (pre1 - pre));

    for (Iterator<Map<String, Object>> iterator = listPack.iterator(); iterator.hasNext();) {
        Map<String, Object> map2 = (Map<String, Object>) iterator.next();
        if (map2.get("createTime") == null) {
            map2.put("createTime", "");
        } else {
            map2.put("createTime", sdf.format((Date) map2.get("createTime")));
        }
        if (map2.get("packType") == null) {
            map2.put("packType", "");
        } else {
            if (Integer.parseInt(map2.get("packType").toString()) == 1) {
                map2.put("packType", "");
            } else {
                map2.put("packType", "");
            }
        }
        if (map2.get("invalid") == null) {
            map2.put("invalid", 0);
        }
        if (map2.get("wavZero") == null) {
            map2.put("wavZero", 0);
        }
        if (map2.get("finishTaskCount") == null) {
            map2.put("finishTaskCount", 0);
        }
        if (map2.get("taskMarkTime") == null) {
            map2.put("taskMarkTime", 0);
        }
        if (map2.get("packLockTime") == null) {
            map2.put("packLockTime", 0);
        } else {
            int m = Integer.parseInt(map2.get("packLockTime").toString()) / 3600000;
            map2.put("packLockTime", m);
        }
        list.add(map2);
    }
    //int pre2 = (int) System.currentTimeMillis();
    //System.out.println("for:"+ (pre2 - pre1));
    map.clear();
    map.put(Constants.TOTLE, totle);
    map.put(Constants.TOTLE_PAGE, Math.ceil((double) totle / (double) Constants.ROW));
    map.put(Constants.LIST, list);
    logger.debug("list:{},totle:{},totlePages", list, totle,
            Math.ceil((double) totle / (double) Constants.ROW));
    return map;
}

From source file:com.glaf.core.service.impl.MxSysDataTableServiceImpl.java

@Transactional
public void saveDataList(String datatableId, List<Map<String, Object>> dataList) {
    SysDataTable dataTable = this.getDataTableById(datatableId);
    Map<String, Object> newData = new HashMap<String, Object>();

    SysDataField idField = null;//from   w w  w  . j  av  a 2s  .  c  om
    List<SysDataField> fields = dataTable.getFields();
    if (fields != null && !fields.isEmpty()) {
        for (SysDataField field : fields) {
            if (StringUtils.equalsIgnoreCase("1", field.getPrimaryKey())
                    || StringUtils.equalsIgnoreCase("y", field.getPrimaryKey())
                    || StringUtils.equalsIgnoreCase("true", field.getPrimaryKey())) {
                idField = field;
                break;
            }
        }
    }

    if (idField == null) {
        throw new java.lang.RuntimeException("primary key not found.");
    }

    for (Map<String, Object> dataMap : dataList) {
        newData.clear();
        Set<Entry<String, Object>> entrySet = dataMap.entrySet();
        for (Entry<String, Object> entry : entrySet) {
            String key = entry.getKey();
            Object value = entry.getValue();
            if (value != null) {
                newData.put(key, value);
                newData.put(key.toUpperCase(), value);
            }
        }

        Object idValue = newData.get(idField.getColumnName().toUpperCase());
        if (idValue == null) {
            idValue = newData.get(idField.getName().toUpperCase());
        }

        TableModel row = new TableModel();
        row.setTableName(dataTable.getTablename());

        ColumnModel col01 = new ColumnModel();
        col01.setColumnName(idField.getColumnName());

        if (idValue == null) {
            if (StringUtils.equalsIgnoreCase(idField.getDataType(), "Integer")) {
                col01.setJavaType("Long");
                Long id = idGenerator.nextId();
                col01.setIntValue(id.intValue());
                col01.setValue(Integer.valueOf(id.intValue()));
            } else if (StringUtils.equalsIgnoreCase(idField.getDataType(), "Long")) {
                col01.setJavaType("Long");
                Long id = idGenerator.nextId();
                col01.setLongValue(id);
                col01.setValue(id);
            } else {
                col01.setJavaType("String");
                String id = idGenerator.getNextId();
                col01.setStringValue(id);
                col01.setValue(id);
            }
            row.setIdColumn(col01);
        } else {
            if (StringUtils.equalsIgnoreCase(idField.getDataType(), "Integer")) {
                col01.setJavaType("Long");
                String id = idValue.toString();
                col01.setIntValue(Integer.parseInt(id));
                col01.setValue(col01.getIntValue());
            } else if (StringUtils.equalsIgnoreCase(idField.getDataType(), "Long")) {
                col01.setJavaType("Long");
                String id = idValue.toString();
                col01.setLongValue(Long.parseLong(id));
                col01.setValue(col01.getLongValue());
            } else {
                col01.setJavaType("String");
                String id = idValue.toString();
                col01.setStringValue(id);
                col01.setValue(id);
            }
            row.setIdColumn(col01);
        }

        if (fields != null && !fields.isEmpty()) {
            for (SysDataField field : fields) {
                if (StringUtils.equalsIgnoreCase(idField.getColumnName(), field.getColumnName())) {
                    continue;
                }
                String name = field.getColumnName().toUpperCase();
                String javaType = field.getDataType();
                ColumnModel c = new ColumnModel();
                c.setColumnName(field.getColumnName());
                c.setJavaType(javaType);
                Object value = newData.get(name);
                if (value != null) {
                    if ("Integer".equals(javaType)) {
                        value = ParamUtils.getInt(newData, name);
                    } else if ("Long".equals(javaType)) {
                        value = ParamUtils.getLong(newData, name);
                    } else if ("Double".equals(javaType)) {
                        value = ParamUtils.getDouble(newData, name);
                    } else if ("Date".equals(javaType)) {
                        value = ParamUtils.getTimestamp(newData, name);
                    } else if ("String".equals(javaType)) {
                        value = ParamUtils.getString(newData, name);
                    } else if ("Clob".equals(javaType)) {
                        value = ParamUtils.getString(newData, name);
                    }
                    c.setValue(value);
                    row.addColumn(c);
                } else {
                    name = field.getName().toUpperCase();
                    value = newData.get(name);
                    if (value != null) {
                        if ("Integer".equals(javaType)) {
                            value = ParamUtils.getInt(newData, name);
                        } else if ("Long".equals(javaType)) {
                            value = ParamUtils.getLong(newData, name);
                        } else if ("Double".equals(javaType)) {
                            value = ParamUtils.getDouble(newData, name);
                        } else if ("Date".equals(javaType)) {
                            value = ParamUtils.getTimestamp(newData, name);
                        } else if ("String".equals(javaType)) {
                            value = ParamUtils.getString(newData, name);
                        } else if ("Clob".equals(javaType)) {
                            value = ParamUtils.getString(newData, name);
                        }
                        c.setValue(value);
                        row.addColumn(c);
                    }
                }
            }
        }
        if (idValue == null) {
            tableDataMapper.insertTableData(row);
        } else {
            tableDataMapper.updateTableDataByPrimaryKey(row);
        }
    }
}

From source file:com.netsteadfast.greenstep.bsc.service.logic.impl.OrganizationLogicServiceImpl.java

@ServiceMethodAuthority(type = { ServiceMethodType.DELETE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class,
        IOException.class, Exception.class })
@Override/*from   ww  w  . j av  a 2 s.co  m*/
public DefaultResult<Boolean> delete(OrganizationVO organization) throws ServiceException, Exception {
    if (organization == null || super.isBlank(organization.getOid())) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    organization = this.findOrganizationData(organization.getOid());
    if (this.foundChild(organization)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE));
    }
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("orgId", organization.getOrgId());
    if (this.employeeOrgaService.countByParams(params) > 0) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE));
    }
    if (this.kpiOrgaService.countByParams(params) > 0) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE));
    }
    if (this.pdcaOrgaService.countByParams(params) > 0) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE));
    }
    if (this.pdcaMeasureFreqService.countByParams(params) > 0) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE));
    }
    if (this.tsaMeasureFreqService.countByParams(params) > 0) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE));
    }
    this.deleteParent(organization);
    this.swotService.deleteForOrgId(organization.getOrgId());

    // delete BB_REPORT_ROLE_VIEW
    params.clear();
    params.put("idName", organization.getOrgId());
    List<BbReportRoleView> reportRoleViews = this.reportRoleViewService.findListByParams(params);
    for (int i = 0; reportRoleViews != null && i < reportRoleViews.size(); i++) {
        BbReportRoleView reportRoleView = reportRoleViews.get(i);
        this.reportRoleViewService.delete(reportRoleView);
    }

    // delete from BB_MEASURE_DATA where ORG_ID = :orgId
    this.measureDataService.deleteForOrgId(organization.getOrgId());

    this.monitorItemScoreService.deleteForOrgId(organization.getOrgId());

    return this.getOrganizationService().deleteObject(organization);
}

From source file:com.healthcit.cacure.businessdelegates.GeneratedModuleDataManager.java

/**
 * Generates a list of modules to be saved to CouchDB
 *///w w w.  ja  v a  2  s. c o m
public JSONArray generateModuleObjects(GeneratedModuleDataDetail formDetail) {
    log.debug("Generating list of modules...");
    log.debug("...............................");
    log.debug("...............................");

    // list of generated modules
    JSONArray list = new JSONArray();

    // actual number of modules to be generated
    int actualNumberOfModules = formDetail.getActualNumberOfModules();

    // actual number of entities to be generated
    int actualNumberOfEntities = formDetail.getActualNumberOfEntities();

    // actual number of CouchDb documents to be generated
    int numberOfDocumentsPerModule = formDao.getNumberOfFormsForModuleId(new Long(formDetail.getModuleId()))
            .intValue();

    int actualNumberOfDocuments = numberOfDocumentsPerModule * actualNumberOfModules;

    formDetail.setActualNumberOfCouchDbDocuments(actualNumberOfDocuments);

    // maximum number of modules per entity
    int numberOfModulesPerEntity = (int) Math.floor(actualNumberOfModules / actualNumberOfEntities);

    // debugging
    log.debug("Number of modules to be generated: " + actualNumberOfModules);
    log.debug("Number of entities to be generated: " + actualNumberOfEntities);

    // entity Id
    String entityId = null;

    // keep track of the last generated unique key
    Map<String, JSONObject> lastUniqueKey = new HashMap<String, JSONObject>();

    for (int index = 0; index < actualNumberOfModules; ++index) {
        // Get an "entity-module" id
        int entityModuleId = index % numberOfModulesPerEntity;

        // Get a new entity Id, whenever appropriate
        if (entityModuleId == 0)
            entityId = UUID.randomUUID().toString();

        // Set up the unique keys for this module
        Map<String, JSONObject> uniqueKey = generateUniqueKey(formDetail, lastUniqueKey, entityId, index,
                entityModuleId);

        JSONObject module = generateModuleData(formDetail, uniqueKey, lastUniqueKey, entityId);

        // track this unique key for later
        lastUniqueKey.clear();
        lastUniqueKey.putAll(uniqueKey);

        list.add(module);
    }

    return list;
}

From source file:edu.ku.brc.specify.conversion.BasicSQLUtils.java

/**
 * Creates or clears and fills a list//from  w w w  .  j  a  v  a2s .  com
 * @param fieldNames the list of names, can be null then the list is cleared and nulled out
 * @param ignoreMap the map to be be crated or cleared and nulled
 * @return the same map or a newly created one
 */
protected static Map<String, String> configureIgnoreMap(final String[] fieldNames,
        final Map<String, String> ignoreMap) {
    Map<String, String> ignoreMapLocal = ignoreMap;
    if (fieldNames == null) {
        if (ignoreMapLocal != null) {
            ignoreMapLocal.clear();
            ignoreMapLocal = null;
        }
    } else {
        if (ignoreMapLocal == null) {
            ignoreMapLocal = UIHelper.createMap();
        } else {
            ignoreMapLocal.clear();
        }
        //log.info("Ignore these Field Names when mapping:");
        for (String name : fieldNames) {
            ignoreMapLocal.put(name, "X");
            //log.info(name);
        }
    }
    return ignoreMapLocal;
}

From source file:gov.nih.nci.ncicb.cadsr.contexttree.service.impl.CDEBrowserTreeServiceImpl.java

public Map getAllPublishingNode(TreeFunctions treeFunctions, TreeIdGenerator idGen,
        boolean showFormsAlphebetically) throws Exception {
    CSITransferObject publishFormCSI = null, publishTemplateCSI = null;

    DefaultMutableTreeNode publishNode = null;
    Map formPublishCSCSIMap = new HashMap();
    Map templatePublishCSCSIMap = new HashMap();
    Map publishNodeByContextMap = new HashMap();

    Map formCSMap = getFormClassificationNodes(treeFunctions, idGen, CaDSRConstants.FORM_CS_TYPE,
            CaDSRConstants.FORM_CSI_TYPE);
    Map templateCSMap = getFormClassificationNodes(treeFunctions, idGen, CaDSRConstants.TEMPLATE_CS_TYPE,
            CaDSRConstants.TEMPLATE_CSI_TYPE);

    FormDAO dao = daoFactory.getFormDAO();
    List formCSIs = dao.getAllPublishingCSCSIsForForm();

    Iterator formIter = formCSIs.iterator();

    while (formIter.hasNext()) {
        publishFormCSI = (CSITransferObject) formIter.next();

        formPublishCSCSIMap.put(publishFormCSI.getCsConteIdseq(), publishFormCSI);
    }/*w  ww.j a v a2s.  c  o  m*/

    List templateCSIs = dao.getAllPublishingCSCSIsForTemplate();

    Iterator templateIter = templateCSIs.iterator();

    while (templateIter.hasNext()) {
        publishTemplateCSI = (CSITransferObject) templateIter.next();

        templatePublishCSCSIMap.put(publishTemplateCSI.getCsConteIdseq(), publishTemplateCSI);
    }

    // get all form publishing context
    Collection formPublishingContexts = formPublishCSCSIMap.keySet();
    Iterator contextIter = formPublishingContexts.iterator();
    Map treeNodeMap = new HashMap();

    while (contextIter.hasNext()) {
        String currContextId = (String) contextIter.next();
        treeNodeMap.clear();

        publishFormCSI = (CSITransferObject) formPublishCSCSIMap.get(currContextId);
        publishNode = new DefaultMutableTreeNode(
                new WebNode(idGen.getNewId(), publishFormCSI.getClassSchemeLongName()));
        publishNodeByContextMap.put(currContextId, publishNode);

        List publishedProtocols = null;
        List publishedForms = null;

        publishedProtocols = dao.getAllProtocolsForPublishedForms(currContextId);

        publishedForms = new ArrayList();

        if (showFormsAlphebetically)
            publishedForms = dao.getAllPublishedForms(currContextId);

        if (!publishedProtocols.isEmpty() || !publishedForms.isEmpty()) {
            DefaultMutableTreeNode publishFormNode = new DefaultMutableTreeNode(
                    new WebNode(idGen.getNewId(), publishFormCSI.getClassSchemeItemName()));

            publishNode.add(publishFormNode);

            if (!publishedForms.isEmpty() && showFormsAlphebetically) {
                DefaultMutableTreeNode listedAlphabetically = new DefaultMutableTreeNode(
                        new WebNode(idGen.getNewId(), "Listed Alphabetically"));

                Iterator formsIt = publishedForms.iterator();

                while (formsIt.hasNext()) {
                    Form currForm = (Form) formsIt.next();

                    listedAlphabetically.add(getFormNode(idGen.getNewId(), currForm, treeFunctions, true));
                }

                publishFormNode.add(listedAlphabetically);
            }

            //starting here
            if (!publishedProtocols.isEmpty()) {
                DefaultMutableTreeNode listedByProtocol = new DefaultMutableTreeNode(
                        new WebNode(idGen.getNewId(), "Listed by Protocol"));

                Iterator protocolIt = publishedProtocols.iterator();

                while (protocolIt.hasNext()) {
                    Protocol currProto = (Protocol) protocolIt.next();

                    // first create protocol node for each protocol
                    DefaultMutableTreeNode currProtoNode = getProtocolNode(idGen.getNewId(), currProto,
                            currContextId, treeFunctions);

                    // then add all form nodes
                    List formsForProtocol = dao.getAllPublishedFormsForProtocol(currProto.getIdseq());

                    Iterator protocolFormsIt = formsForProtocol.iterator();

                    while (protocolFormsIt.hasNext()) {
                        Form currProtocolForm = (Form) protocolFormsIt.next();

                        //TODO - tree for multiple form/protocols
                        //currProtocolForm.setProtocol(currProto);

                        Collection formCSes = currProtocolForm.getClassifications();

                        if (formCSes == null || formCSes.size() == 0) {
                            currProtoNode.add(
                                    this.getFormNode(idGen.getNewId(), currProtocolForm, treeFunctions, true));
                        } else {
                            //add formNode to csTree
                            Iterator csIter = formCSes.iterator();
                            while (csIter.hasNext()) {
                                ClassSchemeItem currCSI = (ClassSchemeItem) csIter.next();

                                Map currCSMap = (Map) formCSMap.get(currCSI.getCsConteIdseq());
                                this.copyCSTree(currProtocolForm, currCSMap, treeNodeMap,
                                        getFormNode(idGen.getNewId(), currProtocolForm, treeFunctions, true),
                                        currProtoNode, idGen);
                            }
                        }

                        listedByProtocol.add(currProtoNode);
                    }

                    publishFormNode.add(listedByProtocol);
                }
            }
        }
    }
    // get all publishing template context
    Collection templatePublishingContexts = templatePublishCSCSIMap.keySet();
    contextIter = templatePublishingContexts.iterator();

    while (contextIter.hasNext()) {
        List publishedTemplates = null;
        treeNodeMap.clear();

        String currContextId = (String) contextIter.next();
        publishTemplateCSI = (CSITransferObject) templatePublishCSCSIMap.get(currContextId);
        publishNode = (DefaultMutableTreeNode) publishNodeByContextMap.get(currContextId);

        if (publishNode == null) {
            publishNode = new DefaultMutableTreeNode(
                    new WebNode(idGen.getNewId(), publishTemplateCSI.getClassSchemeLongName()));

            publishNodeByContextMap.put(currContextId, publishNode);
        }

        publishedTemplates = dao.getAllPublishedTemplates(currContextId);

        if (publishedTemplates != null && !publishedTemplates.isEmpty()) {
            DefaultMutableTreeNode publishTemplateNode = new DefaultMutableTreeNode(
                    new WebNode(idGen.getNewId(), publishTemplateCSI.getClassSchemeItemName()));

            Iterator templateIt = publishedTemplates.iterator();

            while (templateIt.hasNext()) {
                Form currTemplate = (Form) templateIt.next();

                if (currTemplate.getClassifications() == null
                        || currTemplate.getClassifications().size() == 0) {
                    publishTemplateNode.add(getTemplateNode(idGen.getNewId(), currTemplate, treeFunctions));
                } else {
                    //add template node to csTree(s)
                    Iterator csIter = currTemplate.getClassifications().iterator();
                    while (csIter.hasNext()) {
                        ClassSchemeItem currCSI = (ClassSchemeItem) csIter.next();

                        Map currCSMap = (Map) templateCSMap.get(currCSI.getCsConteIdseq());
                        this.copyCSTree(currTemplate, currCSMap, treeNodeMap,
                                getTemplateNode(idGen.getNewId(), currTemplate, treeFunctions),
                                publishTemplateNode, idGen);
                    }

                }

            }

            publishNode.add(publishTemplateNode);
        }
    }

    return publishNodeByContextMap;
}

From source file:fragment.web.SupportControllerTest.java

@Test
public void testListTicketsAsRootOtherTenant() throws Exception {
    Tenant otherTenant = tenantDAO.find(2L);
    User otherMasterUser = otherTenant.getOwner();
    userDAO.save(otherMasterUser);/*  ww  w.ja va 2  s.  c  o m*/
    asUser(otherMasterUser);
    Tenant systemTenant = controller.getCurrentUser().getTenant();
    createTestTicket(3, otherTenant, otherMasterUser);
    asUser(getRootUser());
    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());

    systemTenant = controller.getCurrentUser().getTenant();
    view = controller.listTickets(systemTenant, otherTenant.getUuid(), "All", false, "", "", "", 1, null, map);
    responseAttribute.clear();
    responseAttribute.put("queryLocator", "xyz");
    Assert.assertEquals("support.tickets", view);
    Assert.assertTrue(map.containsKey("tickets"));

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