Example usage for java.util HashMap clear

List of usage examples for java.util HashMap clear

Introduction

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

Prototype

public void clear() 

Source Link

Document

Removes all of the mappings from this map.

Usage

From source file:com.qzgf.datacollection.timer.Yd12580TimerTask.java

@Override
public void run() {
    //get message
    HashMap param = new HashMap();

    ////from   w  ww.ja v  a2  s .c om
    Date currentTime = new Date();//?  
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String nowtime = formatter.format(currentTime); //?  
    SimpleDateFormat formatterex = new SimpleDateFormat("yyyyMMdd");
    String time = formatterex.format(currentTime); //? 
    //???
    log.debug(nowtime + ":12580??5???");
    System.out.println(nowtime + ":12580??5???");

    try {
        //webservice???========================
        //?
        String md5username = username + time;
        String md5passwd = passwd + time;
        MD5 md5 = new MD5();
        md5username = md5.StrToMd5(md5username);
        md5passwd = md5.StrToMd5(md5passwd);
        //=====================================================
        //webservice

        Postal[] ps = proxy.getList(md5username, md5passwd, parameter);
        String reorderArr = "";
        int size = ps.length;
        if (ps != null && size > 0) {
            System.out.println(nowtime + ":?12580" + size + "??");
            for (int i = 0; i < size; i++) {
                //???
                String pidex = baseSqlMapDAO.sequences("t_net_order");
                param.clear();
                param.put("pidex", pidex);
                param.put("pname", ps[i].getRecName()); //???   
                param.put("punit", " "); //??

                //??
                String paddressex = ps[i].getRecAddress();//??^13
                HashMap anlyadd = new HashMap();
                //?
                //               anlyadd.put("type", "NAME_PROVINCEID");
                //               anlyadd.put("value", ps[i].getProvince());
                //               String addcode=(String)baseSqlMapDAO.queryForObject("Communicate.gerCodeYd12580",paddress);
                /*
                //
                anlyadd.clear();
                anlyadd.put("type", "NAME_CITYID");
                anlyadd.put("value", ps[i].getRecCity());
                String pcity=(String)baseSqlMapDAO.queryForObject("Communicate.gerCodeYd12580",anlyadd);
                //
                anlyadd.clear();
                anlyadd.put("type", "NAME_COUNTYID");
                anlyadd.put("value", ps[i].getRecCounty());
                String pcounty=(String)baseSqlMapDAO.queryForObject("Communicate.gerCodeYd12580",anlyadd);
                */
                //ps[i].getRecCity()? ps[i].getRecProvince()?? ps[i].getRecCounty()
                String paddress = ps[i].getRecProvince().replace("?", "")
                        + ps[i].getRecCity().replace("", "") + ps[i].getCounty();
                System.out.println("???:" + paddress);
                String addcode = (String) baseSqlMapDAO.queryForObject("Communicate.gerCodeImmigration",
                        paddress);
                String[] addcodearr = addcode.split("\\,");//?

                //???
                param.put("pprovince", "350000");
                param.put("pcity", addcodearr[1]);
                param.put("pcounty", addcodearr[2]);
                param.put("paddress", paddressex);//???,???

                //?
                anlyadd.clear();
                anlyadd.put("type", "NAME_PROVINCEID");
                anlyadd.put("value", ps[i].getProvince());
                String precprovince = (String) baseSqlMapDAO.queryForObject("Communicate.gerCodeYd12580",
                        anlyadd);
                //
                anlyadd.clear();
                anlyadd.put("type", "NAME_CITYID");
                anlyadd.put("value", ps[i].getCity());
                String recpcity = (String) baseSqlMapDAO.queryForObject("Communicate.gerCodeYd12580", anlyadd);

                //
                param.put("precprovince", precprovince);//??
                param.put("preccity", recpcity);

                param.put("pareacode", " ");
                param.put("ptel", ps[i].getRecTel());//???
                param.put("pmobile", ps[i].getRecTel());
                param.put("ppost", "");
                param.put("pmailtype", "0");//0?
                //================================================================================
                /**
                 * ????
                 */
                String spec = ps[i].getSpec();
                String price = ps[i].getPrice();
                String isfee = ps[i].getIsFee();
                String cnt = "";
                if (isfee.equals("0")) {
                    cnt = ":" + spec;
                } else {
                    cnt = ":" + spec + ",?:" + price + ",";
                }
                param.put("pclientremark", cnt);//

                //=========================================================================================
                param.put("porderingnum", "1");
                param.put("porderingweight", "0.00");

                param.put("pbookingtime", "");//2010-06-23
                param.put("porderingtime", nowtime);
                param.put("precevingtime", nowtime);
                //?testadmin,testadmin
                param.put("pcreate_code", userid);
                param.put("peditor_code", userid);
                param.put("paddressid", "0");
                //????
                param.put("pthirdparty", "12580");
                //1.?
                try {
                    baseSqlMapDAO.insert("Order.insertOrder", param);
                } catch (Exception e) {
                    System.out.println(e.toString());
                }
                //2.????
                param.clear();
                param.put("pid", pidex);

                try {
                    HashMap map = communicateFacade.ProRequest("clientadd", param);

                    param.clear();
                    if (map != null) {
                        String state = map.get("STATE").toString();
                        String remark = map.get("REMARK").toString();
                        //???
                        if (state.equals("2")) {
                            param.put("orderingstate", "");//(??)
                        } else if (state.equals("1")) {
                            param.put("orderingstate", "?");//
                        } else if (state.equals("0")) {
                            param.put("orderingstate", "");//
                        }
                    } else {
                        param.put("orderingstate", "?");//
                    }
                    //??:???????
                    param.put("ORDERID", pidex);
                    communicateFacade.modifyBillState(param);
                } catch (Exception ex) {
                    System.out.println("?");
                }
                //3.??12580???
                param.clear();
                reorderArr = reorderArr + ps[i].getOrderID() + ",";
                param.put("pno", ps[i].getOrderID());
                param.put("pcontactor", ps[i].getContactor());
                param.put("paddress", paddressex);
                param.put("pphone", ps[i].getPhone());
                param.put("pprice", ps[i].getPrice());
                param.put("pisfee", isfee);
                param.put("pspec", ps[i].getSpec());
                param.put("pprovince", ps[i].getProvince());
                param.put("pcity", ps[i].getCity());
                param.put("pcounty", ps[i].getCounty());
                param.put("ppostcode", ps[i].getPostCode());
                param.put("precprovince", ps[i].getRecProvince());
                param.put("preccity", ps[i].getRecCity());
                param.put("preccounty", ps[i].getCounty());
                param.put("precname", ps[i].getRecName());
                param.put("precaddress", ps[i].getRecAddress());
                param.put("prectel", ps[i].getRecTel());
                //??
                param.put("porderid", pidex);
                baseSqlMapDAO.insert("Communicate.insertYd12580", param);
            } //for end
            reorderArr = reorderArr.substring(0, reorderArr.length() - 1);
        } //if end

        System.out.println(nowtime + " " + reorderArr);
        log.debug(nowtime + " " + reorderArr);
        //????12580
        System.out.println("12850??1?" + proxy.postalGetDataBack(reorderArr));
    } catch (RemoteException e) {
        // TODO Auto-generated catch block
        System.out.println("12580");
    }
}

