master moved from ab0407a8ba9f to bb6406bb1209 3 new revisions: Revision: c78c5822be91 Author: Andrew Lindesay <apl@xxxxxxxxxxxxxx> Date: Fri Nov 14 04:41:54 2014 UTC Log: add user rating data to the prominence report https://code.google.com/p/haiku-depot-web-app/source/detail?r=c78c5822be91 Revision: cca3d6da861d Author: Andrew Lindesay <apl@xxxxxxxxxxxxxx> Date: Fri Nov 14 06:22:21 2014 UTC Log: add user rating download functions https://code.google.com/p/haiku-depot-web-app/source/detail?r=cca3d6da861d Revision: bb6406bb1209 Author: Andrew Lindesay <apl@xxxxxxxxxxxxxx> Date: Mon Nov 17 08:54:12 2014 UTC Log: german translations https://code.google.com/p/haiku-depot-web-app/source/detail?r=bb6406bb1209 ============================================================================== Revision: c78c5822be91 Author: Andrew Lindesay <apl@xxxxxxxxxxxxxx> Date: Fri Nov 14 04:41:54 2014 UTC Log: add user rating data to the prominence report https://code.google.com/p/haiku-depot-web-app/source/detail?r=c78c5822be91 Added:/haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/pkg/controller/PkgProminenceAndUserRatingSpreadsheetReportController.java
Deleted:/haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/pkg/controller/PkgProminenceSpreadsheetReportController.java
Modified:/haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/security/AuthorizationService.java /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/security/model/Permission.java
/haikudepotserver-webapp/src/main/resources/messages.properties /haikudepotserver-webapp/src/main/resources/messages_de.properties /haikudepotserver-webapp/src/main/webapp/js/app/controller/reports.html/haikudepotserver-webapp/src/main/webapp/js/app/controller/reportscontroller.js
======================================= --- /dev/null+++ /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/pkg/controller/PkgProminenceAndUserRatingSpreadsheetReportController.java Fri Nov 14 04:41:54 2014 UTC
@@ -0,0 +1,113 @@ +/* + * Copyright 2014, Andrew Lindesay + * Distributed under the terms of the MIT License. + */ + +package org.haikuos.haikudepotserver.pkg.controller; + +import au.com.bytecode.opencsv.CSVWriter; +import com.google.common.base.Optional; +import org.apache.cayenne.ObjectContext; +import org.apache.cayenne.configuration.server.ServerRuntime; +import org.apache.cayenne.query.PrefetchTreeNode; +import org.haikuos.haikudepotserver.dataobjects.Pkg; +import org.haikuos.haikudepotserver.dataobjects.User; +import org.haikuos.haikudepotserver.pkg.PkgOrchestrationService; +import org.haikuos.haikudepotserver.security.AuthorizationService; +import org.haikuos.haikudepotserver.security.model.Permission; +import org.haikuos.haikudepotserver.support.Callback; +import org.haikuos.haikudepotserver.support.web.AbstractController; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseStatus; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/**+ * <p>This report generates a report that lists the prominence of the packages.</p>
+ */ + +@Controller +@RequestMapping("/secured/pkg/pkgprominenceanduserratingspreadsheetreport")+public class PkgProminenceAndUserRatingSpreadsheetReportController extends AbstractController {
++ private static Logger LOGGER = LoggerFactory.getLogger(PkgProminenceAndUserRatingSpreadsheetReportController.class);
+ + @Resource + private AuthorizationService authorizationService; + + @Resource + private ServerRuntime serverRuntime; + + @Resource + private PkgOrchestrationService pkgOrchestrationService; + + @RequestMapping(value="download.csv", method = RequestMethod.GET) + public void generate(HttpServletResponse response) throws IOException { + + ObjectContext context = serverRuntime.getContext(); + + Optional<User> user = tryObtainAuthenticatedUser(context); + + if(!authorizationService.check( + context, + user.orNull(),+ null, Permission.BULK_PKGPROMINENCEANDUSERRATINGSPREADSHEETREPORT)) { + LOGGER.warn("attempt to access a prominence and user rating coverage spreadsheet report, but was unauthorized");
+ throw new AuthorizationFailure(); + } ++ setHeadersForCsvDownload(response, "pkgprominenceanduserratingspreadsheetreport");
+ + final CSVWriter writer = new CSVWriter(response.getWriter(), ','); + + writer.writeNext(new String[] { + "pkg-name", + "prominence-name", + "prominence-ordering", + "derived-rating", + "derived-rating-sample-size" + }); + + // stream out the packages. + + long startMs = System.currentTimeMillis(); + LOGGER.info("will produce prominence spreadsheet report"); ++ int count = pkgOrchestrationService.each(context, new PrefetchTreeNode(), new Callback<Pkg>() {
+ @Override + public boolean process(Pkg pkg) { + + writer.writeNext( + new String[] { + pkg.getName(), + pkg.getProminence().getName(),+ pkg.getProminence().getOrdering().toString(), + null==pkg.getDerivedRating() ? "" : pkg.getDerivedRating().toString(), + null==pkg.getDerivedRating() ? "" : pkg.getDerivedRatingSampleSize().toString()
+ } + ); + + return true; + } + }); + + LOGGER.info(+ "did produce prominence spreadsheet report for {} packages in {}ms",
+ count, + System.currentTimeMillis() - startMs); + + writer.close(); + + } ++ @ResponseStatus(value= HttpStatus.UNAUTHORIZED, reason="the authenticated user is not able to run the package prominence spreadsheet report")
+ public class AuthorizationFailure extends RuntimeException {} + +} =======================================--- /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/pkg/controller/PkgProminenceSpreadsheetReportController.java Tue Nov 11 00:02:22 2014 UTC
+++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2014, Andrew Lindesay - * Distributed under the terms of the MIT License. - */ - -package org.haikuos.haikudepotserver.pkg.controller; - -import au.com.bytecode.opencsv.CSVWriter; -import com.google.common.base.Optional; -import org.apache.cayenne.ObjectContext; -import org.apache.cayenne.configuration.server.ServerRuntime; -import org.apache.cayenne.query.PrefetchTreeNode; -import org.haikuos.haikudepotserver.dataobjects.Pkg; -import org.haikuos.haikudepotserver.dataobjects.User; -import org.haikuos.haikudepotserver.pkg.PkgOrchestrationService; -import org.haikuos.haikudepotserver.security.AuthorizationService; -import org.haikuos.haikudepotserver.security.model.Permission; -import org.haikuos.haikudepotserver.support.Callback; -import org.haikuos.haikudepotserver.support.web.AbstractController; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseStatus; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/**- * <p>This report generates a report that lists the prominence of the packages.</p>
- */ - -@Controller -@RequestMapping("/secured/pkg/pkgprominencespreadsheetreport")-public class PkgProminenceSpreadsheetReportController extends AbstractController {
-- private static Logger LOGGER = LoggerFactory.getLogger(PkgProminenceSpreadsheetReportController.class);
- - @Resource - private AuthorizationService authorizationService; - - @Resource - private ServerRuntime serverRuntime; - - @Resource - private PkgOrchestrationService pkgOrchestrationService; - - @RequestMapping(value="download.csv", method = RequestMethod.GET) - public void generate(HttpServletResponse response) throws IOException { - - ObjectContext context = serverRuntime.getContext(); - - Optional<User> user = tryObtainAuthenticatedUser(context); - - if(!authorizationService.check( - context, - user.orNull(), - null, Permission.BULK_PKGPROMINENCESPREADSHEETREPORT)) {- LOGGER.warn("attempt to access a bulk prominence coverage spreadsheet report, but was unauthorized");
- throw new AuthorizationFailure(); - } -- setHeadersForCsvDownload(response, "pkgprominencespreadsheetreport");
- - final CSVWriter writer = new CSVWriter(response.getWriter(), ','); -- writer.writeNext(new String[] { "pkg-name", "prominence-name", "prominence-ordering" });
- - // stream out the packages. - - long startMs = System.currentTimeMillis(); - LOGGER.info("will produce prominence spreadsheet report"); -- int count = pkgOrchestrationService.each(context, new PrefetchTreeNode(), new Callback<Pkg>() {
- @Override - public boolean process(Pkg pkg) { - - writer.writeNext( - new String[] { - pkg.getName(), - pkg.getProminence().getName(),- pkg.getProminence().getOrdering().toString()
- } - ); - - return true; - } - }); - - LOGGER.info(- "did produce prominence spreadsheet report for {} packages in {}ms",
- count, - System.currentTimeMillis() - startMs); - - writer.close(); - - } -- @ResponseStatus(value= HttpStatus.UNAUTHORIZED, reason="the authenticated user is not able to run the package prominence spreadsheet report")
- public class AuthorizationFailure extends RuntimeException {} - -} =======================================--- /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/security/AuthorizationService.java Wed Nov 12 10:52:27 2014 UTC +++ /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/security/AuthorizationService.java Fri Nov 14 04:41:54 2014 UTC
@@ -213,7 +213,7 @@ case USERRATING_DERIVEANDSTOREFORPKG:return null!=authenticatedUser && authenticatedUser.getIsRoot();
- case BULK_PKGPROMINENCESPREADSHEETREPORT: + case BULK_PKGPROMINENCEANDUSERRATINGSPREADSHEETREPORT: case BULK_PKGICONSPREADSHEETREPORT: case BULK_PKGCATEGORYCOVERAGESPREADSHEETREPORT: return null!=authenticatedUser; =======================================--- /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/security/model/Permission.java Wed Nov 12 10:52:27 2014 UTC +++ /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/security/model/Permission.java Fri Nov 14 04:41:54 2014 UTC
@@ -33,7 +33,7 @@ PKG_EDITPROMINENCE(TargetType.PKG), BULK_PKGCATEGORYCOVERAGESPREADSHEETREPORT(null), - BULK_PKGPROMINENCESPREADSHEETREPORT(null), + BULK_PKGPROMINENCEANDUSERRATINGSPREADSHEETREPORT(null), BULK_PKGICONSPREADSHEETREPORT(null); private TargetType requiredTargetType; =======================================--- /haikudepotserver-webapp/src/main/resources/messages.properties Wed Nov 12 10:52:27 2014 UTC +++ /haikudepotserver-webapp/src/main/resources/messages.properties Fri Nov 14 04:41:54 2014 UTC
@@ -387,7 +387,7 @@ with your preferred feed-aggregation software.reporting.pkgcategorycoveragespreadsheetreport.title=Package category coverage report
-reporting.pkgprominencespreadsheetreport.title=Package prominence report+reporting.pkgprominenceanduserratingspreadsheetreport.title=Package prominence and user rating report
reporting.pkgiconspreadsheetreport.title=Package icon report # Multipage (non-AngularJS) Interface =======================================--- /haikudepotserver-webapp/src/main/resources/messages_de.properties Wed Nov 12 10:52:27 2014 UTC +++ /haikudepotserver-webapp/src/main/resources/messages_de.properties Fri Nov 14 04:41:54 2014 UTC
@@ -381,7 +381,7 @@ genutzt werden kann.reporting.pkgcategorycoveragespreadsheetreport.title=Verteilung der Pakete nach Kategorien
-reporting.pkgprominencespreadsheetreport.title=Empfehlungsstufen der Pakete+reporting.pkgprominencespreadsheetreport.title=Empfehlungsstufen und Bewertungen der Pakete
reporting.pkgiconspreadsheetreport.title=Icons der Pakete # Multipage (non-AngularJS) Interface =======================================--- /haikudepotserver-webapp/src/main/webapp/js/app/controller/reports.html Wed Nov 12 10:52:27 2014 UTC +++ /haikudepotserver-webapp/src/main/webapp/js/app/controller/reports.html Fri Nov 14 04:41:54 2014 UTC
@@ -8,9 +8,9 @@<message key="reporting.pkgcategorycoveragespreadsheetreport.title"></message>
</a> </li> - <li show-if-permission="'BULK_PKGPROMINENCESPREADSHEETREPORT'"> - <a href="" ng-click="goPkgProminenceSpreadsheetReport()">- <message key="reporting.pkgprominencespreadsheetreport.title"></message> + <li show-if-permission="'BULK_PKGPROMINENCEANDUSERRATINGSPREADSHEETREPORT'"> + <a href="" ng-click="goPkgProminenceAndUserRatingSpreadsheetReport()"> + <message key="reporting.pkgprominenceanduserratingspreadsheetreport.title"></message>
</a> </li> <li show-if-permission="'BULK_PKGICONSPREADSHEETREPORT'"> =======================================--- /haikudepotserver-webapp/src/main/webapp/js/app/controller/reportscontroller.js Wed Nov 12 10:52:27 2014 UTC +++ /haikudepotserver-webapp/src/main/webapp/js/app/controller/reportscontroller.js Fri Nov 14 04:41:54 2014 UTC
@@ -31,8 +31,8 @@goSecuredCsvReport('pkg/pkgcategorycoveragespreadsheetreport');
}; - $scope.goPkgProminenceSpreadsheetReport = function() { - goSecuredCsvReport('pkg/pkgprominencespreadsheetreport');+ $scope.goPkgProminenceAndUserRatingSpreadsheetReport = function() { + goSecuredCsvReport('pkg/pkgprominenceanduserratingspreadsheetreport');
}; $scope.goPkgIconSpreadsheetReport = function() { ============================================================================== Revision: cca3d6da861d Author: Andrew Lindesay <apl@xxxxxxxxxxxxxx> Date: Fri Nov 14 06:22:21 2014 UTC Log: add user rating download functions https://code.google.com/p/haiku-depot-web-app/source/detail?r=cca3d6da861d Added:/haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/userrating/controller/UserRatingSpreadsheetReportController.java
Modified:/haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/pkg/PkgOrchestrationService.java /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/security/AuthorizationService.java /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/security/model/Permission.java /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/userrating/UserRatingOrchestrationService.java
/haikudepotserver-webapp/src/main/resources/messages.properties /haikudepotserver-webapp/src/main/resources/messages_de.properties /haikudepotserver-webapp/src/main/webapp/js/app/controller/reports.html/haikudepotserver-webapp/src/main/webapp/js/app/controller/reportscontroller.js
/haikudepotserver-webapp/src/main/webapp/js/app/controller/viewpkg.html/haikudepotserver-webapp/src/main/webapp/js/app/controller/viewpkgcontroller.js
/haikudepotserver-webapp/src/main/webapp/js/app/controller/viewuser.html/haikudepotserver-webapp/src/main/webapp/js/app/controller/viewusercontroller.js
======================================= --- /dev/null+++ /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/userrating/controller/UserRatingSpreadsheetReportController.java Fri Nov 14 06:22:21 2014 UTC
@@ -0,0 +1,201 @@ +/* + * Copyright 2014, Andrew Lindesay + * Distributed under the terms of the MIT License. + */ + +package org.haikuos.haikudepotserver.userrating.controller; + +import au.com.bytecode.opencsv.CSVWriter; +import com.google.common.base.Optional; +import com.google.common.base.Strings; +import org.apache.cayenne.ObjectContext; +import org.apache.cayenne.configuration.server.ServerRuntime; +import org.haikuos.haikudepotserver.dataobjects.Pkg; +import org.haikuos.haikudepotserver.dataobjects.User; +import org.haikuos.haikudepotserver.dataobjects.UserRating; +import org.haikuos.haikudepotserver.security.AuthorizationService; +import org.haikuos.haikudepotserver.security.model.Permission; +import org.haikuos.haikudepotserver.support.Callback; +import org.haikuos.haikudepotserver.support.web.AbstractController;+import org.haikuos.haikudepotserver.userrating.UserRatingOrchestrationService; +import org.haikuos.haikudepotserver.userrating.model.UserRatingSearchSpecification;
+import org.joda.time.format.DateTimeFormatter; +import org.joda.time.format.ISODateTimeFormat; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseStatus; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/**+ * <p>This controller is able to produce a spreadsheet of user rating data. It is able to + * produce this for a number of qualifiers. For example, it is able to produce a report + * for a package, a report for a user and is also able to produce a dump of all user
+ * ratings in the whole system.</p> + */ + +@Controller +@RequestMapping("/secured/userrating/userratingspreadsheetreport")+public class UserRatingSpreadsheetReportController extends AbstractController {
++ private static Logger LOGGER = LoggerFactory.getLogger(UserRatingSpreadsheetReportController.class);
+ + private final static String KEY_USERNICKNAME = "nicknam"; + + private final static String KEY_PKGNAME = "pkgname"; + + @Resource + private AuthorizationService authorizationService; + + @Resource + private ServerRuntime serverRuntime; + + @Resource + private UserRatingOrchestrationService userRatingOrchestrationService; + + @RequestMapping(value="download.csv", method = RequestMethod.GET) + public void generate( + HttpServletResponse response,+ @RequestParam(value = KEY_USERNICKNAME, required = false) String paramUserNickname, + @RequestParam(value = KEY_PKGNAME, required = false) String paramPkgName
+ ) throws IOException { + + ObjectContext context = serverRuntime.getContext(); ++ StringBuilder filenameIdentifier = new StringBuilder("userratingspreadsheetreport");
+ Optional<User> user = tryObtainAuthenticatedUser(context); + Optional<Pkg> paramPkgOptional = Optional.absent(); + Optional<User> paramUserOptional = Optional.absent(); + + if(!Strings.isNullOrEmpty(paramUserNickname)) {+ paramUserOptional = User.getByNickname(context, paramUserNickname);
+ + if(!paramUserOptional.isPresent()) {+ LOGGER.warn("attempt to produce user rating report for user {}, but that user does not exist -- not allowed", paramUserNickname);
+ throw new AuthorizationFailure(); + } + + if(!authorizationService.check( + context, + user.orNull(), + paramUserOptional.get(), + Permission.BULK_USERRATINGSPREADSHEETREPORT_USER)) {+ LOGGER.warn("attempt to access a user rating report for user {}, but this was disallowed", paramUserNickname);
+ throw new AuthorizationFailure(); + } + + filenameIdentifier.append("_user-"); + filenameIdentifier.append(paramUserNickname); + } + + if(!Strings.isNullOrEmpty(paramPkgName)) { + paramPkgOptional = Pkg.getByName(context, paramPkgName); + + if(!paramPkgOptional.isPresent()) {+ LOGGER.warn("attempt to produce user rating report for pkg {}, but that pkg does not exist -- not allowed", paramPkgName);
+ throw new AuthorizationFailure(); + } + + if(!authorizationService.check( + context, + user.orNull(), + paramPkgOptional.get(), + Permission.BULK_USERRATINGSPREADSHEETREPORT_PKG)) {+ LOGGER.warn("attempt to access a user rating report for pkg {}, but this was disallowed", paramUserNickname);
+ throw new AuthorizationFailure(); + } + + filenameIdentifier.append("_pkg-"); + filenameIdentifier.append(paramPkgName); + } + + // if there is no user and no package supplied then assume that + // the user is trying to produce a report for all user ratings. ++ if(!paramPkgOptional.isPresent() && !paramUserOptional.isPresent()) {
+ if(!authorizationService.check( + context, + user.orNull(), + null, + Permission.BULK_USERRATINGSPREADSHEETREPORT_ALL)) {+ LOGGER.warn("attempt to access a user rating report for all, but this was disallowed");
+ throw new AuthorizationFailure(); + } + + filenameIdentifier.append("_all"); + } + + setHeadersForCsvDownload(response, filenameIdentifier.toString()); + + final CSVWriter writer = new CSVWriter(response.getWriter(), ','); + + writer.writeNext(new String[] { + "pkg-name", + "architecture-code", + "version-coordinates", + "user-nickname", + "create-timestamp", + "modify-timestamp", + "rating", + "stability-code", + "natural-language-code", + "comment", + "code" + }); + + // stream out the packages. + + long startMs = System.currentTimeMillis(); + LOGGER.info("will user rating spreadsheet report"); ++ final DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.basicDateTimeNoMillis();
++ UserRatingSearchSpecification spec = new UserRatingSearchSpecification();
+ spec.setPkg(paramPkgOptional.orNull()); + spec.setUser(paramUserOptional.orNull()); + + // TODO; provide a prefetch tree into the user, pkgversion.+ int count = userRatingOrchestrationService.each(context, spec, new Callback<UserRating>() {
+ @Override + public boolean process(UserRating userRating) { + + writer.writeNext( + new String[]{+ userRating.getPkgVersion().getPkg().getName(), + userRating.getPkgVersion().getArchitecture().getCode(), + userRating.getPkgVersion().toVersionCoordinates().toString(),
+ userRating.getUser().getNickname(),+ dateTimeFormatter.print(userRating.getCreateTimestamp().getTime()), + dateTimeFormatter.print(userRating.getModifyTimestamp().getTime()),
+ userRating.getRating().toString(),+ null != userRating.getUserRatingStability() ? userRating.getUserRatingStability().getCode() : "",
+ userRating.getNaturalLanguage().getCode(), + userRating.getComment(), + userRating.getCode() + } + ); + + return true; + } + }); + + LOGGER.info(+ "did produce user rating spreadsheet report for {} user ratings in {}ms",
+ count, + System.currentTimeMillis() - startMs); + + writer.close(); + + } ++ @ResponseStatus(value= HttpStatus.UNAUTHORIZED, reason="the authenticated user is not able to run the user rating spreadsheet report")
+ public class AuthorizationFailure extends RuntimeException {} + +} =======================================--- /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/pkg/PkgOrchestrationService.java Wed Nov 12 10:52:27 2014 UTC +++ /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/pkg/PkgOrchestrationService.java Fri Nov 14 06:22:21 2014 UTC
@@ -1004,7 +1004,6 @@ } } - // ------------------------------------- // LOCALIZATION =======================================--- /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/security/AuthorizationService.java Fri Nov 14 04:41:54 2014 UTC +++ /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/security/AuthorizationService.java Fri Nov 14 06:22:21 2014 UTC
@@ -128,7 +128,9 @@ Preconditions.checkNotNull(permission); Preconditions.checkNotNull(objectContext);- Preconditions.checkState(deriveTargetType(target) == permission.getRequiredTargetType());
+ Preconditions.checkState(+ deriveTargetType(target) == permission.getRequiredTargetType(), + "during checking authorization, the target object type " + deriveTargetType(target) + " does not match the expected type " + permission.getRequiredTargetType());
// if the authenticated user is not active then there should not be a situation arising where
// an authorization check is being made. @@ -218,6 +220,17 @@ case BULK_PKGCATEGORYCOVERAGESPREADSHEETREPORT: return null!=authenticatedUser; + case BULK_USERRATINGSPREADSHEETREPORT_ALL:+ return null!=authenticatedUser && authenticatedUser.getIsRoot();
+ + case BULK_USERRATINGSPREADSHEETREPORT_PKG: + return null!=authenticatedUser; + + case BULK_USERRATINGSPREADSHEETREPORT_USER: + return null!=authenticatedUser && + (authenticatedUser.getIsRoot() ||+ authenticatedUser.getNickname().equals(((User) target).getNickname()));
+ default:throw new IllegalStateException("unhandled permission; "+permission.name());
} =======================================--- /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/security/model/Permission.java Fri Nov 14 04:41:54 2014 UTC +++ /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/security/model/Permission.java Fri Nov 14 06:22:21 2014 UTC
@@ -34,7 +34,10 @@ BULK_PKGCATEGORYCOVERAGESPREADSHEETREPORT(null), BULK_PKGPROMINENCEANDUSERRATINGSPREADSHEETREPORT(null), - BULK_PKGICONSPREADSHEETREPORT(null); + BULK_PKGICONSPREADSHEETREPORT(null), + BULK_USERRATINGSPREADSHEETREPORT_PKG(TargetType.PKG), + BULK_USERRATINGSPREADSHEETREPORT_ALL(null), + BULK_USERRATINGSPREADSHEETREPORT_USER(TargetType.USER); private TargetType requiredTargetType; =======================================--- /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/userrating/UserRatingOrchestrationService.java Tue Aug 19 11:01:57 2014 UTC +++ /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/userrating/UserRatingOrchestrationService.java Fri Nov 14 06:22:21 2014 UTC
@@ -16,6 +16,7 @@ import org.haikuos.haikudepotserver.dataobjects.PkgVersion; import org.haikuos.haikudepotserver.dataobjects.User; import org.haikuos.haikudepotserver.dataobjects.UserRating; +import org.haikuos.haikudepotserver.support.Callback; import org.haikuos.haikudepotserver.support.VersionCoordinates; import org.haikuos.haikudepotserver.support.VersionCoordinatesComparator;import org.haikuos.haikudepotserver.userrating.model.UserRatingSearchSpecification;
@@ -49,7 +50,69 @@ @Resource ServerRuntime serverRuntime; - // ------------------------------ + // ------------------------------------- + // ITERATION + + /**+ * <p>This will be called for each user rating in the system with some constraints.</p>
+ * @param c is the callback to invoke. + * @return the quantity of user ratings processed. + */ + + // TODO; somehow prefetch the user? prefetch tree? + + public int each( + ObjectContext context, + UserRatingSearchSpecification search, + Callback<UserRating> c) { + + Preconditions.checkNotNull(c); + Preconditions.checkNotNull(context); + + int count = 0; + StringBuilder queryExpression = new StringBuilder(); + List<Object> parameters = Lists.newArrayList(); + + queryExpression.append("SELECT ur FROM UserRating ur"); + + if(null!=search) { + queryExpression.append(" WHERE ");+ queryExpression.append(prepareWhereClause(parameters, context, search));
+ } ++ queryExpression.append(" ORDER BY ur.createTimestamp DESC, ur.code DESC");
+ + EJBQLQuery query = new EJBQLQuery(queryExpression.toString()); + + for(int i=0;i<parameters.size();i++) { + query.setParameter(i + 1, parameters.get(i)); + } + + query.setFetchLimit(100); + + // now loop through the user ratings. + + while(true) { + + query.setFetchOffset(count);+ List<UserRating> userRatings = (List<UserRating>) context.performQuery(query);
+ + if(userRatings.isEmpty()) { + return count; + } + + for(UserRating userRating : userRatings) { + if(!c.process(userRating)) { + return count; + } + } + + count += userRatings.size(); + } + + } + + // ------------------------------------- // SEARCH private String prepareWhereClause( =======================================--- /haikudepotserver-webapp/src/main/resources/messages.properties Fri Nov 14 04:41:54 2014 UTC +++ /haikudepotserver-webapp/src/main/resources/messages.properties Fri Nov 14 06:22:21 2014 UTC
@@ -220,6 +220,7 @@ viewPkg.editPkgCategoriesAction.title=Edit categories viewPkg.editPkgProminenceAction.title=Edit prominence viewPkg.editVersionLocalizationAction.title=Edit localizations +viewPkg.downloadUserRatingsAction.title=Download user ratings viewPkg.userRating.title=User Rating viewPkg.userRating.title.plural=User Ratings viewPkg.userRating.moreAction.title=More... @@ -250,6 +251,7 @@ viewUser.logoutAction.title=Logout viewUser.deactivateAction.title=Deactivate viewUser.reactivateAction.title=Reactivate +viewUser.downloadUserRatingsAction.title=Download user ratings listPkgVersionsForPkg.title={0} Version for {1} listPkgVersionsForPkg.title.plural={0} Versions for {1} @@ -389,6 +391,7 @@reporting.pkgcategorycoveragespreadsheetreport.title=Package category coverage report reporting.pkgprominenceanduserratingspreadsheetreport.title=Package prominence and user rating report
reporting.pkgiconspreadsheetreport.title=Package icon report +reporting.userratingspreadsheetreportall.title=Report of all user ratings # Multipage (non-AngularJS) Interface multipage.banner.title.suffix=Simple =======================================--- /haikudepotserver-webapp/src/main/resources/messages_de.properties Fri Nov 14 04:41:54 2014 UTC +++ /haikudepotserver-webapp/src/main/resources/messages_de.properties Fri Nov 14 06:22:21 2014 UTC
@@ -214,6 +214,7 @@ viewPkg.editScreenshotsAction.title=Screenshots bearbeiten viewPkg.editPkgCategoriesAction.title=Kategorien bearbeiten viewPkg.editVersionLocalizationAction.title=Übersetzungen bearbeiten +viewPkg.downloadUserRatingsAction.title=Bewertungen unterladen viewPkg.userRating.title=Bewertung viewPkg.userRating.title.plural=Bewertungen viewPkg.userRating.moreAction.title=Mehr... @@ -245,6 +246,7 @@ viewUser.logoutAction.title=Abmelden viewUser.deactivateAction.title=Deaktivieren viewUser.reactivateAction.title=Reaktivieren +viewUser.downloadUserRatingsAction.title=Bewertungen unterladen completePasswordReset.oldPasswordClear.title=Existierendes KennwortcompletePasswordReset.oldPasswordClear.required=Zur Bestätigung der Identität des Benutzers wird das existierende Kennwort benötigt.
@@ -325,7 +327,7 @@ banner.action.authorizationPkgRules=Paket-Autorisierung banner.action.pkgFeedBuilder=Feed-URL erzeugen banner.action.rootOperations=Root Operations -banner.actions.reports=Berichte +banner.action.reports=Berichte banner.warning.nonProductionDeploy=Test-Umgebung! permission.pkg_editicon.title=Paket-Icon bearbeiten @@ -381,8 +383,9 @@ genutzt werden kann.reporting.pkgcategorycoveragespreadsheetreport.title=Verteilung der Pakete nach Kategorien -reporting.pkgprominencespreadsheetreport.title=Empfehlungsstufen und Bewertungen der Pakete +reporting.pkgprominencespreadsheetreport.title=Empfehlungsstufen und Bewertung der Pakete
reporting.pkgiconspreadsheetreport.title=Icons der Pakete +reporting.userratingspreadsheetreportall.title=Alle Bewertungen # Multipage (non-AngularJS) Interface multipage.banner.title.suffix=Einfach =======================================--- /haikudepotserver-webapp/src/main/webapp/js/app/controller/reports.html Fri Nov 14 04:41:54 2014 UTC +++ /haikudepotserver-webapp/src/main/webapp/js/app/controller/reports.html Fri Nov 14 06:22:21 2014 UTC
@@ -17,6 +17,11 @@ <a href="" ng-click="goPkgIconSpreadsheetReport()"><message key="reporting.pkgiconspreadsheetreport.title"></message>
</a> + </li> + <li show-if-permission="'BULK_USERRATINGSPREADSHEETREPORT_ALL'"> + <a href="" ng-click="goUserRatingSpreadsheetReportAll()">+ <message key="reporting.userratingspreadsheetreportall.title"></message>
+ </a> </li> </ul> =======================================--- /haikudepotserver-webapp/src/main/webapp/js/app/controller/reportscontroller.js Fri Nov 14 04:41:54 2014 UTC +++ /haikudepotserver-webapp/src/main/webapp/js/app/controller/reportscontroller.js Fri Nov 14 06:22:21 2014 UTC
@@ -39,6 +39,10 @@ goSecuredCsvReport('pkg/pkgiconspreadsheetreport'); }; + $scope.goUserRatingSpreadsheetReportAll = function() {+ goSecuredCsvReport('userrating/userratingspreadsheetreport');
+ }; + } ] ); =======================================--- /haikudepotserver-webapp/src/main/webapp/js/app/controller/viewpkg.html Fri Oct 3 09:40:54 2014 UTC +++ /haikudepotserver-webapp/src/main/webapp/js/app/controller/viewpkg.html Fri Nov 14 06:22:21 2014 UTC
@@ -157,6 +157,19 @@ <a href="" ng-click="goAddUserRating()"><message key="viewPkg.userRating.addAction.title"></message>
</a> + </li>+ <li pkg="pkg" show-if-pkg-permission="'BULK_USERRATINGSPREADSHEETREPORT_PKG'" ng-show="userRatings.items.length">
+ <a href="" ng-click="goDownloadUserRatings()">+ <message key="viewPkg.downloadUserRatingsAction.title"></message>
+ </a> + </li> + <li show-if-permission="'USERRATING_DERIVEANDSTOREFORPKG'"> + <a href="" ng-click="goDeriveAndStoreUserRating()">+ <message key="viewPkg.deriveAndStoreUserRatingAction.title"></message>
+ </a> + <span ng-show="didDeriveAndStoreUserRating">+ <em><message key="viewPkg.deriveAndStoreUserRatingAction.completed"></message></em>
+ </span> </li> </ul> </div> @@ -211,14 +224,6 @@ <a href="" ng-click="goEditPkgCategories()"><message key="viewPkg.editPkgCategoriesAction.title"></message>
</a> - </li>- <li pkg="pkg" show-if-permission="'USERRATING_DERIVEANDSTOREFORPKG'">
- <a href="" ng-click="goDeriveAndStoreUserRating()">- <message key="viewPkg.deriveAndStoreUserRatingAction.title"></message>
- </a> - <span ng-show="didDeriveAndStoreUserRating">- <em><message key="viewPkg.deriveAndStoreUserRatingAction.completed"></message></em>
- </span> </li> </ul> </div> =======================================--- /haikudepotserver-webapp/src/main/webapp/js/app/controller/viewpkgcontroller.js Fri Oct 3 09:40:54 2014 UTC +++ /haikudepotserver-webapp/src/main/webapp/js/app/controller/viewpkgcontroller.js Fri Nov 14 06:22:21 2014 UTC
@@ -449,6 +449,21 @@ }; + /**+ * <p>This function will produce a spreadsheet of the user ratings for this
+ * package.</p> + */ + + $scope.goDownloadUserRatings = function() { + var iframeEl = document.getElementById("download-iframe");+ iframeEl.src = '/secured/userrating/userratingspreadsheetreport/download.csv?hdsbtok=' +
+ userState.user().token + + '&pkgname=' + + $routeParams.name + + '&rnd=' + + _.random(0,1000); + }; + // --------------------- // EVENTS =======================================--- /haikudepotserver-webapp/src/main/webapp/js/app/controller/viewuser.html Tue Jul 1 10:10:47 2014 UTC +++ /haikudepotserver-webapp/src/main/webapp/js/app/controller/viewuser.html Fri Nov 14 06:22:21 2014 UTC
@@ -46,6 +46,11 @@ <a href="" ng-click="goLogout()"> <message key="viewUser.logoutAction.title"></message> </a> + </li>+ <li user="user" show-if-user-permission="'BULK_USERRATINGSPREADSHEETREPORT_USER'">
+ <a href="" ng-click="goDownloadUserRatings()">+ <message key="viewUser.downloadUserRatingsAction.title"></message>
+ </a> </li> </ul> =======================================--- /haikudepotserver-webapp/src/main/webapp/js/app/controller/viewusercontroller.js Tue Jul 8 11:11:57 2014 UTC +++ /haikudepotserver-webapp/src/main/webapp/js/app/controller/viewusercontroller.js Fri Nov 14 06:22:21 2014 UTC
@@ -111,11 +111,26 @@ $scope.goDeactivate = function() { setActive(false); - } + }; $scope.goReactivate = function() { setActive(true); - } + }; + + /**+ * <p>This function will produce a spreadsheet of the user ratings for this
+ * package.</p> + */ + + $scope.goDownloadUserRatings = function() { + var iframeEl = document.getElementById("download-iframe");+ iframeEl.src = '/secured/userrating/userratingspreadsheetreport/download.csv?hdsbtok=' +
+ userState.user().token + + '&nicknam=' + + $routeParams.nickname + + '&rnd=' + + _.random(0,1000); + }; } ] ============================================================================== Revision: bb6406bb1209 Author: Andrew Lindesay <apl@xxxxxxxxxxxxxx> Date: Mon Nov 17 08:54:12 2014 UTC Log: german translations https://code.google.com/p/haiku-depot-web-app/source/detail?r=bb6406bb1209 Modified: /haikudepotserver-webapp/src/main/resources/messages_de.properties =======================================--- /haikudepotserver-webapp/src/main/resources/messages_de.properties Fri Nov 14 06:22:21 2014 UTC +++ /haikudepotserver-webapp/src/main/resources/messages_de.properties Mon Nov 17 08:54:12 2014 UTC
@@ -214,7 +214,7 @@ viewPkg.editScreenshotsAction.title=Screenshots bearbeiten viewPkg.editPkgCategoriesAction.title=Kategorien bearbeiten viewPkg.editVersionLocalizationAction.title=Übersetzungen bearbeiten -viewPkg.downloadUserRatingsAction.title=Bewertungen unterladen +viewPkg.downloadUserRatingsAction.title=Bewertungen herunterladen viewPkg.userRating.title=Bewertung viewPkg.userRating.title.plural=Bewertungen viewPkg.userRating.moreAction.title=Mehr... @@ -246,7 +246,7 @@ viewUser.logoutAction.title=Abmelden viewUser.deactivateAction.title=Deaktivieren viewUser.reactivateAction.title=Reaktivieren -viewUser.downloadUserRatingsAction.title=Bewertungen unterladen +viewUser.downloadUserRatingsAction.title=Bewertungen herunterladen completePasswordReset.oldPasswordClear.title=Existierendes KennwortcompletePasswordReset.oldPasswordClear.required=Zur Bestätigung der Identität des Benutzers wird das existierende Kennwort benötigt.
@@ -383,7 +383,7 @@ genutzt werden kann.reporting.pkgcategorycoveragespreadsheetreport.title=Verteilung der Pakete nach Kategorien -reporting.pkgprominencespreadsheetreport.title=Empfehlungsstufen und Bewertung der Pakete +reporting.pkgprominencespreadsheetreport.title=Empfehlungsstufen und Bewertungen der Pakete
reporting.pkgiconspreadsheetreport.title=Icons der Pakete reporting.userratingspreadsheetreportall.title=Alle Bewertungen