Examples of RatingDO


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

                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

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

        }
    }

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

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

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

        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

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

        return ratingDO;
    }

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

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

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

            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

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

                ps.setInt(4, CurrentSession.getTenantId());
            }

            result = ps.executeQuery();
            while (result.next()) {
                RatingDO ratingDO = new RatingDO();
                ratingDO.setRating(result.getInt(DatabaseConstants.RATING_FIELD));
                ratingDO.setRatedTime(new java.util.Date(
                        result.getTimestamp(DatabaseConstants.RATED_TIME_FIELD).getTime()));
                ratingDO.setRatedUserName(result.getString(DatabaseConstants.USER_ID_FIELD));
                ratingDO.setRatingID(result.getInt(DatabaseConstants.ID_FIELD));

                ratingDOs.add(ratingDO);
            }
        } catch (SQLException e) {
View Full Code Here

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

        List<String> ratingPathList = new ArrayList<String>();

        while (results.next()) {
            long ratingID = results.getLong(DatabaseConstants.RATING_ID_FIELD);
            RatingDO ratingDAO = ((JDBCRatingsDAO)ratingsDAO).getRating(ratingID);
            String ratingPath =
                    ratingDAO.getResourcePath() + RegistryConstants.URL_SEPARATOR + "ratings:" +
                            ratingDAO.getRatedUserName();
            ratingPathList.add(ratingPath);
        }

        String[] ratingPaths =
                ratingPathList.toArray(new String[ratingPathList.size()]);
View Full Code Here

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

        String ratedUserName = resourcePath.getParameterValue("ratings");
        if (ratedUserName != null) {
            ResourceImpl resourceImpl = resourceDAO.getResourceMetaData(resourcePath.getPath());

            RatingDO ratingDO = ratingsDAO.getRatingDO(resourceImpl, ratedUserName);
            int rating = ratingDO.getRating();
            Date ratedTime = ratingDO.getRatedTime();

            ResourceImpl resource = new ResourceImpl();
            resource.setMediaType(RegistryConstants.RATING_MEDIA_TYPE);
            resource.setContent(rating);
            resource.setAuthorUserName(ratedUserName);
View Full Code Here

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

     * @return the rate id.
     * @throws RegistryException if an error occurs while getting the rate id.
     */
    public int getRateID(ResourceImpl resourceImpl, String userID) throws RegistryException {

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

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

        Connection conn = JDBCDatabaseTransaction.getConnection();

        PreparedStatement ps = null;
        ResultSet result = null;
        RatingDO ratingDO = new RatingDO();
        try {
            String sql = "SELECT R.REG_ID, R.REG_RATING, R.REG_RATED_TIME " +
                    "FROM REG_RATING R, REG_RESOURCE_RATING RR " +
                    "WHERE RR.REG_VERSION=? 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.setLong(1, resourceImpl.getVersionNumber());
            ps.setString(2, userID);
            ps.setInt(3, CurrentSession.getTenantId());
            ps.setInt(4, 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
TOP
Copyright © 2018 www.massapi.com. 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.