From source file:org.apache.accumulo.storagehandler.CustomIndexPredicateAnalyzer.java

/**
 * Analyzes a predicate.//from  www.  j ava 2s .c  o  m
 *
 * @param predicate predicate to be analyzed
 *
 * @param searchConditions receives conditions produced by analysis
 *
 * @return residual predicate which could not be translated to
 * searchConditions
 */
public ExprNodeDesc analyzePredicate(ExprNodeDesc predicate,
        final List<IndexSearchCondition> searchConditions) {

    //pre-process the graph to determine if there are any OR statements and what level of nesting they are at
    orFirstLevel = false;
    orOtherLevel = false;
    NodeProcessor upFrontNodeProcessor = new NodeProcessor() {
        @Override
        public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx, Object... nodeOutputs)
                throws SemanticException {

            int position = 0;
            for (Node ancestor : stack) {
                if (nd == ancestor) {
                    break;
                }
                if (!FunctionRegistry.isOpOr((ExprNodeDesc) ancestor)) {
                    if (position == 0) {
                        orFirstLevel = true;
                    } else {
                        orOtherLevel = true;
                    }
                    return nd;
                }
                position++;
            }

            return analyzeExpr((ExprNodeDesc) nd, searchConditions, nodeOutputs);
        }
    };
    Dispatcher upFrontDisp = new DefaultRuleDispatcher(upFrontNodeProcessor,
            new LinkedHashMap<Rule, NodeProcessor>(), null);
    GraphWalker upFrontOgw = new DefaultGraphWalker(upFrontDisp);
    ArrayList<Node> topNodes = new ArrayList<Node>();
    topNodes.add(predicate);
    HashMap<Node, Object> nodeOutput = new HashMap<Node, Object>();
    try {
        upFrontOgw.startWalking(topNodes, nodeOutput);
    } catch (SemanticException ex) {
        throw new RuntimeException(ex);
    }

    //if there are no OR statements or any OR statements are the first level then we can just treat this normally
    //if there are OR statements but they are only at nesting levels then we need to look for any rowid checks at the first level and process them

    Map<Rule, NodeProcessor> opRules = new LinkedHashMap<Rule, NodeProcessor>();
    NodeProcessor nodeProcessor = new NodeProcessor() {
        @Override
        public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx, Object... nodeOutputs)
                throws SemanticException {

            // We can only push down stuff which appears as part of
            // a pure conjunction:  reject OR, CASE, etc.
            for (Node ancestor : stack) {
                if (nd == ancestor) {
                    break;
                }
                if ((!FunctionRegistry.isOpAnd((ExprNodeDesc) ancestor))
                        && (!FunctionRegistry.isOpOr((ExprNodeDesc) ancestor))) {
                    return nd;
                }
            }

            return analyzeExpr((ExprNodeDesc) nd, searchConditions, nodeOutputs);
        }
    };

    Dispatcher disp = new DefaultRuleDispatcher(nodeProcessor, opRules, null);
    GraphWalker ogw = new DefaultGraphWalker(disp);
    topNodes.clear();
    topNodes.add(predicate);
    nodeOutput.clear();
    try {
        ogw.startWalking(topNodes, nodeOutput);
    } catch (SemanticException ex) {
        throw new RuntimeException(ex);
    }
    ExprNodeDesc residualPredicate = (ExprNodeDesc) nodeOutput.get(predicate);
    return residualPredicate;
}

