Example usage for java.util Hashtable get

List of usage examples for java.util Hashtable get

Introduction

In this page you can find the example usage for java.util Hashtable get.

Prototype

@SuppressWarnings("unchecked")
public synchronized V get(Object key) 

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:BeanVector.java

/**
 * This method returns the index of an object representing the
 * mode value of a property name.// w w  w . ja  v  a  2  s  .c  om
 * @param propertyName String value of the property name to calculate.
 * @throws java.lang.IllegalAccessException reflection exception
 * @throws java.beans.IntrospectionException reflection exception
 * @throws java.lang.reflect.InvocationTargetException reflection exception
 * @return int value of the mode index
 */
public int getModeIndex(String propertyName) throws java.lang.IllegalAccessException,
        java.beans.IntrospectionException, java.lang.reflect.InvocationTargetException {
    int index = -1;
    int max = 0;
    int count = 0;
    Object o = null;
    Object hold = null;
    Hashtable cache = new Hashtable();
    String currentClass = "";
    PropertyDescriptor pd = null;
    BeanVector bv = new BeanVector(this.size(), 0, this);
    bv.sortOnProperty(propertyName);

    for (int i = 0; i < bv.size(); i++) {
        if (!currentClass.equals(bv.elementAt(i).getClass().getName())) {
            pd = (PropertyDescriptor) cache.get(bv.elementAt(i).getClass().getName());

            if (pd == null) {
                PropertyDescriptor[] pds = Introspector.getBeanInfo(bv.elementAt(i).getClass())
                        .getPropertyDescriptors();
                boolean foundProperty = false;

                for (int pdi = 0; (pdi < pds.length) && !foundProperty; pdi++) {
                    if (pds[pdi].getName().equals(propertyName)) {
                        pd = pds[pdi];
                        cache.put(bv.elementAt(i).getClass().getName(), pd);
                        foundProperty = true;
                    }
                }
            }
        }

        if (hold == null) {
            hold = pd.getReadMethod().invoke(bv.elementAt(i));
        } else {
            o = pd.getReadMethod().invoke(bv.elementAt(i));

            if ((o != null) && o.equals(hold)) {
                count++;

                if (count > max) {
                    max = count;
                    index = this.indexOf(bv.elementAt(i));
                }
            } else {
                count = 1;
            }

            hold = o;
        }
    }

    return index;
}

From source file:com.ramadda.plugins.investigation.PhoneDbTypeHandler.java

/**
 * _more_/*w ww. j a  v a2s  .co  m*/
 *
 * @param request _more_
 * @param entry _more_
 * @param valueList _more_
 * @param fromSearch _more_
 *
 * @return _more_
 *
 * @throws Exception _more_
 */
