[haiku-depot-web] [haiku-depot-web-app] 2 new revisions pushed by haiku.li...@xxxxxxxxx on 2014-08-19 11:04 GMT

  • From: haiku-depot-web-app@xxxxxxxxxxxxxx
  • To: haiku-depot-web@xxxxxxxxxxxxx
  • Date: Tue, 19 Aug 2014 11:05:09 +0000

master moved from 761e4b024d1f to 92a0d41c5056

2 new revisions:

Revision: 0afdd6566107
Author:   Andrew Lindesay <apl@xxxxxxxxxxxxxx>
Date:     Mon Aug 18 10:25:15 2014 UTC
Log:      cut down on excess logging from repository import
http://code.google.com/p/haiku-depot-web-app/source/detail?r=0afdd6566107

Revision: 92a0d41c5056
Author:   Andrew Lindesay <apl@xxxxxxxxxxxxxx>
Date:     Tue Aug 19 11:01:57 2014 UTC
Log: implement user interface and functions to facilitate force derive and ...
http://code.google.com/p/haiku-depot-web-app/source/detail?r=92a0d41c5056

==============================================================================
Revision: 0afdd6566107
Author:   Andrew Lindesay <apl@xxxxxxxxxxxxxx>
Date:     Mon Aug 18 10:25:15 2014 UTC
Log:      cut down on excess logging from repository import

http://code.google.com/p/haiku-depot-web-app/source/detail?r=0afdd6566107

Modified:
/haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/pkg/PkgOrchestrationService.java

=======================================
--- /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/pkg/PkgOrchestrationService.java Thu Aug 14 11:03:33 2014 UTC +++ /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/pkg/PkgOrchestrationService.java Mon Aug 18 10:25:15 2014 UTC
@@ -858,19 +858,25 @@
                 persistedLatestExistingPkgVersion.get().setIsLatest(false);
             }
             else {
+ boolean isRealArchitecture = !persistedPkgVersion.getArchitecture().getCode().equals(Architecture.CODE_SOURCE);
+
                 if(0==c) {
-                    LOGGER.debug(
- "imported a package version {} of {} which is the same as the existing {}",
-                            persistedPkgVersionCoords,
-                            persistedPkgVersion.getPkg().getName(),
-                            persistedLatestExistingPkgVersionCoords);
+                    if(isRealArchitecture) {
+                        LOGGER.debug(
+ "imported a package version {} of {} which is the same as the existing {}",
+                                persistedPkgVersionCoords,
+                                persistedPkgVersion.getPkg().getName(),
+                                persistedLatestExistingPkgVersionCoords);
+                    }
                 }
                 else {
-                    LOGGER.warn(
- "imported a package version {} of {} which is older or the same as the existing {}",
-                            persistedPkgVersionCoords,
-                            persistedPkgVersion.getPkg().getName(),
-                            persistedLatestExistingPkgVersionCoords);
+                    if(isRealArchitecture) {
+                        LOGGER.warn(
+ "imported a package version {} of {} which is older or the same as the existing {}",
+                                persistedPkgVersionCoords,
+                                persistedPkgVersion.getPkg().getName(),
+                                persistedLatestExistingPkgVersionCoords);
+                    }
                 }
             }
         }

==============================================================================
Revision: 92a0d41c5056
Author:   Andrew Lindesay <apl@xxxxxxxxxxxxxx>
Date:     Tue Aug 19 11:01:57 2014 UTC
Log: implement user interface and functions to facilitate force derive and store for a package or all packages

http://code.google.com/p/haiku-depot-web-app/source/detail?r=92a0d41c5056

Added:
/haikudepotserver-api1/src/main/java/org/haikuos/haikudepotserver/api1/model/userrating/DeriveAndStoreUserRatingForPkgRequest.java /haikudepotserver-api1/src/main/java/org/haikuos/haikudepotserver/api1/model/userrating/DeriveAndStoreUserRatingForPkgResult.java /haikudepotserver-api1/src/main/java/org/haikuos/haikudepotserver/api1/model/userrating/DeriveAndStoreUserRatingsForAllPkgsRequest.java /haikudepotserver-api1/src/main/java/org/haikuos/haikudepotserver/api1/model/userrating/DeriveAndStoreUserRatingsForAllPkgsResult.java /haikudepotserver-webapp/src/main/webapp/js/app/controller/rootoperations.html /haikudepotserver-webapp/src/main/webapp/js/app/controller/rootoperationscontroller.js
Modified:
/haikudepotserver-api1/src/main/java/org/haikuos/haikudepotserver/api1/UserRatingApi.java /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/api1/UserRatingApiImpl.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/LocalUserRatingDerivationService.java /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/userrating/UserRatingOrchestrationService.java /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/userrating/model/UserRatingDerivationJob.java
 /haikudepotserver-webapp/src/main/resources/messages.properties
 /haikudepotserver-webapp/src/main/resources/messages_de.properties