From source file:com.silverwrist.dynamo.unistore.MessageImpl.java

void deletedTextPart(int partnum, QualifiedNameKey identity) throws DatabaseException {
    PropertyKey pk = new PropertyKey(m_nscache.namespaceNameToId(identity.getNamespace()), identity.getName());
    synchronized (this) { // Remove the entry from the cache reference maps.
        m_part_to_text.remove(new Integer(partnum));
        m_pk_to_text.remove(pk);/*from  ww w . j  a v  a  2s.  co m*/
        if (m_text_count >= 0)
            m_text_count--;

        // All entries with a part number higher than the deleted part number have to be renumbered downwards.
        // First, scan through the keyset to find all the appropriate part numbers, get their values, and lock them
        // into a hard HashMap to keep them in memory while we do this.
        HashMap temp = new HashMap();
        Iterator it = m_part_to_text.keySet().iterator();
        while (it.hasNext()) { // get each key in turn and check it
            Integer key = (Integer) (it.next());
            if (key.intValue() > partnum) { // now see if the object's in memory
                TextPartImpl obj = (TextPartImpl) (m_part_to_text.get(key));
                if (obj != null)
                    temp.put(key, obj);

            } // end if

        } // end while

        // Now go through, poke new part numbers into each of these parts, and get them into the parts
        // mapping correctly.
        it = temp.entrySet().iterator();
        while (it.hasNext()) { // get each part in turn and deal with it
            Map.Entry ntry = (Map.Entry) (it.next());
            m_part_to_text.remove(ntry.getKey());
            int new_partnum = ((Integer) (ntry.getKey())).intValue() - 1;
            TextPartImpl obj = (TextPartImpl) (ntry.getValue());
            obj.resetPartNumber(new_partnum);
            m_part_to_text.put(new Integer(new_partnum), obj);

        } // end while

        temp.clear(); // release the extra references

    } // end synchronized block

}

From source file:com.silverwrist.dynamo.unistore.MessageImpl.java

void deletedBinaryPart(int partnum, QualifiedNameKey identity) throws DatabaseException {
    PropertyKey pk = new PropertyKey(m_nscache.namespaceNameToId(identity.getNamespace()), identity.getName());
    synchronized (this) { // Remove the entry from the cache reference maps.
        m_part_to_binary.remove(new Integer(partnum));
        m_pk_to_binary.remove(pk);//www .  j a v  a  2  s .c  om
        if (m_binary_count >= 0)
            m_binary_count--;

        // All entries with a part number higher than the deleted part number have to be renumbered downwards.
        // First, scan through the keyset to find all the appropriate part numbers, get their values, and lock them
        // into a hard HashMap to keep them in memory while we do this.
        HashMap temp = new HashMap();
        Iterator it = m_part_to_binary.keySet().iterator();
        while (it.hasNext()) { // get each key in turn and check it
            Integer key = (Integer) (it.next());
            if (key.intValue() > partnum) { // now see if the object's in memory
                BinaryPartImpl obj = (BinaryPartImpl) (m_part_to_binary.get(key));
                if (obj != null)
                    temp.put(key, obj);

            } // end if

        } // end while

        // Now go through, poke new part numbers into each of these parts, and get them into the parts
        // mapping correctly.
        it = temp.entrySet().iterator();
        while (it.hasNext()) { // get each part in turn and deal with it
            Map.Entry ntry = (Map.Entry) (it.next());
            m_part_to_binary.remove(ntry.getKey());
            int new_partnum = ((Integer) (ntry.getKey())).intValue() - 1;
            BinaryPartImpl obj = (BinaryPartImpl) (ntry.getValue());
            obj.resetPartNumber(new_partnum);
            m_part_to_binary.put(new Integer(new_partnum), obj);

        } // end while

        temp.clear(); // release the extra references

    } // end synchronized block

}