public Result handleCallListing(Request request, Entry entry, List<Object[]> valueList, boolean fromSearch)
        throws Exception {

    Hashtable<String, Number> numberMap = new Hashtable<String, Number>();
    List<Number> numbers = new ArrayList<Number>();
    StringBuilder sb = new StringBuilder();
    addViewHeader(request, entry, sb, VIEW_CALL_LISTING, valueList.size(), fromSearch);

    for (Object[] tuple : valueList) {
        String fromNumber = fromNumberColumn.getString(tuple);

        Number from = numberMap.get(fromNumber);
        if (from == null) {
            from = new Number(fromNumber, fromNameColumn.getString(tuple));
            numbers.add(from);
            numberMap.put(from.number, from);
        }
        String toNumber = toNumberColumn.getString(tuple);
        Number to = numberMap.get(toNumber);
        if (to == null) {
            to = new Number(toNumber, toNameColumn.getString(tuple));
            numbers.add(to);
            numberMap.put(to.number, to);
        }
        String date = dateColumn.getString(tuple);
        from.addOutbound(to, tuple);
        to.addInbound(from, tuple);
    }

    SimpleDateFormat sdf = getDateFormat(entry);

    Collections.sort(numbers);
    for (Number n : numbers) {
        //Only show numbers with outbounds
        if ((n.outbound.size() <= 1) && (n.inbound.size() <= 1)) {
            continue;
        }

        sb.append(HtmlUtils.p());
        sb.append(HtmlUtils.div(getTitle(n), HtmlUtils.cssClass("ramadda-heading-1")));

        if (n.outbound.size() > 0) {
            sb.append(HtmlUtils.open(HtmlUtils.TAG_DIV, HtmlUtils.style("margin-top:0px;margin-left:20px;")));
            StringBuilder numberSB = new StringBuilder("<table cellspacing=5 width=100%>");
            for (Number outbound : n.getSortedOutbound()) {
                numberSB.append("<tr valign=top><td width=10%>");
                String searchUrl = HtmlUtils.url(request.makeUrl(getRepository().URL_ENTRY_SHOW),
                        new String[] { ARG_ENTRYID, entry.getId(), ARG_DB_SEARCH, "true",
                                getSearchUrlArgument(fromNumberColumn), n.number, toNumberColumn.getSearchArg(),
                                outbound.number, });

                numberSB.append(HtmlUtils.href(searchUrl, getTitle(outbound)));
                numberSB.append("</td>");

                List<Object[]> calls = n.getOutboundCalls(outbound);
                StringBuilder callSB = new StringBuilder();
                for (Object[] values : calls) {
                    StringBuilder dateSB = new StringBuilder();
                    dateColumn.formatValue(entry, dateSB, Column.OUTPUT_HTML, values, sdf);
                    StringBuilder html = new StringBuilder();
                    getHtml(request, html, entry, values);
                    callSB.append(HtmlUtils.makeShowHideBlock(dateSB.toString(),
                            HtmlUtils.insetLeft(
                                    HtmlUtils.div(html.toString(), HtmlUtils.cssClass("ramadda-popup-box")),
                                    10),
                            false));
                }
                numberSB.append("<td width=5% align=right>");
                numberSB.append(calls.size());
                numberSB.append("</td><td width=85%>");
                numberSB.append(HtmlUtils.makeShowHideBlock("Details",
                        HtmlUtils.insetLeft(callSB.toString(), 10), false));
                numberSB.append("</td></tr>");
            }
            numberSB.append("</table>");
            sb.append(HtmlUtils.makeShowHideBlock("Outbound", HtmlUtils.insetLeft(numberSB.toString(), 10),
                    true));
            sb.append(HtmlUtils.close(HtmlUtils.TAG_DIV));
        }

        if (n.inbound.size() > 0) {
            sb.append(HtmlUtils.open(HtmlUtils.TAG_DIV, HtmlUtils.style("margin-top:0px;margin-left:20px;")));
            StringBuilder numberSB = new StringBuilder("<table cellspacing=5 width=100%>");
            for (Number inbound : n.getSortedInbound()) {
                numberSB.append("<tr valign=top><td width=10%>");
                String searchUrl = HtmlUtils.url(request.makeUrl(getRepository().URL_ENTRY_SHOW),
                        new String[] { ARG_ENTRYID, entry.getId(), ARG_DB_SEARCH, "true",
                                getSearchUrlArgument(fromNumberColumn), n.number, toNumberColumn.getSearchArg(),
                                inbound.number, });

                numberSB.append(HtmlUtils.href(searchUrl, getTitle(inbound)));
                numberSB.append("</td>");

                List<Object[]> calls = n.getInboundCalls(inbound);
                StringBuilder callSB = new StringBuilder();
                for (Object[] values : calls) {
                    StringBuilder dateSB = new StringBuilder();
                    dateColumn.formatValue(entry, dateSB, Column.OUTPUT_HTML, values, sdf);
                    StringBuilder html = new StringBuilder();
                    getHtml(request, html, entry, values);
                    callSB.append(HtmlUtils.makeShowHideBlock(dateSB.toString(),
                            HtmlUtils.insetLeft(
                                    HtmlUtils.div(html.toString(), HtmlUtils.cssClass("ramadda-popup-box")),
                                    10),
                            false));
                }
                numberSB.append("<td width=5% align=right>");
                numberSB.append(calls.size());
                numberSB.append("</td><td width=85%>");
                numberSB.append(HtmlUtils.makeShowHideBlock("Details",
                        HtmlUtils.insetLeft(callSB.toString(), 10), false));
                numberSB.append("</td></tr>");
            }
            numberSB.append("</table>");
            sb.append(
                    HtmlUtils.makeShowHideBlock("Inbound", HtmlUtils.insetLeft(numberSB.toString(), 10), true));
            sb.append(HtmlUtils.close(HtmlUtils.TAG_DIV));
        }

    }

    return new Result(getTitle(request, entry), sb);
}

From source file:com.krawler.spring.crm.common.documentController.java

