Package org.wso2.carbon.registry.core.jdbc.dataobjects

Examples of org.wso2.carbon.registry.core.jdbc.dataobjects.RatingDO


    }

    public byte[] getProcessImage(String processId) {

        QName qName = decode(processId);
        SVGInterface svg = createSVG(qName);
        return svg.toPNGBytes();
    }
View Full Code Here


    private SVGInterface createSVG(QName qName) {

        // generate new
        InputStream in = getBpelDescriptor(qName);

        SVGInterface svg = null;

        try {
            svg = BPEL2SVGUtil.generate(in);

            if (svg == null)
View Full Code Here

   
    protected static SVGImpl generateSVGImpl(java.io.InputStream is) throws java.io.IOException {
      byte[] b=new byte[is.available()];
      is.read(b);
   
      BPELInterface bpel = new BPELImpl();
        OMElement bpelStr = bpel.load(new String(b));
       
        bpel.processBpelString(bpelStr);

        LayoutManager layoutManager = BPEL2SVGFactory.getInstance().getLayoutManager();
        layoutManager.setVerticalLayout(true);
        layoutManager.setYSpacing(20);
        layoutManager.setYSpacing(50);
        layoutManager.layoutSVG(bpel.getRootActivity());

        SVGImpl svg = new SVGImpl();
        svg.setRootActivity(bpel.getRootActivity());
       
        return(svg);
    }
View Full Code Here

   * @param transformer The optional image transformer
   * @throws java.io.IOException Failed to generate the representation
   */
    public static void generate(java.io.InputStream is, java.io.OutputStream os,
                SVGImageTransformer transformer) throws java.io.IOException {
        SVGImpl svg = generateSVGImpl(is);
       
        if (transformer == null) {
          String str=svg.getHeaders()+svg.generateSVGString();
          os.write(str.getBytes());
        } else {
          transformer.transform(svg, os);
        }
    }
View Full Code Here

        layoutManager.setVerticalLayout(true);
        layoutManager.setYSpacing(20);
        layoutManager.setYSpacing(50);
        layoutManager.layoutSVG(bpel.getRootActivity());

        SVGImpl svg = new SVGImpl();
        svg.setRootActivity(bpel.getRootActivity());
       
        return(svg);
    }
View Full Code Here

                do {
                    xmlReader.next();
                } while (!xmlReader.isStartElement() && xmlReader.hasNext());
                while (xmlReader.hasNext() &&
                        xmlReader.getLocalName().equals(DumpConstants.RATING_ENTRY)) {
                    RatingDO ratingDO = new RatingDO();

                    do {
                        xmlReader.next();
                    } while (!xmlReader.isStartElement() && xmlReader.hasNext());

                    localName = xmlReader.getLocalName();
                    while (xmlReader.hasNext() &&
                            (localName.equals(DumpConstants.RATING_ENTRY_USER) ||
                                    localName.equals(DumpConstants.RATING_ENTRY_DATE) ||
                                    localName.equals(DumpConstants.RATING_ENTRY_RATE))) {
                        if (localName.equals(DumpConstants.RATING_ENTRY_USER)) {
                            String text = xmlReader.getElementText();
                            if (text != null) {
                                ratingDO.setRatedUserName(text);
                            }
                        } else if (localName.equals(DumpConstants.RATING_ENTRY_DATE)) {
                            String text = xmlReader.getElementText();
                            if (text != null) {
                                long date = Long.parseLong(text);
                                ratingDO.setRatedTime(new Date(date));
                            }
                        } else if (localName.equals(DumpConstants.RATING_ENTRY_RATE)) {
                            String text = xmlReader.getElementText();
                            if (text != null) {
                                int ratingValue = Integer.parseInt(text);
                                ratingDO.setRating(ratingValue);
                            }
                        }
                        do {
                            xmlReader.next();
                        } while (!xmlReader.isStartElement() && xmlReader.hasNext());
View Full Code Here

        }
    }

    public int getRateID(ResourceImpl resourceImpl, String userID) throws RegistryException {

        RatingDO ratingDO = getRatingDO(resourceImpl, userID);
        return ratingDO.getRatingID();
    }
View Full Code Here

        Connection conn = JDBCDatabaseTransaction.getConnection();

        PreparedStatement ps = null;
        ResultSet result = null;
        RatingDO ratingDO = new RatingDO();
        try {
            if (resourceImpl instanceof CollectionImpl) {
                String sql = "SELECT R.REG_ID, R.REG_RATING, R.REG_RATED_TIME " +
                        "FROM REG_RATING R, REG_RESOURCE_RATING RR " +
                        "WHERE RR.REG_PATH_ID=? AND RR.REG_RESOURCE_NAME IS NULL AND " +
                        "RR.REG_RATING_ID=R.REG_ID AND R.REG_USER_ID=? AND " +
                        "R.REG_TENANT_ID=? AND RR.REG_TENANT_ID=?";

                ps = conn.prepareStatement(sql);
                ps.setInt(1, resourceImpl.getPathID());
                ps.setString(2, userID);
                ps.setInt(3, CurrentSession.getTenantId());
                ps.setInt(4, CurrentSession.getTenantId());
            } else {
                String sql = "SELECT R.REG_ID, R.REG_RATING, R.REG_RATED_TIME " +
                        "FROM REG_RATING R, REG_RESOURCE_RATING RR " +
                        "WHERE RR.REG_PATH_ID=? AND RR.REG_RESOURCE_NAME = ? AND " +
                        "RR.REG_RATING_ID=R.REG_ID AND R.REG_USER_ID=? AND " +
                        "R.REG_TENANT_ID=? AND RR.REG_TENANT_ID=?";

                ps = conn.prepareStatement(sql);
                ps.setInt(1, resourceImpl.getPathID());
                ps.setString(2, resourceImpl.getName());
                ps.setString(3, userID);
                ps.setInt(4, CurrentSession.getTenantId());
                ps.setInt(5, CurrentSession.getTenantId());
            }

            result = ps.executeQuery();
            if (result.next()) {
                ratingDO.setRating(result.getInt(DatabaseConstants.RATING_FIELD));
                ratingDO.setRatedTime(new java.util.Date(
                        result.getTimestamp(DatabaseConstants.RATED_TIME_FIELD).getTime()));
                ratingDO.setRatedUserName(userID);
                ratingDO.setRatingID(result.getInt(DatabaseConstants.ID_FIELD));
            }
        } catch (SQLException e) {

            String msg = "Failed to get rating on resource " + resourceImpl.getPath() +
                    " done by user " + userID + ". " + e.getMessage();
View Full Code Here

        return ratingDO;
    }

    public int getRating(ResourceImpl resourceImpl, String userID) throws RegistryException {

        RatingDO ratingDO = getRatingDO(resourceImpl, userID);
        return ratingDO.getRating();
    }
View Full Code Here

            try {
                if (results.next()) {
                    java.util.Date ratedTime = new java.util.Date(
                            results.getTimestamp(DatabaseConstants.RATED_TIME_FIELD).getTime());

                    RatingDO ratingDAO = new RatingDO();
                    ratingDAO.setRatedUserName(results.getString(DatabaseConstants.USER_ID_FIELD));
                    ratingDAO.setRatedTime(ratedTime);
                    ratingDAO.setRating(results.getInt(DatabaseConstants.RATING_FIELD));
                    // TODO:
                    //ratingDAO.setResourceID(results.getString(DatabaseConstants.AID_FIELD));

                    String resourcePath;

                    int pathId = results.getInt(DatabaseConstants.PATH_ID_FIELD);
                    String resourceName = results.getString(DatabaseConstants.RESOURCE_NAME_FIELD);
                    resourcePath = resourceDAO.getPath(pathId, resourceName, true);
                    if (resourcePath != null) {
                        ratingDAO.setResourcePath(resourcePath);
                    }
                    return ratingDAO;
                }
            } finally {
                if (results != null) {
View Full Code Here

TOP

Related Classes of org.wso2.carbon.registry.core.jdbc.dataobjects.RatingDO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.