From source file:org.kuali.ext.mm.integration.service.impl.kfs.KfsPurchasingService.java

/**
 * @see org.kuali.ext.mm.integration.service.FinancialPurchasingService#getPurchaseOrderByRequisitionId(java.lang.Integer)
 *///w  w  w.ja  va 2  s .co m
@SuppressWarnings("unchecked")
public FinancialPurchaseOrderDocument getPurchaseOrderByRequisitionId(Integer requisitionId) {
    /***************************************************************************************************************************
     * SEVERE WARNING - This method is intended to be used by a batch job which reconciles POs that are open. This
     * implementation uses service bus and so needs to query each object through HTTP protocol and could cause serious
     * performance issues, so it is strongly suggested that we move away from this approach for batch jobs, this is an
     * intermediate solution
     **************************************************************************************************************************/
    HashMap<String, Object> fieldValues = new HashMap<String, Object>();
    fieldValues.put(PurapPropertyConstants.REQUISITION_IDENTIFIER, requisitionId);
    fieldValues.put(PurapPropertyConstants.PURCHASE_ORDER_CURRENT_INDICATOR, "Y");
    Collection<PurchaseOrderDocument> orders = financialBusinessObjectService
            .findMatching(PurchaseOrderDocument.class, fieldValues);
    PurchaseOrderDocument purchaseOrderDocument = null;
    if (orders != null & orders.iterator().hasNext()) {
        purchaseOrderDocument = orders.iterator().next();
    }
    FinancialPurchaseOrderDocument financialPurchaseOrderDocument = null;
    if (purchaseOrderDocument != null && ("OPEN".equals(purchaseOrderDocument.getStatusCode())
            || "VOID".equals(purchaseOrderDocument.getStatusCode()))) {
        DocumentRouteHeaderValue routeHeader = SpringContext.getBean(RouteHeaderService.class)
                .getRouteHeader(Long.valueOf(purchaseOrderDocument.getDocumentNumber()));
        financialPurchaseOrderDocument = new FinancialPurchaseOrderDocument();
        financialPurchaseOrderDocument.setWorkflowStatusCode(routeHeader.getDocRouteStatus());
        financialPurchaseOrderDocument.setPoStatusCode(purchaseOrderDocument.getStatusCode());
        adapt(purchaseOrderDocument, financialPurchaseOrderDocument);
        // query the items for the document
        fieldValues.clear();
        fieldValues.put("documentNumber", purchaseOrderDocument.getDocumentNumber());
        Collection<PurchaseOrderItem> items = financialBusinessObjectService
                .findMatching(PurchaseOrderItem.class, fieldValues);
        for (PurchaseOrderItem purchaseOrderItem : items) {
            FinancialPurchaseOrderDetail financialPurchaseOrderDetail = new FinancialPurchaseOrderDetail();
            adapt(purchaseOrderItem, financialPurchaseOrderDetail);
            financialPurchaseOrderDocument.getOrderDetails().add(financialPurchaseOrderDetail);
            // query the accounts for the items
            fieldValues.clear();
            fieldValues.put("itemIdentifier", purchaseOrderItem.getItemIdentifier());
            Collection<PurchaseOrderAccount> accounts = financialBusinessObjectService
                    .findMatching(PurchaseOrderAccount.class, fieldValues);
            for (PurchaseOrderAccount purchaseOrderAccount : accounts) {
                FinancialPurchaseOrderAccount financialPurchaseOrderAccount = new FinancialPurchaseOrderAccount();
                adapt(purchaseOrderAccount, financialPurchaseOrderAccount);
                financialPurchaseOrderDetail.getAccounts().add(financialPurchaseOrderAccount);
            }
        }
    }
    return financialPurchaseOrderDocument;
}

From source file:org.sbs.goodcrawler.plugin.storage.ElasticSearchStorage.java