public ModelAndView downloadDocuments(HttpServletRequest request, HttpServletResponse response)
        throws ServletException {
    JSONObject jobj = new JSONObject();
    JSONObject myjobj = new JSONObject();
    KwlReturnObject kmsg = null;//from  w  w  w  .jav  a 2s.c om
    String details = "";
    String auditAction = "";
    try {
        String url = request.getParameter("url");
        url = StringUtil.checkForNull(url);
        kmsg = crmDocumentDAOObj.downloadDocument(url);
        Hashtable ht = getDocumentDownloadHash(kmsg.getEntityList());
        String src = storageHandlerImplObj.GetDocStorePath();
        //            String src = "/home/trainee/";
        if (request.getParameter("mailattch") != null) {
            src = src + ht.get("svnname");
        } else {
            src = src + ht.get("userid").toString() + "/" + ht.get("svnname");
        }

        File fp = new File(src);
        byte[] buff = new byte[(int) fp.length()];
        FileInputStream fis = new FileInputStream(fp);
        int read = fis.read(buff);
        javax.activation.FileTypeMap mmap = new javax.activation.MimetypesFileTypeMap();
        response.setContentType(mmap.getContentType(src));
        response.setContentLength((int) fp.length());
        response.setHeader("Content-Disposition",
                request.getParameter("dtype") + "; filename=\"" + ht.get("Name") + "\";");
        response.getOutputStream().write(buff);
        response.getOutputStream().flush();
        response.getOutputStream().close();
        String map = ht.get("relatedto").toString();
        String refid = ht.get("recid").toString();

        if (map.equals("0")) {
            CrmCampaign c = (CrmCampaign) hibernateTemplate.get(CrmCampaign.class, refid);
            details = " Campaign - ";
            details += StringUtil.isNullOrEmpty(c.getCampaignname()) ? "" : c.getCampaignname();
            auditAction = AuditAction.CAMPAIGN_DOC_DOWNLOAD;
        } else if (map.equals("1")) {
            CrmLead l = (CrmLead) hibernateTemplate.get(CrmLead.class, refid);
            details = " Lead - ";
            details += StringUtil.isNullOrEmpty(l.getFirstname()) ? "" : l.getFirstname() + " ";
            details += StringUtil.isNullOrEmpty(l.getLastname()) ? "" : l.getLastname();
            auditAction = AuditAction.LEAD_DOC_DOWNLOAD;
        } else if (map.equals("2")) {
            CrmContact c = (CrmContact) hibernateTemplate.get(CrmContact.class, refid);
            details = " Contact - ";
            details += StringUtil.isNullOrEmpty(c.getFirstname()) ? "" : c.getFirstname() + " ";
            details += StringUtil.isNullOrEmpty(c.getLastname()) ? "" : c.getLastname();
            auditAction = AuditAction.CONTACT_DOC_DOWNLOAD;
        } else if (map.equals("3")) {
            CrmProduct p = (CrmProduct) hibernateTemplate.get(CrmProduct.class, refid);
            details = " Product - ";
            details += StringUtil.isNullOrEmpty(p.getProductname()) ? "" : p.getProductname();
            auditAction = AuditAction.PRODUCT_DOC_DOWNLOAD;
        } else if (map.equals("4")) {
            CrmAccount a = (CrmAccount) hibernateTemplate.get(CrmAccount.class, refid);
            details = " Account - ";
            details += StringUtil.isNullOrEmpty(a.getAccountname()) ? "" : a.getAccountname();
            auditAction = AuditAction.ACCOUNT_DOC_DOWNLOAD;
        } else if (map.equals("5")) {
            CrmOpportunity o = (CrmOpportunity) hibernateTemplate.get(CrmOpportunity.class, refid);
            details = " Opportunity - ";
            details += StringUtil.isNullOrEmpty(o.getOppname()) ? "" : o.getOppname();
            auditAction = AuditAction.OPPORTUNITY_DOC_DOWNLOAD;
        } else if (map.equals("6")) {
            CrmCase c = (CrmCase) hibernateTemplate.get(CrmCase.class, refid);
            details = " Case - ";
            details += StringUtil.isNullOrEmpty(c.getSubject()) ? "" : c.getSubject();
            auditAction = AuditAction.CASE_DOC_DOWNLOAD;
        } else if (map.equals("7")) {
            CrmActivityMaster am = (CrmActivityMaster) hibernateTemplate.get(CrmActivityMaster.class, refid);
            details = " Activity - ";
            details += StringUtil.isNullOrEmpty(am.getFlag()) ? "" : am.getFlag() + " ";
            details += StringUtil.isNullOrEmpty(am.getCrmCombodataByStatusid().getValue()) ? ""
                    : am.getCrmCombodataByStatusid().getValue();
            auditAction = AuditAction.ACTIVITY_DOC_DOWNLOAD;
        } else if (map.equals("-1")) {
            details = " My - Document ";
            auditAction = AuditAction.MY_DOC_DOWNLOAD;
        }

        auditTrailDAOObj.insertAuditLog(auditAction,
                " Document - '" + ht.get("Name").toString() + "' downloaded for " + details + " ", request,
                ht.get("docid").toString());

        myjobj.put("success", true);
    } catch (Exception e) {
        logger.warn(e.getMessage(), e);
    }
    return new ModelAndView("jsonView", "model", myjobj.toString());
}

From source file:eionet.gdem.dcm.business.SchemaManager.java

/**
 * Get XML Schema and related stylesheets information.
 * @param schema XML Schema URL or database ID.
 * @return StylesheetListHolder object holding schema stylesheet and user permission information
 * @throws DCMException in case of database error occurs.
 *//*from w  w  w.jav a 2  s  .c  o  m*/