/haikudepotserver-webapp/src/main/webapp/js/app/controller/aboutcontroller.js /haikudepotserver-webapp/src/main/webapp/js/app/controller/runtimeinformation.html /haikudepotserver-webapp/src/main/webapp/js/app/controller/runtimeinformationcontroller.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/directive/banner.html
/haikudepotserver-webapp/src/main/webapp/js/app/directive/bannerdirective.js
 /haikudepotserver-webapp/src/main/webapp/js/app/routes.js
/haikudepotserver-webapp/src/main/webapp/js/app/service/breadcrumbfactoryservice.js

=======================================
--- /dev/null
+++ /haikudepotserver-api1/src/main/java/org/haikuos/haikudepotserver/api1/model/userrating/DeriveAndStoreUserRatingForPkgRequest.java Tue Aug 19 11:01:57 2014 UTC
@@ -0,0 +1,12 @@
+/*
+* Copyright 2014, Andrew Lindesay
+* Distributed under the terms of the MIT License.
+*/
+
+package org.haikuos.haikudepotserver.api1.model.userrating;
+
+public class DeriveAndStoreUserRatingForPkgRequest {
+
+    public String pkgName;
+
+}
=======================================
--- /dev/null
+++ /haikudepotserver-api1/src/main/java/org/haikuos/haikudepotserver/api1/model/userrating/DeriveAndStoreUserRatingForPkgResult.java Tue Aug 19 11:01:57 2014 UTC
@@ -0,0 +1,9 @@
+/*
+* Copyright 2014, Andrew Lindesay
+* Distributed under the terms of the MIT License.
+*/
+
+package org.haikuos.haikudepotserver.api1.model.userrating;
+
+public class DeriveAndStoreUserRatingForPkgResult {
+}
=======================================
--- /dev/null
+++ /haikudepotserver-api1/src/main/java/org/haikuos/haikudepotserver/api1/model/userrating/DeriveAndStoreUserRatingsForAllPkgsRequest.java Tue Aug 19 11:01:57 2014 UTC
@@ -0,0 +1,9 @@
+/*
+* Copyright 2014, Andrew Lindesay
+* Distributed under the terms of the MIT License.
+*/
+
+package org.haikuos.haikudepotserver.api1.model.userrating;
+
+public class DeriveAndStoreUserRatingsForAllPkgsRequest {
+}
=======================================
--- /dev/null
+++ /haikudepotserver-api1/src/main/java/org/haikuos/haikudepotserver/api1/model/userrating/DeriveAndStoreUserRatingsForAllPkgsResult.java Tue Aug 19 11:01:57 2014 UTC
@@ -0,0 +1,9 @@
+/*
+* Copyright 2014, Andrew Lindesay
+* Distributed under the terms of the MIT License.
+*/
+
+package org.haikuos.haikudepotserver.api1.model.userrating;
+
+public class DeriveAndStoreUserRatingsForAllPkgsResult {
+}
=======================================
--- /dev/null
+++ /haikudepotserver-webapp/src/main/webapp/js/app/controller/rootoperations.html Tue Aug 19 11:01:57 2014 UTC
@@ -0,0 +1,26 @@
+<breadcrumbs items="breadcrumbItems"></breadcrumbs>
+
+<!-- Because this page is root only, I will not worry about localization for it -->
+
+<div class="content-container">
+
+ <p>These are root-level operations that can be performed on the system.</p>
+
+    <h1>Actions</h1>
+    <ul>
+        <li>
+            <a href="" ng-click="goDeriveAndStoreUserRatingsForAllPkgs()">
+                Derive and store user ratings for all packages
+            </a>
+            <span ng-show="didDeriveAndStoreUserRatingsForAllPkgs">
+                <em>&mdash; did initiate</em>
+            </span>
+        </li>
+ <li><a href="" ng-click="goRuntimeInformation()">Runtime information</a></li> + <li><a href="" ng-click="goPaginationControlPlayground()">Pagination playground</a></li> + <li><a href="" ng-click="goRaiseExceptionInLocalRuntime()">Raise test exception in javascript environment</a></li> + <li><a href="" ng-click="goRaiseExceptionInServerRuntime()">Raise test exception on server via json-rpc</a></li>
+    </ul>
+
+</div>
+<div class="footer"></div>
=======================================
--- /dev/null
+++ /haikudepotserver-webapp/src/main/webapp/js/app/controller/rootoperationscontroller.js Tue Aug 19 11:01:57 2014 UTC
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2014, Andrew Lindesay
+ * Distributed under the terms of the MIT License.
+ */
+
+angular.module('haikudepotserver').controller(
+    'RootOperationsController',
+    [
+        '$scope','$log','$location','$timeout',
+        'jsonRpc','constants','userState',
+        'breadcrumbs','breadcrumbFactory','errorHandling',
+        function(
+            $scope,$log,$location,$timeout,
+            jsonRpc,constants,userState,
+            breadcrumbs,breadcrumbFactory,errorHandling) {
+
+            breadcrumbs.mergeCompleteStack([
+                breadcrumbFactory.createHome(),
+                breadcrumbFactory.createRootOperations(),
+            ]);
+
+            $scope.didDeriveAndStoreUserRatingsForAllPkgs = false;
+            $scope.deriveAndStoreUserRatingsForAllPkgsTimeout = undefined;
+
+            $scope.goDeriveAndStoreUserRatingsForAllPkgs = function() {
+                jsonRpc.call(
+                    constants.ENDPOINT_API_V1_USERRATING,
+                    "deriveAndStoreUserRatingsForAllPkgs",
+                    [{}]
+                ).then(
+                    function() {
+ $log.info('requested derive and store user ratings for all pkgs'); + $scope.didDeriveAndStoreUserRatingsForAllPkgs = true;
+
+ if($scope.deriveAndStoreUserRatingsForAllPkgsTimeout) { + $timeout.cancel($scope.deriveAndStoreUserRatingsForAllPkgsTimeout);
+                        }
+
+ $scope.deriveAndStoreUserRatingsForAllPkgsTimeout = $timeout(function() { + $scope.didDeriveAndStoreUserRatingsForAllPkgs = false; + $scope.deriveAndStoreUserRatingsForAllPkgsTimeout = undefined;
+                        }, 3000);
+                    },
+                    function(err) {
+ $log.error('unable to derive and store user ratings for all pkgs');
+                        errorHandling.handleJsonRpcError(err);
+                    }
+                );
+            };
+
+            /**
+ * <p>This is outside of the normal breadcrumb navigation system because it is a
+             * developers' feature.</p>
+             */
+
+            $scope.goPaginationControlPlayground = function() {
+                $location.path('/paginationcontrolplayground').search({});
+            }
+
+            $scope.goRuntimeInformation = function() {
+ breadcrumbs.pushAndNavigate(breadcrumbFactory.createRuntimeInformation());
+            }
+
+            // -------------------
+            // TEST ERROR HANDLING TESTING
+
+            $scope.goRaiseExceptionInLocalRuntime = function() {
+                throw Error('test exception in javascript environment');
+            };
+
+            $scope.goRaiseExceptionInServerRuntime = function() {
+                jsonRpc.call(
+                    constants.ENDPOINT_API_V1_MISCELLANEOUS,
+                    "raiseException",
+                    [{}]
+                ).then(
+                    function() {
+ $log.error('the exception raised on the server runtime -> should not have reached this point');
+                    },
+                    function(err) {
+                        errorHandling.handleJsonRpcError(err);
+                    }
+                );
+            }
+        }
+    ]
+);
=======================================
--- /haikudepotserver-api1/src/main/java/org/haikuos/haikudepotserver/api1/UserRatingApi.java Sat May 24 11:47:09 2014 UTC +++ /haikudepotserver-api1/src/main/java/org/haikuos/haikudepotserver/api1/UserRatingApi.java Tue Aug 19 11:01:57 2014 UTC
@@ -16,6 +16,18 @@
 @JsonRpcService("/api/v1/userrating")
 public interface UserRatingApi {

+    /**
+ * <p>This method will re-calculate and store the user rating for the nominated packaging.</p>
+     */
+
+ DeriveAndStoreUserRatingForPkgResult deriveAndStoreUserRatingForPkg(DeriveAndStoreUserRatingForPkgRequest request) throws ObjectNotFoundException;
+
+    /**
+ * <p>This method will trigger the re-calculation of user ratings for all of the packages in the system.</p>
+     */
+
+ DeriveAndStoreUserRatingsForAllPkgsResult deriveAndStoreUserRatingsForAllPkgs(DeriveAndStoreUserRatingsForAllPkgsResult request);
+
     /**
* <p>This will find the user rating identified by the supplied code and will return data pertaining to that * or if the user rating was not able to be found for the code supplied then it will throw an instance of
=======================================
--- /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/api1/UserRatingApiImpl.java Sun Aug 3 11:11:48 2014 UTC +++ /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/api1/UserRatingApiImpl.java Tue Aug 19 11:01:57 2014 UTC
@@ -20,7 +20,9 @@
 import org.haikuos.haikudepotserver.security.AuthorizationService;
 import org.haikuos.haikudepotserver.security.model.Permission;
 import org.haikuos.haikudepotserver.support.VersionCoordinates;
+import org.haikuos.haikudepotserver.userrating.UserRatingDerivationService;
import org.haikuos.haikudepotserver.userrating.UserRatingOrchestrationService; +import org.haikuos.haikudepotserver.userrating.model.UserRatingDerivationJob; import org.haikuos.haikudepotserver.userrating.model.UserRatingSearchSpecification;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -42,6 +44,9 @@
     @Resource
     AuthorizationService authorizationService;

+    @Resource
+    UserRatingDerivationService userRatingDerivationService;
+
     @Resource
     UserRatingOrchestrationService userRatingOrchestrationService;

@@ -93,6 +98,53 @@
result.userRatingStabilityCode = userRating.getUserRatingStability().getCode();
         }
     }
+
+    @Override
+ public DeriveAndStoreUserRatingForPkgResult deriveAndStoreUserRatingForPkg(DeriveAndStoreUserRatingForPkgRequest request) throws ObjectNotFoundException {
+        Preconditions.checkNotNull(request);
+        Preconditions.checkState(!Strings.isNullOrEmpty(request.pkgName));
+
+        final ObjectContext context = serverRuntime.getContext();
+
+        if(!authorizationService.check(
+                context,
+                tryObtainAuthenticatedUser(context).orNull(),
+                null,
+                Permission.USERRATING_DERIVEANDSTOREFORPKG)) {
+            throw new AuthorizationFailureException();
+        }
+
+ Optional<Pkg> pkgOptional = Pkg.getByName(context, request.pkgName);
+
+        if(!pkgOptional.isPresent()) {
+ throw new ObjectNotFoundException(Pkg.class.getSimpleName(), request.pkgName);
+        }
+
+ userRatingDerivationService.submit(new UserRatingDerivationJob(request.pkgName));
+
+        return new DeriveAndStoreUserRatingForPkgResult();
+    }
+
+    @Override
+ public DeriveAndStoreUserRatingsForAllPkgsResult deriveAndStoreUserRatingsForAllPkgs(DeriveAndStoreUserRatingsForAllPkgsResult request) {
+        Preconditions.checkNotNull(request);
+
+        final ObjectContext context = serverRuntime.getContext();
+
+        if(!authorizationService.check(
+                context,
+                tryObtainAuthenticatedUser(context).orNull(),
+                null,
+                Permission.USERRATING_DERIVEANDSTOREFORPKG)) {
+            throw new AuthorizationFailureException();
+        }
+
+ userRatingDerivationService.submit(UserRatingDerivationJob.JOB_ALL_PKG); + LOGGER.info("did enqueue request to derive and store user ratings for all packages");
+
+        return new DeriveAndStoreUserRatingsForAllPkgsResult();
+    }
+

     @Override
public GetUserRatingResult getUserRating(GetUserRatingRequest request) throws ObjectNotFoundException {
=======================================
--- /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/security/AuthorizationService.java Wed Aug 6 09:46:44 2014 UTC +++ /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/security/AuthorizationService.java Tue Aug 19 11:01:57 2014 UTC
@@ -209,6 +209,9 @@
                 UserRating userRating = (UserRating) target;
return null!=authenticatedUser && (userRating.getUser().equals(authenticatedUser) || authenticatedUser.getIsRoot());

+            case USERRATING_DERIVEANDSTOREFORPKG:
+ return null!=authenticatedUser && authenticatedUser.getIsRoot();
+
             default:
throw new IllegalStateException("unhandled permission; "+permission.name());
         }
=======================================
--- /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/security/model/Permission.java Wed Aug 6 09:46:44 2014 UTC +++ /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/security/model/Permission.java Tue Aug 19 11:01:57 2014 UTC
@@ -22,6 +22,7 @@
     AUTHORIZATION_CONFIGURE(null),

     USERRATING_EDIT(TargetType.USERRATING),
+ USERRATING_DERIVEANDSTOREFORPKG(null), // not on a package because it applies across all packages

     PKG_CREATEUSERRATING(TargetType.PKG),
     PKG_EDITICON(TargetType.PKG),
=======================================
--- /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/userrating/LocalUserRatingDerivationService.java Sun Aug 3 11:11:48 2014 UTC +++ /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/userrating/LocalUserRatingDerivationService.java Tue Aug 19 11:01:57 2014 UTC
@@ -31,7 +31,13 @@

     protected void run(UserRatingDerivationJob job) {
         Preconditions.checkNotNull(job);
- userRatingOrchestrationService.updateUserRatingDerivation(job.getPkgName());
+
+        if(job.appliesToAllPkgs()) {
+ userRatingOrchestrationService.updateUserRatingDerivationsForAllPkgs();
+        }
+        else {
+ userRatingOrchestrationService.updateUserRatingDerivation(job.getPkgName());
+        }
     }

     /**
=======================================
--- /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/userrating/UserRatingOrchestrationService.java Sun Aug 3 11:11:48 2014 UTC +++ /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/userrating/UserRatingOrchestrationService.java Tue Aug 19 11:01:57 2014 UTC
@@ -52,12 +52,6 @@
     // ------------------------------
     // SEARCH

-    // [apl 11.may.2014]
- // SelectQuery has no means of getting a count. This is a bit of an annoying limitation, but can be worked around - // by using EJBQL. However converting from an Expression to EJBQL has a problem (see CAY-1932) so for the time - // being, just use EJBQL directly by assembling strings and convert back later.
-
- // NOTE; raw EJBQL can be replaced with Expressions once CAY-1932 is fixed.
     private String prepareWhereClause(
             List<Object> parameterAccumulator,
             ObjectContext context,
@@ -142,92 +136,6 @@
throw new IllegalStateException("expected 1 row from count query, but got "+result.size());
         }
     }
-
-// public SelectQuery prepare(ObjectContext context, UserRatingSearchSpecification search) {
-//        Preconditions.checkNotNull(search);
-//        Preconditions.checkNotNull(context);
-//        DateTime now = new DateTime();
-//
-//        // build up a list of expressions
-//
-//        List<Expression> expressions = Lists.newArrayList();
-//
-//        if (!search.getIncludeInactive()) {
-//            expressions.add(ExpressionFactory.matchExp(
-//                    UserRating.ACTIVE_PROPERTY,
-//                    Boolean.TRUE));
-//        }
-//
-//        if (null != search.getDaysSinceCreated()) {
-//            expressions.add(ExpressionFactory.greaterExp(
-//                    UserRating.CREATE_TIMESTAMP_PROPERTY,
-// new java.sql.Timestamp(now.minusDays(search.getDaysSinceCreated()).getMillis())));
-//        }
-//
-//        if (null != search.getPkg() && null == search.getPkgVersion()) {
-//            expressions.add(ExpressionFactory.matchExp(
-// UserRating.PKG_VERSION_PROPERTY + "." + PkgVersion.PKG_PROPERTY,
-//                    search.getPkg()));
-//        }
-//
-// if (null != search.getArchitecture() && null == search.getPkgVersion()) {
-//            expressions.add(ExpressionFactory.matchExp(
-// UserRating.PKG_VERSION_PROPERTY + "." + PkgVersion.ARCHITECTURE_PROPERTY,
-//                    search.getArchitecture()));
-//        }
-//
-//        if (null != search.getPkgVersion()) {
-//            expressions.add(ExpressionFactory.matchExp(
-//                    UserRating.PKG_VERSION_PROPERTY,
-//                    search.getPkgVersion()));
-//        }
-//
-//        if (null != search.getUser()) {
-//            expressions.add(ExpressionFactory.matchExp(
-//                    UserRating.USER_PROPERTY,
-//                    search.getUser()));
-//        }
-//
-// return new SelectQuery(UserRating.class, ExpressionHelper.andAll(expressions));
-//    }
-//
-// public List<UserRating> search(ObjectContext context, UserRatingSearchSpecification search) {
-//        Preconditions.checkNotNull(search);
-//        Preconditions.checkNotNull(context);
-//
-//        SelectQuery selectQuery = prepare(context, search);
-//        selectQuery.setFetchOffset(search.getOffset());
-//        selectQuery.setFetchLimit(search.getLimit());
-// selectQuery.addOrdering(new Ordering(UserRating.CREATE_TIMESTAMP_PROPERTY, SortOrder.DESCENDING));
-//
-//        //noinspection unchecked
-//        return context.performQuery(selectQuery);
-//    }
-//
-// public long total(ObjectContext context, UserRatingSearchSpecification search) {
-//        Preconditions.checkNotNull(search);
-//        Preconditions.checkNotNull(context);
-//
-//        SelectQuery selectQuery = prepare(context, search);
-//        List<Object> parameters = Lists.newArrayList();
-// String ejbql = selectQuery.getQualifier().toEJBQL(parameters, "ur");
-//
-// EJBQLQuery ejbQuery = new EJBQLQuery("SELECT COUNT(ur) FROM UserRating AS ur WHERE " + ejbql);
-//
-//        for(int i=0;i<parameters.size();i++) {
-//            ejbQuery.setParameter(i+1,parameters.get(i));
-//        }
-//
-// @SuppressWarnings("unchecked") List<Number> result = context.performQuery(ejbQuery);
-//
-//        switch(result.size()) {
-//            case 1:
-//                return result.get(0).longValue();
-//
-//            default:
-// throw new IllegalStateException("expected 1 row from count query, but got "+result.size());
-//        }
-//    }

     // ------------------------------
     // DERIVATION ALGORITHM
@@ -297,6 +205,31 @@

         return context.performQuery(query);
     }
+
+    /**
+ * <p>This method will go through all of the relevant packages and will derive their user ratings.</p>
+     */
+
+    public void updateUserRatingDerivationsForAllPkgs() {
+        ObjectContext context = serverRuntime.getContext();
+
+        StringBuilder builder = new StringBuilder();
+        builder.append("SELECT p.name FROM ");
+        builder.append(Pkg.class.getSimpleName());
+        builder.append(" p");
+        builder.append(" WHERE p.active=true");
+        builder.append(" ORDER BY p.name DESC");
+
+ List<String> pkgNames = context.performQuery(new EJBQLQuery(builder.toString()));
+
+ LOGGER.info("will derive and store user ratings for {} packages", pkgNames.size());
+
+        for (String pkgName : pkgNames) {
+            updateUserRatingDerivation(pkgName);
+        }
+
+ LOGGER.info("did derive and store user ratings for {} packages", pkgNames.size());
+    }

     public void updateUserRatingDerivation(String pkgName) {
         Preconditions.checkState(!Strings.isNullOrEmpty(pkgName));
=======================================
--- /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/userrating/model/UserRatingDerivationJob.java Wed Jun 4 11:36:29 2014 UTC +++ /haikudepotserver-webapp/src/main/java/org/haikuos/haikudepotserver/userrating/model/UserRatingDerivationJob.java Tue Aug 19 11:01:57 2014 UTC
@@ -8,8 +8,24 @@
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;

+/**
+ * <p>An instance of this job can be submitted to an implementation of
+ * {@link org.haikuos.haikudepotserver.userrating.UserRatingDerivationService} in order to get the + * aggregated user rating re-calculated for the package. It is possible that the job can also be configured + * such that the derivation is undertaken not for just one package, but for every package in the system.</p>
+ */
+
 public class UserRatingDerivationJob {

+    /**
+ * <P>This is a special package name that cannot occur in actual package names which means;
+     * do the user rating derivation for all of the packages.</P>
+     */
+
+    final static String PKG_NAME_ALL = "-*-";
+
+ public final static UserRatingDerivationJob JOB_ALL_PKG = new UserRatingDerivationJob(PKG_NAME_ALL);
+
     private String pkgName;

     public UserRatingDerivationJob(String pkgName) {
@@ -22,6 +38,10 @@
     public String getPkgName() {
         return pkgName;
     }
+
+    public boolean appliesToAllPkgs() {
+        return getPkgName().equals(PKG_NAME_ALL);
+    }

     @Override
     public boolean equals(Object o) {
=======================================
--- /haikudepotserver-webapp/src/main/resources/messages.properties Thu Aug 14 11:03:33 2014 UTC +++ /haikudepotserver-webapp/src/main/resources/messages.properties Tue Aug 19 11:01:57 2014 UTC
@@ -42,6 +42,7 @@
 breadcrumb.listAuthorizationPkgRules.title=Package Authorization Rules
 breadcrumb.addAuthorizationPkgRule.title=Add Rule
 breadcrumb.pkgFeedBuilder.title=Build Feed URL
+breadcrumb.rootOperations.title=Root Operations

 about.info.title=Information
 about.info.version=Version {0}
@@ -218,6 +219,8 @@
viewPkg.userRating.noResults.authenticateAction=Login (or register) to add the first rating.
 viewPkg.userRating.user.by=by
 viewPkg.derivedUserRating.sampleSize={0} ratings
+viewPkg.deriveAndStoreUserRatingAction.title=Recalculate user rating for this package
+viewPkg.deriveAndStoreUserRatingAction.completed=- was requested

 viewRepository.importTriggered.title=Import triggered
viewRepository.importTriggered.description=the application will import the repository's data soon.
@@ -319,6 +322,7 @@
 banner.action.users=List users
 banner.action.authorizationPkgRules=Package authorization
 banner.action.pkgFeedBuilder=Build Feed URL
+banner.action.rootOperations=Root Operations

 naturalLanguage.en=English
 naturalLanguage.de=Deutsch
=======================================
--- /haikudepotserver-webapp/src/main/resources/messages_de.properties Thu Aug 14 11:03:33 2014 UTC +++ /haikudepotserver-webapp/src/main/resources/messages_de.properties Tue Aug 19 11:01:57 2014 UTC
@@ -40,6 +40,7 @@
 breadcrumb.listAuthorizationPkgRules.title=Paket Autorisierungsregeln
 breadcrumb.addAuthorizationPkgRule.title=Regel hinzufügen
 breadcrumb.pkgFeedBuilder.title=Feed-URL erzeugen
+breadcrumb.rootOperations.title=Root Operations

 about.info.title=Information
 about.info.version=Version {0}
@@ -213,6 +214,8 @@
viewPkg.userRating.noResults.authenticateAction=Anmelden, um die erste Bewertung abzugeben.
 viewPkg.userRating.user.by=von
 viewPkg.derivedUserRating.sampleSize={0} Bewertungen
+viewPkg.deriveAndStoreUserRatingAction.title=Paketebewertungen neu Rechnen
+viewPkg.deriveAndStoreUserRatingAction.completed=- ist begonnen

 viewRepository.importTriggered.title=Import angestoßen
viewRepository.importTriggered.description=Die Anwendung wird in Kürze die Daten des Depots importieren.
@@ -310,6 +313,7 @@
 banner.action.users=Benutzer anzeigen
 banner.action.authorizationPkgRules=Paket-Autorisierung
 banner.action.pkgFeedBuilder=Feed-URL erzeugen
+banner.action.rootOperations=Root Operations

 permission.pkg_editicon.title=Paket-Icon bearbeiten
 permission.pkg_editscreenshot.title=Paket-Screenshots bearbeiten
=======================================
--- /haikudepotserver-webapp/src/main/webapp/js/app/controller/aboutcontroller.js Tue Jul 8 11:11:57 2014 UTC +++ /haikudepotserver-webapp/src/main/webapp/js/app/controller/aboutcontroller.js Tue Aug 19 11:01:57 2014 UTC
@@ -39,15 +39,13 @@
                 else {
                     jsonRpc.call(
                             constants.ENDPOINT_API_V1_USER,
-                            "getUser",
+                            'getUser',
                             [{
                                 nickname : u.nickname
                             }]
                         ).then(
                         function(result) {
-                            if(result.isRoot) {
-                                $scope.canGoRuntimeInformation = true;
-                            }
+ $scope.canGoRuntimeInformation = !!result.isRoot;
                         },
                         function(err) {
                             errorHandling.handleJsonRpcError(err);
=======================================
--- /haikudepotserver-webapp/src/main/webapp/js/app/controller/runtimeinformation.html Fri Mar 28 10:40:14 2014 UTC +++ /haikudepotserver-webapp/src/main/webapp/js/app/controller/runtimeinformation.html Tue Aug 19 11:01:57 2014 UTC
@@ -4,12 +4,6 @@

 <div class="content-container">

-    <h1>Actions</h1>
-    <ul>
- <li><a href="" ng-click="goRaiseExceptionInLocalRuntime()">Raise test exception in javascript environment</a></li> - <li><a href="" ng-click="goRaiseExceptionInServerRuntime()">Raise test exception on server via json-rpc</a></li>
-    </ul>
-
     <h1>Uptime</h1>
     <p>
         This instance of the application-server has been running since
=======================================
--- /haikudepotserver-webapp/src/main/webapp/js/app/controller/runtimeinformationcontroller.js Sun Jul 27 10:55:51 2014 UTC +++ /haikudepotserver-webapp/src/main/webapp/js/app/controller/runtimeinformationcontroller.js Tue Aug 19 11:01:57 2014 UTC
@@ -47,27 +47,6 @@

             refreshRuntimeInformation();

-            // -------------------
-            // ERROR HANDLING TESTING
-
-            $scope.goRaiseExceptionInLocalRuntime = function() {
-                throw Error('test exception in javascript environment');
-            };
-
-            $scope.goRaiseExceptionInServerRuntime = function() {
-                jsonRpc.call(
-                        constants.ENDPOINT_API_V1_MISCELLANEOUS,
-                        "raiseException",
-                        [{}]
-                    ).then(
-                    function() {
- $log.error('the exception raised on the server runtime -> should not have reached this point');
-                    },
-                    function(err) {
-                        errorHandling.handleJsonRpcError(err);
-                    }
-                );
-            }
         }
     ]
 );
=======================================
--- /haikudepotserver-webapp/src/main/webapp/js/app/controller/viewpkg.html Thu Aug 14 11:03:33 2014 UTC +++ /haikudepotserver-webapp/src/main/webapp/js/app/controller/viewpkg.html Tue Aug 19 11:01:57 2014 UTC
@@ -207,6 +207,14 @@
                 <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 Thu Aug 14 11:03:33 2014 UTC +++ /haikudepotserver-webapp/src/main/webapp/js/app/controller/viewpkgcontroller.js Tue Aug 19 11:01:57 2014 UTC
@@ -6,12 +6,12 @@
 angular.module('haikudepotserver').controller(
     'ViewPkgController',
     [
-        '$scope','$log','$location','$routeParams','$rootScope',
+        '$scope','$log','$location','$routeParams','$rootScope','$timeout',
         'jsonRpc','constants','userState','errorHandling',
         'pkgScreenshot','pkgIcon','referenceData','breadcrumbs',
         'pkg','breadcrumbFactory',
         function(
-            $scope,$log,$location,$routeParams,$rootScope,
+            $scope,$log,$location,$routeParams,$rootScope,$timeout,
             jsonRpc,constants,userState,errorHandling,
             pkgScreenshot,pkgIcon,referenceData,breadcrumbs,
             pkg,breadcrumbFactory) {
@@ -24,6 +24,9 @@
             var SCREENSHOT_THUMBNAIL_TARGETHEIGHT = 240;
             var SCREENSHOT_MAX_TARGETHEIGHT = 1500;

+            $scope.didDeriveAndStoreUserRating = false;
+            $scope.didDeriveAndStoreUserRatingTimeout = undefined;
+
             $scope.pkg = undefined;
             $scope.pkgScreenshots = undefined;
             $scope.pkgIconHvifUrl = undefined;
@@ -329,6 +332,38 @@
breadcrumbs.pushAndNavigate(breadcrumbFactory.createEditPkgProminence($scope.pkg));
             };

+            /**
+ * <p>Sends a request off to enqueue that a package should have its derived rating re-calculated + * and stored. It will display a little message to indicate that this has happened and the
+             * little message will vanish after a few moments.</p>
+             */
+
+            $scope.goDeriveAndStoreUserRating = function() {
+                jsonRpc.call(
+                    constants.ENDPOINT_API_V1_USERRATING,
+                    "deriveAndStoreUserRatingForPkg",
+                    [{ pkgName: $routeParams.name }]
+                ).then(
+                    function() {
+ $log.info('requested derive and store user rating for '+$routeParams.name+' pkg');
+                        $scope.didDeriveAndStoreUserRating = true;
+
+                        if($scope.didDeriveAndStoreUserRatingTimeout) {
+ $timeout.cancel($scope.didDeriveAndStoreUserRatingTimeout);
+                        }
+
+ $scope.didDeriveAndStoreUserRatingTimeout = $timeout(function() {
+                            $scope.didDeriveAndStoreUserRating = false;
+ $scope.didDeriveAndStoreUserRatingTimeout = undefined;
+                        }, 3000);
+                    },
+                    function(err) {
+ $log.error('unable to derive and store user rating for '+$routeParams.name+' pkg');
+                        errorHandling.handleJsonRpcError(err);
+                    }
+                );
+            };
+
             $scope.goRemoveIcon = function() {
                 jsonRpc.call(
                     constants.ENDPOINT_API_V1_PKG,
=======================================
--- /haikudepotserver-webapp/src/main/webapp/js/app/directive/banner.html Thu Aug 14 11:03:33 2014 UTC +++ /haikudepotserver-webapp/src/main/webapp/js/app/directive/banner.html Tue Aug 19 11:01:57 2014 UTC
@@ -109,6 +109,12 @@
                 </a>
             </li>

+            <li ng-show="canShowRootOperations">
+                <a href="" ng-click="goRootOperations()">
+                    <message key="banner.action.rootOperations"></message>
+                </a>
+            </li>
+
         </ul>

     </modal-container>
=======================================
--- /haikudepotserver-webapp/src/main/webapp/js/app/directive/bannerdirective.js Thu Aug 14 11:03:33 2014 UTC +++ /haikudepotserver-webapp/src/main/webapp/js/app/directive/bannerdirective.js Tue Aug 19 11:01:57 2014 UTC
@@ -19,11 +19,11 @@
             [
                 '$rootScope','$scope','$log','$location','$route','$window',
                 'userState','referenceData','messageSource','breadcrumbs',
-                'errorHandling','breadcrumbFactory',
+                'errorHandling','breadcrumbFactory','jsonRpc','constants',
                 function(
                     $rootScope,$scope,$log,$location,$route,$window,
                     userState,referenceData,messageSource,breadcrumbs,
-                    errorHandling,breadcrumbFactory) {
+                    errorHandling,breadcrumbFactory,jsonRpc,constants) {

                     $scope.showActions = false;
                     $scope.userNickname = undefined;
@@ -155,6 +155,42 @@
                         $scope.showActions = true;
                     };

+                    // -----------------
+                    // ROOT ONLY
+
+                    $scope.canShowRootOperations = false;
+
+                    function updateCanShowRootOperations() {
+                        $scope.canShowRootOperations = false;
+                        var u = userState.user();
+
+                        if(u) {
+                            jsonRpc.call(
+                                constants.ENDPOINT_API_V1_USER,
+                                'getUser',
+                                [{ nickname : u.nickname }]
+                            ).then(
+                                function(result) {
+ $scope.canShowRootOperations = !!result.isRoot;
+                                },
+                                function(err) {
+                                    errorHandling.handleJsonRpcError(err);
+                                }
+                            );
+                        }
+                    }
+
+                    updateCanShowRootOperations();
+
+                    $scope.goRootOperations = function() {
+                        breadcrumbs.resetAndNavigate([
+                            breadcrumbFactory.createHome(),
+                            breadcrumbFactory.createRootOperations()
+                        ]);
+
+                        $scope.showActions = false;
+                    };
+
                     // -----------------
                     // FEEDS

@@ -265,6 +301,7 @@
                         'userChangeSuccess',
                         function() {
$scope.userNickname = userState.user() ? userState.user().nickname : undefined;
+                            updateCanShowRootOperations();
                         }
                     );

=======================================
--- /haikudepotserver-webapp/src/main/webapp/js/app/routes.js Thu Aug 14 11:03:33 2014 UTC +++ /haikudepotserver-webapp/src/main/webapp/js/app/routes.js Tue Aug 19 11:01:57 2014 UTC
@@ -11,6 +11,7 @@
var pkgVersionPrefix = '/pkg/:name/:major/:minor?/:micro?/:preRelease?/:revision?/:architectureCode';

             $routeProvider
+                
.when('/rootoperations',{controller:'RootOperationsController',templateUrl:'/js/app/controller/rootoperations.html'})
                 
.when('/pkg/feed/builder',{controller:'PkgFeedBuilderController',templateUrl:'/js/app/controller/pkgfeedbuilder.html'})
                 
.when('/paginationcontrolplayground',{controller:'PaginationControlPlayground',templateUrl:'/js/app/controller/paginationcontrolplayground.html'})
                 
.when('/repositories/add',{controller:'AddEditRepositoryController',templateUrl:'/js/app/controller/addeditrepository.html'})
=======================================
--- /haikudepotserver-webapp/src/main/webapp/js/app/service/breadcrumbfactoryservice.js Thu Aug 14 11:03:33 2014 UTC +++ /haikudepotserver-webapp/src/main/webapp/js/app/service/breadcrumbfactoryservice.js Tue Aug 19 11:01:57 2014 UTC
@@ -401,6 +401,13 @@
                     return applyDefaults({
                         titleKey : 'breadcrumb.pkgFeedBuilder.title',
                         path : '/pkg/feed/builder'
+                    });
+                },
+
+                createRootOperations : function() {
+                    return applyDefaults({
+                        titleKey : 'breadcrumb.rootOperations.title',
+                        path : '/rootoperations'
                     });
                 }

Other related posts:

  • » [haiku-depot-web] [haiku-depot-web-app] 2 new revisions pushed by haiku.li...@xxxxxxxxx on 2014-08-19 11:04 GMT - haiku-depot-web-app