@SuppressWarnings({ "unchecked" })
@Override//from  w w w  . j a v a2  s .c o m
public StoreResult onStore(ExtractedPage page) {
    StoreResult storeResult = null;
    if (null != plugin) {
        page = plugin.process(page);
    }
    try {
        storeResult = new StoreResult();
        // ?Result
        if (null == page || page.getMessages() == null) {
            storeResult.setStatus(Status.ignored);
            return storeResult;
        }
        HashMap<String, Object> data = page.getMessages();
        HashMap<String, Object> content = (HashMap<String, Object>) data.get(config.indexName);
        content.put("url", page.getUrl().getURL());
        // ??url--?
        String update = (String) content.get("update");
        if (null != update) {
            if (update.contains("")) {
                // ??update url index
                HashMap<String, Object> m = Maps.newHashMap();
                m.put("url", page.getUrl().getURL());
                m.put("domain", page.getUrl().getDomain());
                m.put("time", new Date());
                m.put("indexName", config.indexName);
                m.put("jobName", config.jobName);
                EsClient.index("update", "0", m);
                System.err.println("####################################");
            }
        }
        content.remove("update");
        // ?
        GetResponse get = null;
        try {
            String id = config.genId(content);
            System.out.println("id = " + id);
            get = client.prepareGet(config.indexName, "0", config.genId(content)).execute().actionGet();
        } catch (Exception e) {
            e.printStackTrace();
            // index?
            EsClient.index(config.indexName, "0", config.genId(content), content);
        }
        if (null != get && get.isExists()) {
            Map<String, Object> m = get.getSource();
            m = MapUtils.mager((HashMap<String, Object>) m, content);
            log.info("mrege");
            EsClient.index(config.indexName, "0", config.genId(content), m);
        } else {
            EsClient.index(config.indexName, "0", config.genId(content), content);
        }
        data.clear();
        storeResult.setStatus(Status.success);
        return storeResult;
    } catch (Exception e) {
        e.printStackTrace();
        log.info(e.getMessage());
        storeResult.setStatus(Status.failed);
        return storeResult;
    }
}

From source file:ddf.catalog.source.opensearch.CddaOpenSearchSite.java

private Map<String, String> updateDefaultClassification() {
    HashMap<String, String> securityProps = new HashMap<String, String>();
    logger.debug("Assigning default classification values");
    if (siteSecurityConfig != null) {
        logger.debug("setting properties from config admin");
        try {//from www  .j  ava 2s.  co  m
            // siteSecurityConfig.update();
            @SuppressWarnings("unchecked")
            Dictionary<String, Object> propertyDictionary = (Dictionary<String, Object>) siteSecurityConfig
                    .getProperties();
            Enumeration<String> propertyKeys = propertyDictionary.keys();
            while (propertyKeys.hasMoreElements()) {
                String currKey = propertyKeys.nextElement();
                String currValue = propertyDictionary.get(currKey).toString();
                securityProps.put(currKey, currValue);
            }

            logger.debug("security properties: " + securityProps);

        } catch (Exception e) {
            logger.warn("Exception thrown while trying to obtain default properties.  "
                    + "Setting all default classifications and owner/producers to U and USA respectively as a last resort.",
                    e);
            securityProps.clear(); // this is being cleared, so the
                                   // "last-resort" defaults specified in
                                   // the xsl will be used.

        }
    } else {
        logger.info("site security config is null");
        securityProps.clear(); // this is being cleared, so the
                               // "last-resort" defaults specified in the
                               // xsl will be used.

    }
    return securityProps;
}

From source file:de.fabianonline.telegram_backup.exporter.HTMLExporter.java