public StylesheetListHolder getSchemaStylesheetsList(String schema) throws DCMException {
    StylesheetListHolder st = new StylesheetListHolder();

    ArrayList<Schema> schemas;

    try {

        schemas = new ArrayList<Schema>();

        String schemaId = schemaDao.getSchemaID(schema);

        if (schemaId == null) {
            st.setHandcoded(false);
        } else {
            st.setHandcoded(true);
        }

        ConversionServiceIF cs = new ConversionService();
        Vector stylesheets = cs.listConversions(schema);
        ArrayList<Stylesheet> stls = new ArrayList<Stylesheet>();
        Schema sc = new Schema();
        sc.setId(schemaId);
        sc.setSchema(schema);

        for (int i = 0; i < stylesheets.size(); i++) {
            Hashtable hash = (Hashtable) stylesheets.get(i);
            String xsl = (String) hash.get("xsl");
            String type;
            String lastModified = "";
            boolean ddConv = false;
            String xslUrl;

            if (!xsl.startsWith(Properties.gdemURL + "/do/getStylesheet?id=")) {

                File f = new File(Properties.xslFolder + File.separatorChar + xsl);
                if (f != null && f.exists()) {
                    lastModified = Utils.getDateTime(new Date(f.lastModified()));
                }
                // DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(new Date(f.lastModified()));
                xslUrl = Names.XSL_FOLDER + (String) hash.get("xsl");
                type = (String) hash.get("result_type");
            } else {
                xslUrl = (String) hash.get("xsl");
                ddConv = true;
                type = (String) hash.get("result_type");
            }

            Stylesheet stl = new Stylesheet();
            // st.setConvId(1);
            stl.setType(type);
            stl.setXsl(xslUrl);
            stl.setXslFileName(xsl);
            stl.setDescription((String) hash.get("description"));
            stl.setModified(lastModified);
            stl.setConvId((String) hash.get("convert_id"));
            stl.setDdConv(ddConv);
            stls.add(stl);

        }
        if (stls.size() > 0) {
            sc.setStylesheets(stls);
        }
        schemas.add(sc);
        st.setHandCodedStylesheets(schemas);
    } catch (Exception e) {
        LOGGER.debug("Errror getting schema stylesheets", e);
        throw new DCMException(BusinessConstants.EXCEPTION_GENERAL);
    }
    return st;
}

From source file:com.flipzu.flipzu.Player.java

private void displayComment(Hashtable<String, String> comment) {
    if (comment == null)
        return;//from w  w  w.  j a va  2 s.  c o  m

    final LinearLayout com_layout = (LinearLayout) findViewById(R.id.comments_layout);
    TextView comment_tv = new TextView(Player.this);
    comment_tv.setText(comment.get("username") + ": " + comment.get("comment"), TextView.BufferType.SPANNABLE);
    comment_tv.setTextColor(Color.parseColor("#656565"));
    Spannable comment_span = (Spannable) comment_tv.getText();
    comment_span.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, comment_tv.getText().length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    comment_span.setSpan(new ForegroundColorSpan(Color.parseColor("#597490")), 0,
            comment.get("username").length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    comment_tv.setText(comment_span);
    com_layout.addView(comment_tv);
}

From source file:ca.queensu.cs.sail.mailboxmina2.main.modules.ThreadsModule.java

/** This method calculates all roots for the given messages in messageData
 * and stores this information in the database
 * @param messages a list of Messages//from w  ww  . j  ava2s . c  o  m
 * @throws SQLException if there was an error with the database
 */
private void calculateRoots(List<MM2Message> messages, Connection connection) throws SQLException {
    // Needed Data Structures
    Hashtable<String, String> parentsTable = new Hashtable<String, String>();
    Hashtable<String, String> rootsTable = new Hashtable<String, String>();

    // Build up parents table form database
    String query = "SELECT * FROM parent";
    Statement stmt = connection.createStatement();
    ResultSet results = stmt.executeQuery(query);
    while (results.next()) {
        parentsTable.put(results.getString("msg_id"), results.getString("parent_id"));
    }

    Main.getLogger().debug(3, parentsTable.keySet().size() + " parent relations are known!");

    // Calculate all roots
    for (MM2Message msg : messages) {
        String msgUID = msg.getHeaderEntry("msg_id");
        String rootUID = msgUID;
        if (parentsTable.containsKey(msgUID)) {
            Set<String> seenParents = new HashSet<String>();

            String myParent = parentsTable.get(msgUID);
            seenParents.add(myParent);
            while (myParent != null) {
                rootUID = myParent;
                myParent = parentsTable.get(myParent);
                if (seenParents.contains(myParent)) {
                    Main.getLogger().log("Parents Cycle: " + rootUID + " " + myParent);
                    break;
                } else {
                    seenParents.add(myParent);
                }
            }
        }
        rootsTable.put(msgUID, rootUID);
    }
    Main.getLogger().log("Storing " + rootsTable.keySet().size() + " roots in database...");
    storeRoots(rootsTable, connection);
}

From source file:com.seachangesimulations.platform.domain.Plugin.java

/**
 * Assumes that the plugin itself has been saved (so its id has been set.)
 * //from w w w .ja va2 s  .c o m
 */
@Override
public void saveSubObjects() {

    String baseFromDirectory = PlatformProperties.getValue("pluginSourceDirectory") + File.separator
            + this.getPluginOriginDirectory() + File.separator;
    String baseToDirectory = PlatformProperties.getValue("pluginFileDirectory") + File.separator;

    Hashtable<String, PluginObjectDocument> pluginObjectsReadIn = new Hashtable();

    // Get all objects and hold them in memory.
    for (Object pluginObject : this.getPluginObjects()) {

        if (true) {
            PluginObjectDocument pod = (PluginObjectDocument) pluginObject;
            String key = pluginObject.getClass().getCanonicalName() + "_" + pod.getId();
            System.out.println("KKKKKKKKKKKKKKKKKey was : " + key);
            pluginObjectsReadIn.put(key, pod);

        }

    }
    // Get all object associations and look up the objects read in in the previous step
    // Then save the object and the object association.
    for (PluginObjectAssociation poa : this.getPluginObjectAssociations()) {

        poa.setPluginId(this.id);
        String key = poa.getObjectType() + "_" + poa.getObjectId();
        System.out.println("LLLLLLLLLLLLLLLLLLKey was : " + key);
        PluginObjectDocument pod = pluginObjectsReadIn.get(key);

        // Remove any id that the plugin object may have had associated before. It will be different here.
        pod.setId(null);
        pod.setVersion(null);

        pod.save();

        poa.setObjectId(pod.getId());
        poa.setId(null);
        poa.setVersion(null);
        poa.save();

    }

    // Get all files and save them.
    for (PluginFileDescriptor pfd : this.getPluginFiles()) {

        String readingFromFileName = baseFromDirectory + pfd.getFilePath() + File.separator + pfd.getFileName();
        System.out.println("reading plugin file " + readingFromFileName);

        String savingToFileName = baseToDirectory + this.generatePluginDirectory() + File.separator
                + pfd.getFileName();
        System.out.println("saving plugin file " + savingToFileName);

        try {
            FileUtils.copyFile(new File(readingFromFileName), new File(savingToFileName));
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
    // Get all objects from list and save them.

}

From source file:edu.mayo.informatics.lexgrid.convert.directConversions.obo1_2.OBO2LGDynamicMapHolders.java

public void storeConceptAndRelations(OBOResourceReader oboReader, OBOTerm oboTerm, CodingScheme csclass) {
    try {/*from ww  w.j a  v  a  2s.co  m*/
        // OBO Term should not be null and either one of ID or term name
        // should be there.
        OBOContents contents = oboReader.getContents(false, false);
        if ((oboTerm != null)
                && ((!OBO2LGUtils.isNull(oboTerm.getId())) || (!OBO2LGUtils.isNull(oboTerm.getName())))) {
            propertyCounter = 0;

            Entity concept = new Entity();
            concept.setEntityType(new String[] { EntityTypes.CONCEPT.toString() });
            concept.setEntityCodeNamespace(csclass.getCodingSchemeName());

            if (!OBO2LGUtils.isNull(oboTerm.getId()))
                concept.setEntityCode(oboTerm.getId());
            else
                concept.setEntityCode(oboTerm.getName());

            String termDesc = "";

            if (!OBO2LGUtils.isNull(oboTerm.getName()))
                termDesc = oboTerm.getName();
            else
                termDesc = oboTerm.getId();

            EntityDescription ed = new EntityDescription();
            ed.setContent(termDesc);
            concept.setEntityDescription(ed);

            if (oboTerm.isObsolete()) {
                concept.setIsActive(new Boolean(false));
            }
            Presentation tp = new Presentation();
            Text txt = new Text();
            txt.setContent(termDesc);
            tp.setValue(txt);
            tp.setIsPreferred(new Boolean(true));
            tp.setPropertyName(OBO2LGConstants.PROPERTY_TEXTPRESENTATION);

            String preferredPresetationID = OBO2LGConstants.PROPERTY_ID_PREFIX + (++propertyCounter);
            tp.setPropertyId(preferredPresetationID);
            concept.getPresentationAsReference().add(tp);

            if (!OBO2LGUtils.isNull(oboTerm.getComment())) {
                Comment comment = new Comment();
                txt = new Text();
                txt.setContent(OBO2LGUtils.removeInvalidXMLCharacters(oboTerm.getComment(), null));
                comment.setValue(txt);
                comment.setPropertyName(OBO2LGConstants.PROPERTY_COMMENT);
                comment.setPropertyId(OBO2LGConstants.PROPERTY_ID_PREFIX + (++propertyCounter));
                concept.getCommentAsReference().add(comment);
            }

            if (!OBO2LGUtils.isNull(oboTerm.getDefinition())) {
                Definition defn = new Definition();
                txt = new Text();
                txt.setContent(OBO2LGUtils.removeInvalidXMLCharacters(oboTerm.getDefinition(), null));
                defn.setValue(txt);
                defn.setPropertyName(OBO2LGConstants.PROPERTY_DEFINITION);
                defn.setPropertyId(OBO2LGConstants.PROPERTY_ID_PREFIX + (++propertyCounter));
                concept.getDefinitionAsReference().add(defn);

                OBOAbbreviations abbreviations = contents.getOBOAbbreviations();
                addOBODbxrefAsSource(defn, oboTerm.getDefinitionSources(), abbreviations);

            }

            addPropertyAttribute(oboTerm.getSubset(), concept, OBO2LGConstants.PROPERTY_SUBSET);
            Vector<String> dbxref_src_vector = OBODbxref.getSourceAndSubRefAsVector(oboTerm.getDbXrefs());
            addPropertyAttribute(dbxref_src_vector, concept, "xref");
            // Add Synonyms as presentations
            Vector<OBOSynonym> synonyms = oboTerm.getSynonyms();

            if ((synonyms != null) && (!synonyms.isEmpty())) {
                for (OBOSynonym synonym : synonyms) {
                    Presentation ip = new Presentation();
                    txt = new Text();
                    txt.setContent(synonym.getText());
                    ip.setValue(txt);
                    ip.setPropertyName(OBO2LGConstants.PROPERTY_SYNONYM);
                    String synPresID = OBO2LGConstants.PROPERTY_ID_PREFIX + (++propertyCounter);
                    ip.setPropertyId(synPresID);
                    concept.getPresentationAsReference().add(ip);

                    String scope = synonym.getScope();
                    if (scope != null && scope.length() > 0)
                        ip.setDegreeOfFidelity(scope);

                    // Add source information
                    Vector<OBODbxref> dbxref = OBODbxref.parse(synonym.getDbxref());
                    OBOAbbreviations abbreviations = contents.getOBOAbbreviations();
                    addOBODbxrefAsSource(ip, dbxref, abbreviations);

                }
            }

            Vector<String> vec_altIds = oboTerm.getAltIds();

            if ((vec_altIds != null) && (!vec_altIds.isEmpty())) {
                for (String altId : vec_altIds) {

                    if (StringUtils.isNotBlank(altId)) {

                        Property emfProp = new Property();
                        emfProp.setPropertyName(OBO2LGConstants.PROPERTY_ALTID);
                        String prop_id = OBO2LGConstants.PROPERTY_ID_PREFIX + (++propertyCounter);
                        emfProp.setPropertyId(prop_id);

                        txt = new Text();
                        txt.setContent(altId);
                        emfProp.setValue(txt);

                        concept.getPropertyAsReference().add(emfProp);

                    }
                }
            }

            String created_by = oboTerm.getCreated_by();
            if (StringUtils.isNotBlank(created_by)) {
                addPropertyAttribute(created_by, concept, OBO2LGConstants.PROPERTY_CREATED_BY);

            }

            String creation_date = oboTerm.getCreation_date();
            if (StringUtils.isNotBlank(creation_date)) {
                addPropertyAttribute(creation_date, concept, OBO2LGConstants.PROPERTY_CREATION_DATE);
            }

            Hashtable<String, Vector<String>> relationships = oboTerm.getRelationships();
            if (relationships != null) {
                for (Enumeration<String> e = relationships.keys(); e.hasMoreElements();) {
                    String relName = e.nextElement();
                    OBORelations relations = contents.getOBORelations();
                    OBORelation relation = relations.getMemberById(relName);
                    Vector<String> targets = relationships.get(relName);
                    if (targets != null) {
                        addAssociationAttribute(concept, relation, targets);
                    }
                }
            }

            codedEntriesList.add(concept);

        }
    }

    catch (Exception e) {
        e.printStackTrace();
        messages_.info("Failed to store concept " + oboTerm.getName() + "(" + oboTerm.getId() + ")");
    }
}

From source file:hu.sztaki.lpds.pgportal.portlets.workflow.RealWorkflowPortlet.java

/**
 * Workflow exportalas az ETICS rendszerbe (singlenode & multinode tipusu WF)
public void doExportEtics(ActionRequest request, ActionResponse response) throws PortletException {
String msg = new String("");/*  ww  w  .  ja  v a  2s.  c om*/
String retString = "";
try {
    String portalID = new String("http://hostURL:8080/portal30");
    String wfsServiceURL = new String("http://hostURL:8080/wfs");
    String wfsServiceID = new String("/services/urn:wfswfiservice");
    String clientObject = new String("hu.sztaki.lpds.wfs.net.wsaxis13.WfiWfsClientImpl");
    //
        
    WorkflowData wData=PortalCacheService.getInstance().getUser(request.getRemoteUser()).getWorkflow(request.getParameter("workflow"));
    //
        
    Hashtable hsh = new Hashtable();
    hsh.put("url", wData.getWfsID());// PortalCacheService.getInstance().getUser(req.getRemoteUser()).getWorkflow(wfID).getWfsID()
    ServiceType st = InformationBase.getI().getService("wfs", "wfi", hsh, new Vector());
        
        
    WfiWfsClient client = (WfiWfsClient) Class.forName(st.getClientObject()).newInstance();
    client.setServiceURL(st.getServiceUrl());
    client.setServiceID(st.getServiceID());
    //
    ComDataBean comBean = new ComDataBean();
    comBean.setPortalID(PropertyLoader.getInstance().getProperty("service.url"));//portalID
    comBean.setWorkflowtype(wData.getWorkflowType());//"workflowType"
    comBean.setWorkflowID(wData.getWorkflowID());//"workflowID"
    comBean.setGraf(wData.getGraf());//"grafID"
    comBean.setUserID(request.getRemoteUser());//"userID"
    //
    retString = client.getWfiXML(comBean);
    msg=EticsCacheService.getInstance().processWorkflowXml(retString, request.getRemoteUser());
            
    //
} catch (Exception e) {
    e.printStackTrace();
    msg = e.getLocalizedMessage();
}
setRequestAttribute(request.getPortletSession(),"msg",msg);
}
 */

@Override
public void serveResource(ResourceRequest request, ResourceResponse response)
        throws PortletException, IOException {
    String key;
    if ("editgraphURL".equals(request.getResourceID()) && request.getParameter("wfId") != null) {
        GraphEditorUtil.jnpl(request, response);
        return;
    }

    if ("refreshConfigURL".equals(request.getResourceID())) {
        List<String> graphs = new ArrayList<String>();
        Enumeration<String> enm = PortalCacheService.getInstance().getUser(request.getRemoteUser())
                .getAbstactWorkflows().keys();
        while (enm.hasMoreElements())
            graphs.add(enm.nextElement());

        request.setAttribute("graphs", graphs);
        request.setAttribute("workflow", request.getPortletSession().getAttribute("cworkflow"));
        getPortletContext().getRequestDispatcher("/jsp/workflow/accepteditedgraph.jsp").include(request,
                response);
        return;
    }

    // ajax help
    if (request.getParameter("helptext") != null) {
        super.serveResource(request, response);
        return;
    }
    //output download
    if (request.getParameter("downloadType") != null) {
        response.setContentType("application/zip");
        response.setProperty("Content-Disposition", "inline; filename=\"" + request.getParameter("workflowID")
                + "_" + request.getParameter("jobID") + "_" + request.getParameter("pidID") + "_outputs.zip\"");
        try {
            HttpDownload.fileDownload(request.getParameter("downloadType"), request, response);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PortletException("com error");
        }
        return;
    }
    // logs download  
    if (request.getParameter("fileID") != null) {
        response.setContentType("application/text");
        response.setProperty("Content-Disposition",
                "inline; filename=\"" + request.getParameter("workflowID") + "_" + request.getParameter("jobID")
                        + "_" + request.getParameter("pidID") + "_" + request.getParameter("fileID")
                        + ".txt\"");
        try {
            HttpDownload.fileView(request, response);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PortletException("com error");
        }
        return;
    }

    // file upload status
    if (request.getParameter("uploadStatus") != null) {
        PortletSession ps = request.getPortletSession();
        // end of download
        if (ps.getAttribute("finaluploads") != null) {
            ps.removeAttribute("finaluploads");
            ps.removeAttribute("uploaded");
            ps.removeAttribute("upload");
            ps.removeAttribute("uploading");
            response.getWriter().write("Upload");

        } else {
            try {
                Vector<String> tmp = (Vector<String>) ps.getAttribute("uploaded");
                response.getWriter().write("&nbsp;<br/>");
                for (String t : tmp)
                    response.getWriter().write("uploaded:" + t + "<br/>");
                FileUploadProgressListener lisener = (FileUploadProgressListener) ((PortletFileUpload) ps
                        .getAttribute("upload")).getProgressListener();
                byte uplStatus = Byte.parseByte(lisener.getFileuploadstatus());
                response.getWriter()
                        .write("uploading:" + ps.getAttribute("uploading") + "->" + "<div style=\"width:"
                                + uplStatus + "px;background-color:blue; \" >" + uplStatus + "%<br/>");
            } catch (Exception ee) {
                System.out.println("file upload has not yet begun " + ps.getId());
                ee.printStackTrace();
            }
        }
        return;
    }
    // configuration
    Hashtable reqhash = new Hashtable();
    Enumeration enm0 = request.getParameterNames();
    while (enm0.hasMoreElements()) {
        key = "" + enm0.nextElement();
        reqhash.put(key, request.getParameter(key));
    }
    reqhash.put("sid", request.getPortletSession().getId());
    try {
        ActionHandler t = null;
        try {
            String sid = request.getPortletSession().getId();
            String workflowName = "" + request.getPortletSession().getAttribute("cworkflow");
            String username = request.getRemoteUser();
            String wftype;
            PortletSession ps = request.getPortletSession();
            if (request.getPortletSession().getAttribute("cworkflow") == null) {
                System.out.println(
                        "RealWFPortlet-serveresource- request.getPortletSession().getAttribute(cworkflow)==null !!!!!!!! try cworkflow1");
                System.out.println("cworkflow1:" + ps.getAttribute("cworkflow1", ps.APPLICATION_SCOPE));
                workflowName = "" + ps.getAttribute("cworkflow1", ps.APPLICATION_SCOPE);
                if (ps.getAttribute("cworkflow1", ps.APPLICATION_SCOPE) != null) {
                    request.getPortletSession().setAttribute("cworkflow", workflowName);
                }
            }
            wftype = PortalCacheService.getInstance().getUser(username).getWorkflow(workflowName)
                    .getWorkflowType();
            reqhash.put("ws-pgrade.wftype", wftype);
            t = (ActionHandler) Class.forName(
                    "hu.sztaki.lpds.pgportal.servlet.ajaxactions." + wftype + "." + request.getParameter("m"))
                    .newInstance();
            //                System.out.println("***SERVE-RESOURCE:"+t.getClass().getName());

        } catch (Exception e) {
            try {
                t = (ActionHandler) Class
                        .forName("hu.sztaki.lpds.pgportal.servlet.ajaxactions." + request.getParameter("m"))
                        .newInstance();
                //                    System.out.println("***SERVE-RESOURCE:"+t.getClass().getName());
            } catch (ClassNotFoundException e0) {
                System.out.println("classnotfound");
                e0.printStackTrace();
            } catch (InstantiationException e0) {
                e0.printStackTrace();
                System.out.println("---Init error:hu.sztaki.lpds.pgportal.servlet.ajaxactions."
                        + request.getParameter("m"));
                e0.printStackTrace();
            } catch (IllegalAccessException e0) {
                e0.printStackTrace();
                System.out.println("---Illegal Access:hu.sztaki.lpds.pgportal.servlet.ajaxactions."
                        + request.getParameter("m"));
                e0.printStackTrace();
            }
        }
        try {
            // Session transfer
            t.setSessionVariables(request.getPortletSession());
            // Parameter setting 
            reqhash.put("user", request.getRemoteUser());
            if (request.getPortletSession().getAttribute("cworkflow") != null)
                reqhash.put("workflow", request.getPortletSession().getAttribute("cworkflow"));
            if (request.getPortletSession().getAttribute("detailsruntime") != null)
                reqhash.put("detailsruntime", request.getPortletSession().getAttribute("detailsruntime"));
        } catch (Exception e) {
            e.printStackTrace();
        }
        // Content transfer
        if (t.getDispacher(reqhash) == null) {
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
            try {
                out.print(t.getOutput(reqhash));
            } catch (Exception e) {
                e.printStackTrace();
            }
            out.close();
        }
        // Transfer of controlling 
        else {
            Hashtable res = t.getParameters(reqhash);
            Enumeration enm = res.keys();
            while (enm.hasMoreElements()) {
                key = "" + enm.nextElement();
                request.setAttribute(key, res.get(key));
            }
            PortletRequestDispatcher dispatcher = getPortletContext()
                    .getRequestDispatcher(t.getDispacher(reqhash));
            dispatcher.include(request, response);
        }
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("-----------------------Can not be initialized:" + request.getParameter("m"));
    }

}

From source file:net.zypr.api.Protocol.java

public JSONObject doStreamPost(APIVerbs apiVerb, Hashtable<String, String> urlParameters,
        Hashtable<String, String> postParameters, InputStream inputStream)
        throws APICommunicationException, APIProtocolException {
    if (!_apiEntity.equalsIgnoreCase("voice"))
        Session.getInstance().addActiveRequestCount();
    long t1 = System.currentTimeMillis();
    JSONObject jsonObject = null;/*from   w ww.ja  v  a2s. c om*/
    JSONParser jsonParser = new JSONParser();
    try {
        DefaultHttpClient httpclient = getHTTPClient();
        HttpPost httpPost = new HttpPost(buildURL(apiVerb, urlParameters));
        HttpProtocolParams.setUseExpectContinue(httpPost.getParams(), false);
        MultipartEntity multipartEntity = new MultipartEntity();
        if (postParameters != null)
            for (Enumeration enumeration = postParameters.keys(); enumeration.hasMoreElements();) {
                String key = enumeration.nextElement().toString();
                String value = postParameters.get(key);
                multipartEntity.addPart(key, new StringBody(value));
                Debug.print("HTTP POST : " + key + "=" + value);
            }
        if (inputStream != null) {
            InputStreamBody inputStreamBody = new InputStreamBody(inputStream, "binary/octet-stream");
            multipartEntity.addPart("audio", inputStreamBody);
        }
        httpPost.setEntity(multipartEntity);
        HttpResponse httpResponse = httpclient.execute(httpPost);
        if (httpResponse.getStatusLine().getStatusCode() != 200)
            throw new APICommunicationException("HTTP Error " + httpResponse.getStatusLine().getStatusCode()
                    + " - " + httpResponse.getStatusLine().getReasonPhrase());
        HttpEntity httpEntity = httpResponse.getEntity();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpEntity.getContent()));
        jsonObject = (JSONObject) jsonParser.parse(bufferedReader);
        bufferedReader.close();
        httpclient.getConnectionManager().shutdown();
    } catch (ParseException parseException) {
        throw new APIProtocolException(parseException);
    } catch (IOException ioException) {
        throw new APICommunicationException(ioException);
    } catch (ClassCastException classCastException) {
        throw new APIProtocolException(classCastException);
    } finally {
        if (!_apiEntity.equalsIgnoreCase("voice"))
            Session.getInstance().removeActiveRequestCount();
        long t2 = System.currentTimeMillis();
        Debug.print(buildURL(apiVerb, urlParameters) + " : " + t1 + "-" + t2 + "=" + (t2 - t1) + " : "
                + jsonObject);
    }
    return (jsonObject);
}