public void export(UserManager user) {
    try {/*from   w  ww.  j  av  a  2 s. c o m*/
        Database db = new Database(user, null);

        // Create base dir
        logger.debug("Creating base dir");
        String base = user.getFileBase() + "files" + File.separatorChar;
        new File(base).mkdirs();
        new File(base + "dialogs").mkdirs();

        logger.debug("Fetching dialogs");
        LinkedList<Database.Dialog> dialogs = db.getListOfDialogsForExport();
        logger.trace("Got {} dialogs", dialogs.size());
        logger.debug("Fetching chats");
        LinkedList<Database.Chat> chats = db.getListOfChatsForExport();
        logger.trace("Got {} chats", chats.size());

        logger.debug("Generating index.html");
        HashMap<String, Object> scope = new HashMap<String, Object>();
        scope.put("user", user);
        scope.put("dialogs", dialogs);
        scope.put("chats", chats);

        // Collect stats data
        scope.put("count.chats", chats.size());
        scope.put("count.dialogs", dialogs.size());

        int count_messages_chats = 0;
        int count_messages_dialogs = 0;
        for (Database.Chat c : chats)
            count_messages_chats += c.count;
        for (Database.Dialog d : dialogs)
            count_messages_dialogs += d.count;

        scope.put("count.messages", count_messages_chats + count_messages_dialogs);
        scope.put("count.messages.chats", count_messages_chats);
        scope.put("count.messages.dialogs", count_messages_dialogs);

        scope.put("count.messages.from_me", db.getMessagesFromUserCount());

        scope.put("heatmap_data", intArrayToString(db.getMessageTimesMatrix()));

        scope.putAll(db.getMessageAuthorsWithCount());
        scope.putAll(db.getMessageTypesWithCount());
        scope.putAll(db.getMessageMediaTypesWithCount());

        MustacheFactory mf = new DefaultMustacheFactory();
        Mustache mustache = mf.compile("templates/html/index.mustache");
        OutputStreamWriter w = getWriter(base + "index.html");
        mustache.execute(w, scope);
        w.close();

        mustache = mf.compile("templates/html/chat.mustache");

        int i = 0;
        logger.debug("Generating {} dialog pages", dialogs.size());
        for (Database.Dialog d : dialogs) {
            i++;
            logger.trace("Dialog {}/{}: {}", i, dialogs.size(), Utils.anonymize("" + d.id));
            LinkedList<HashMap<String, Object>> messages = db.getMessagesForExport(d);
            scope.clear();
            scope.put("user", user);
            scope.put("dialog", d);
            scope.put("messages", messages);

            scope.putAll(db.getMessageAuthorsWithCount(d));
            scope.put("heatmap_data", intArrayToString(db.getMessageTimesMatrix(d)));
            scope.putAll(db.getMessageTypesWithCount(d));
            scope.putAll(db.getMessageMediaTypesWithCount(d));

            w = getWriter(base + "dialogs" + File.separatorChar + "user_" + d.id + ".html");
            mustache.execute(w, scope);
            w.close();
        }

        i = 0;
        logger.debug("Generating {} chat pages", chats.size());
        for (Database.Chat c : chats) {
            i++;
            logger.trace("Chat {}/{}: {}", i, chats.size(), Utils.anonymize("" + c.id));
            LinkedList<HashMap<String, Object>> messages = db.getMessagesForExport(c);
            scope.clear();
            scope.put("user", user);
            scope.put("chat", c);
            scope.put("messages", messages);

            scope.putAll(db.getMessageAuthorsWithCount(c));
            scope.put("heatmap_data", intArrayToString(db.getMessageTimesMatrix(c)));
            scope.putAll(db.getMessageTypesWithCount(c));
            scope.putAll(db.getMessageMediaTypesWithCount(c));

            w = getWriter(base + "dialogs" + File.separatorChar + "chat_" + c.id + ".html");
            mustache.execute(w, scope);
            w.close();
        }

        logger.debug("Generating additional files");
        // Copy CSS
        URL cssFile = getClass().getResource("/templates/html/style.css");
        File dest = new File(base + "style.css");
        FileUtils.copyURLToFile(cssFile, dest);
        logger.debug("Done exporting.");
    } catch (IOException e) {
        e.printStackTrace();
        throw new RuntimeException("Exception above!");
    }
}

From source file:org.rhq.enterprise.server.installer.ServerInstallUtil.java

private static void createNewDatasources_Oracle(ModelControllerClient mcc) throws Exception {
    final HashMap<String, String> props = new HashMap<String, String>(2);
    final DatasourceJBossASClient client = new DatasourceJBossASClient(mcc);

    ModelNode noTxDsRequest = null;//from  w w w  . j ava2  s . c o  m
    ModelNode xaDsRequest = null;

    if (!client.isDatasource(RHQ_DATASOURCE_NAME_NOTX)) {
        props.put("char.encoding", "UTF-8");

        noTxDsRequest = client.createNewDatasourceRequest(RHQ_DATASOURCE_NAME_NOTX, 30000,
                "${rhq.server.database.connection-url:jdbc:oracle:thin:@127.0.0.1:1521:rhq}",
                JDBC_DRIVER_ORACLE, "org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter", 15,
                false, 2, 5, 75, RHQ_DS_SECURITY_DOMAIN_NOTX,
                "org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker",
                "TRANSACTION_READ_COMMITTED",
                "org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker", true, props);
    } else {
        LOG.info("Oracle datasource [" + RHQ_DATASOURCE_NAME_NOTX + "] already exists");
    }

    if (!client.isDatasource(RHQ_DATASOURCE_NAME_XA)) {
        props.clear();
        props.put("URL", "${rhq.server.database.connection-url:jdbc:oracle:thin:@127.0.0.1:1521:rhq}");

        xaDsRequest = client.createNewXADatasourceRequest(RHQ_DATASOURCE_NAME_XA, 30000, JDBC_DRIVER_ORACLE,
                XA_DATASOURCE_CLASS_ORACLE,
                "org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter", 15, 5, 50,
                (Boolean) null, Boolean.TRUE, 75, (String) null, RHQ_DS_SECURITY_DOMAIN_XA,
                "org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker",
                "TRANSACTION_READ_COMMITTED",
                "org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker", props);
    } else {
        LOG.info("Oracle XA datasource [" + RHQ_DATASOURCE_NAME_XA + "] already exists");
    }

    if (noTxDsRequest != null || xaDsRequest != null) {
        ModelNode batch = DatasourceJBossASClient.createBatchRequest(noTxDsRequest, xaDsRequest);
        ModelNode results = client.execute(batch);
        if (!DatasourceJBossASClient.isSuccess(results)) {
            throw new FailureException(results, "Failed to create Oracle datasources");
        }
    }
}

From source file:org.kuali.ole.select.document.OlePaymentRequestDocument.java

@Override
public void processAfterRetrieve() {
    super.processAfterRetrieve();
    try {//  ww  w .  j a va 2  s.c o  m
        LOG.debug("###########inside OlePaymentRequestDocument processAfterRetrieve###########");
        if (this.getVendorAliasName() == null) {
            populateVendorAliasName();
        }
        if (this.getPaymentMethodId() != null) {
            OlePaymentMethod olePaymentMethod = SpringContext.getBean(BusinessObjectService.class)
                    .findBySinglePrimaryKey(OlePaymentMethod.class, this.getPaymentMethodId());
            this.setPaymentMethod(olePaymentMethod);
        }
        List<BigDecimal> newUnitPriceList = new ArrayList<BigDecimal>();
        BigDecimal newUnitPrice = new BigDecimal(0);
        BigDecimal hundred = new BigDecimal(100);
        List<OlePaymentRequestItem> item = this.getItems();

        for (int i = 0; item.size() > i; i++) {
            OlePaymentRequestItem items = (OlePaymentRequestItem) this.getItem(i);
            if ((items.getItemType().isQuantityBasedGeneralLedgerIndicator())) {
                if (items.getItemDiscount() == null) {
                    items.setItemDiscount(KualiDecimal.ZERO);
                }

                if (items.getItemListPrice() == null) {
                    items.setItemListPrice(KualiDecimal.ZERO);
                }

                if (items.getItemDiscountType() != null && items.getItemDiscountType()
                        .equalsIgnoreCase(OleSelectConstant.DISCOUNT_TYPE_PERCENTAGE)) {
                    newUnitPrice = (hundred.subtract(items.getItemDiscount().bigDecimalValue())).divide(hundred)
                            .multiply(items.getItemListPrice().bigDecimalValue());
                } else {
                    newUnitPrice = items.getItemListPrice().bigDecimalValue()
                            .subtract(items.getItemDiscount().bigDecimalValue());
                }
                items.setItemSurcharge(
                        items.getItemUnitPrice().subtract(newUnitPrice).setScale(4, RoundingMode.HALF_UP));
            }
        }
        if (this.getVendorDetail().getCurrencyType() != null) {
            if (this.getVendorDetail().getCurrencyType().getCurrencyType()
                    .equalsIgnoreCase(OleSelectConstant.CURRENCY_TYPE_NAME)) {
                currencyTypeIndicator = true;
            } else {
                currencyTypeIndicator = false;
            }
        }

        OleInvoiceDocument oleInvoiceDocument = SpringContext.getBean(BusinessObjectService.class)
                .findBySinglePrimaryKey(OleInvoiceDocument.class, this.getInvoiceIdentifier());

        if (oleInvoiceDocument.getInvoiceCurrencyTypeId() != null
                && oleInvoiceDocument.getForeignVendorInvoiceAmount() != null
                && oleInvoiceDocument.getInvoiceCurrencyExchangeRate() != null) {
            this.setForeignVendorInvoiceAmount(this.getVendorInvoiceAmount().bigDecimalValue()
                    .multiply(new BigDecimal(oleInvoiceDocument.getInvoiceCurrencyExchangeRate())));
        } else {
            if (this.getVendorDetail() != null && (!currencyTypeIndicator)) {
                Long currencyTypeId = this.getVendorDetail().getCurrencyType().getCurrencyTypeId();
                Map documentNumberMap = new HashMap();
                documentNumberMap.put(OleSelectConstant.CURRENCY_TYPE_ID, currencyTypeId);
                List<OleExchangeRate> exchangeRateList = (List) getBusinessObjectService().findMatchingOrderBy(
                        OleExchangeRate.class, documentNumberMap, OleSelectConstant.EXCHANGE_RATE_DATE, false);
                Iterator iterator = exchangeRateList.iterator();
                for (OlePaymentRequestItem items : item) {
                    iterator = exchangeRateList.iterator();
                    if (iterator.hasNext()) {
                        OleExchangeRate tempOleExchangeRate = (OleExchangeRate) iterator.next();
                        items.setItemExchangeRate(new KualiDecimal(tempOleExchangeRate.getExchangeRate()));
                        this.setForeignVendorInvoiceAmount(this.getVendorInvoiceAmount().bigDecimalValue()
                                .multiply(tempOleExchangeRate.getExchangeRate()));
                    }
                }
            }

        }
        String itemDescription = "";
        for (OlePaymentRequestItem singleItem : item) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Title id while retriving ------>" + singleItem.getItemTitleId());
            }
            if (singleItem.getItemTitleId() != null) {
                LOG.debug("###########inside processAfterRetrieve ole requisition item###########");
                Bib bib = new BibMarc();
                DocstoreClientLocator docstoreClientLocator = new DocstoreClientLocator();
                if (singleItem.getItemTitleId() != null && singleItem.getItemTitleId() != "") {
                    bib = docstoreClientLocator.getDocstoreClient().retrieveBib(singleItem.getItemTitleId());
                    singleItem.setBibUUID(bib.getId());
                    singleItem
                            .setDocFormat(DocumentUniqueIDPrefix.getBibFormatType(singleItem.getItemTitleId()));
                }
                if (singleItem.getItemUnitPrice() != null) {
                    singleItem.setItemUnitPrice(
                            singleItem.getItemUnitPrice().setScale(2, BigDecimal.ROUND_HALF_UP));
                }
                itemDescription = ((bib.getTitle() != null && !bib.getTitle().isEmpty())
                        ? bib.getTitle().trim() + ", "
                        : "")
                        + ((bib.getAuthor() != null && !bib.getAuthor().isEmpty())
                                ? bib.getAuthor().trim() + ", "
                                : "")
                        + ((bib.getPublisher() != null && !bib.getPublisher().isEmpty())
                                ? bib.getPublisher().trim() + ", "
                                : "")
                        + ((bib.getIsbn() != null && !bib.getIsbn().isEmpty()) ? bib.getIsbn().trim() + ", "
                                : "");
                if (itemDescription != null && !(itemDescription.equals(""))) {
                    itemDescription = itemDescription.lastIndexOf(",") < 0 ? itemDescription
                            : itemDescription.substring(0, itemDescription.lastIndexOf(","));
                    StringEscapeUtils stringEscapeUtils = new StringEscapeUtils();
                    itemDescription = stringEscapeUtils.unescapeXml(itemDescription);
                    singleItem.setItemDescription(itemDescription);
                }
                HashMap<String, String> queryMap = new HashMap<String, String>();
                if (singleItem.getPoItemIdentifier() != null) {
                    queryMap.put(OLEConstants.PO_ITEM_ID, singleItem.getPoItemIdentifier().toString());
                    OleInvoiceItem oleInvoiceItem = getBusinessObjectService()
                            .findByPrimaryKey(OleInvoiceItem.class, queryMap);
                    if (oleInvoiceItem != null && oleInvoiceItem.getPoItemIdentifier() != null) {
                        queryMap.clear();
                        queryMap.put(OLEConstants.OleCopy.PO_ITM_ID,
                                oleInvoiceItem.getPoItemIdentifier().toString());
                        List<OLELinkPurapDonor> oleLinkPurapDonorList = (List<OLELinkPurapDonor>) getBusinessObjectService()
                                .findMatching(OLELinkPurapDonor.class, queryMap);
                        if (oleLinkPurapDonorList != null) {
                            singleItem.setOleDonors(oleLinkPurapDonorList);
                        }
                    }
                }
            }
            for (OLEPaidCopy olePaidCopy : singleItem.getPaidCopies()) {
                if (olePaidCopy.getPaymentRequestItemId() == null
                        && olePaidCopy.getPaymentRequestIdentifier() == null) {
                    olePaidCopy.setPaymentRequestItemId(singleItem.getItemIdentifier());
                    olePaidCopy.setPaymentRequestIdentifier(this.getPurapDocumentIdentifier());
                    getBusinessObjectService().save(olePaidCopy);
                }
            }
        }
        if (this.getProrateBy() != null) {
            this.setProrateQty(this.getProrateBy().equals(OLEConstants.PRORATE_BY_QTY));
            this.setProrateManual(this.getProrateBy().equals(OLEConstants.MANUAL_PRORATE));
            this.setProrateDollar(this.getProrateBy().equals(OLEConstants.PRORATE_BY_DOLLAR));
            this.setNoProrate(this.getProrateBy().equals(OLEConstants.NO_PRORATE));
        }
    } catch (Exception e) {
        LOG.error("Exception during processAfterRetrieve() in OlePaymentRequestDocument", e);
        throw new RuntimeException(e);
    }
}