Skip to content

Commit

Permalink
Merge pull request #627 from fxprunayre/improvements/harvester-timeli…
Browse files Browse the repository at this point in the history
…ne-and-misc

Fix harvester log info and display history using timeline
  • Loading branch information
François Prunayre committed Sep 2, 2014
2 parents a687db9 + b328ef7 commit e982aae
Show file tree
Hide file tree
Showing 23 changed files with 676 additions and 200 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ protected synchronized OperResult harvest() {
this.log.info("Starting harvesting of " + this.getParams().name);
error = null;
errors.clear();
final Logger logger = Log.createLogger(Geonet.HARVESTER);
final Logger logger = this.log;
final String nodeName = getParams().name + " (" + getClass().getSimpleName() + ")";
final String lastRun = new DateTime().withZone(DateTimeZone.forID("UTC")).toString();
try {
Expand Down Expand Up @@ -562,7 +562,8 @@ private void logHarvest(String logfile, Logger logger, String nodeName, String l
.setHarvesterUuid(getParams().uuid)
.setElapsedTime((int) elapsedTime)
.setHarvestDate(new ISODate(lastRun))
.setParams(getParams().node);
.setParams(getParams().node)
.setInfo(result);
historyRepository.save(history);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,14 @@ private Element doSearch(XmlRequest request, Search s) throws OperationAbortedEx
harvestError.setHint("Check with your administrator.");
this.errors.add(harvestError);
throw new OperationAbortedEx("Raised exception when searching", e);
}
catch(Exception e)
{
log.warning("Raised exception when searching : "+ e);
throw new OperationAbortedEx("Raised exception when searching", e);
} catch(Exception e) {
HarvestError harvestError = new HarvestError(e, log);
harvestError.setDescription("Error while searching on "
+ params.name + ". ");
harvestError.setHint("Check with your administrator.");
this.errors.add(harvestError);
log.warning("Raised exception when searching : "+ e);
return new Element("response");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,19 @@

package org.fao.geonet.kernel.harvest.harvester.geonet;

import com.google.common.base.Splitter;
import org.fao.geonet.Logger;
import org.fao.geonet.Util;
import org.fao.geonet.constants.Geonet;
import org.fao.geonet.exceptions.BadParameterEx;
import org.fao.geonet.exceptions.OperationAbortedEx;
import org.fao.geonet.lib.Lib;
import org.fao.geonet.utils.Log;
import org.fao.geonet.utils.Xml;
import org.jdom.Element;

import java.util.Iterator;

//=============================================================================

class Search
Expand All @@ -37,8 +45,8 @@ class Search
//--- Constructor
//---
//---------------------------------------------------------------------------

public Search() {}
public Search() {
}

//---------------------------------------------------------------------------

Expand Down Expand Up @@ -94,7 +102,24 @@ public Element createRequest()
add(req, "abstract", abstrac);
add(req, "themekey", keywords);
add(req, "siteId", sourceUuid);
add(req, anyField, anyValue);

try {
Iterable<String> fields = Splitter.on(';').split(anyField);
Iterable<String> values = Splitter.on(';').split(anyValue);
Iterator<String> valuesIterator = values.iterator();
for (String field : fields) {
String value = valuesIterator.next();
if (field != null && value != null) {
add(req, field, value);
}
}
} catch (Exception e) {
throw new OperationAbortedEx("Search request criteria error. " +
"Check that the free criteria fields '" +
anyField + "' and values '" +
anyValue + "' are correct. You MUST have the same " +
"number of criteria and values.", e);
}

if (digital)
Lib.element.add(req, "digital", "on");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,107 @@
}
};
});


/**
* @ngdoc directive
* @name gn_utility_directive.directive:gnPaginationList
* @function
*
* @description
* Adjust textarea size onload and when text change.
*
* Source: http://www.frangular.com/2012/12/
* pagination-cote-client-directive-angularjs.html
*/
module.factory('gnPaginationListStateCache', ['$cacheFactory',
function($cacheFactory) {
return $cacheFactory('gnPaginationListStateCache');
}]);
module.directive('gnPaginationList', ['gnPaginationListStateCache',
function(gnPaginationListStateCache) {
var pageSizeLabel = 'Page size';
return {
priority: 0,
restrict: 'A',
scope: {items: '&'},
templateUrl: '../../catalog/components/utility/' +
'partials/paginationlist.html',
replace: false,
compile: function compile(tElement, tAttrs) {
var cacheId = tAttrs.cache ? tAttrs.cache + '.paginator' : '';
return {
pre: function preLink(scope) {
scope.pageSizeList = [10, 20, 50, 100];
var defaultSettings = {
pageSize: 10,
currentPage: 0
};
scope.paginator = cacheId ?
gnPaginationListStateCache.get(cacheId) || defaultSettings :
defaultSettings;
if (cacheId) {
gnPaginationListStateCache.put(cacheId, scope.paginator);
}
scope.isFirstPage = function() {
return scope.paginator.currentPage == 0;
};
scope.isLastPage = function() {
if (scope.items()) {
return scope.paginator.currentPage >=
scope.items().length / scope.paginator.pageSize - 1;
} else {
return false;
}
};
scope.incPage = function() {
if (!scope.isLastPage()) {
scope.paginator.currentPage++;
}
};
scope.decPage = function() {
if (!scope.isFirstPage()) {
scope.paginator.currentPage--;
}
};
scope.firstPage = function() {
scope.paginator.currentPage = 0;
};
scope.numberOfPages = function() {
if (scope.items()) {
return Math.ceil(scope.items().length /
scope.paginator.pageSize);
} else {
return 0;
}
};
scope.$watch('paginator.pageSize',
function(newValue, oldValue) {
if (newValue != oldValue) {
scope.firstPage();
}
});

// ---- Functions available in parent scope -----

scope.$parent.firstPage = function() {
scope.firstPage();
};
// Function that returns the reduced items list,
// to use in ng-repeat
scope.$parent.pageItems = function() {
if (scope.items()) {
var start = scope.paginator.currentPage *
scope.paginator.pageSize;
var limit = scope.paginator.pageSize;
return scope.items().slice(start, start + limit);
} else {
return null;
}
};
}
};
}
};
}]);
})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<ul class="pager"
data-ng-show="numberOfPages() > 1">
<li>
<a href="" class="btn btn-default btn-xs"
data-ng-disabled="isFirstPage() ? 'disabled' : ''"
data-ng-click="decPage()"
data-translate>previous</a></li>
<li>{{paginator.currentPage+1}} / {{numberOfPages()}}</li>
<li>
<a href="" class="btn btn-default btn-xs"
data-ng-class="isLastPage() ? 'disabled' : ''"
data-ng-click="incPage()"
data-translate>next</a></li>
<!--<li>-->
<!--<select ng-model="paginator.pageSize"-->
<!--data-ng-options="size for size in pageSizeList"></select>-->
<!--</li>-->
</ul>
14 changes: 11 additions & 3 deletions web-ui/src/main/resources/catalog/js/admin/CSWVirtualController.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
*
*/
module.controller('GnCSWVirtualController', [
'$scope', '$http', '$rootScope', '$translate',
function($scope, $http, $rootScope, $translate) {
'$scope', '$http', '$rootScope', '$translate', '$timeout',
function($scope, $http, $rootScope, $translate, $timeout) {

/**
* CSW virtual
*/
$scope.cswVirtual = {};
$scope.cswVirtual = null;
$scope.virtualCSWSelected = null;
$scope.virtualCSWUpdated = false;
$scope.virtualCSWSearch = '';
Expand Down Expand Up @@ -74,6 +74,10 @@
serviceParameters[param['@name']] = param['#text'];
});
$scope.virtualCSWUpdated = false;

$timeout(function() {
$('#servicename').focus();
}, 100);
}).error(function(data) {
// TODO
});
Expand All @@ -97,6 +101,10 @@
'type': ''
}
};

$timeout(function() {
$('#servicename').focus();
}, 100);
};
$scope.saveVirtualCSW = function(formId) {

Expand Down
12 changes: 10 additions & 2 deletions web-ui/src/main/resources/catalog/js/admin/CategoriesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
* to manage category.
*/
module.controller('GnCategoriesController', [
'$scope', '$routeParams', '$http', '$rootScope', '$translate',
function($scope, $routeParams, $http, $rootScope, $translate) {
'$scope', '$routeParams', '$http', '$rootScope',
'$translate', '$timeout',
function($scope, $routeParams, $http, $rootScope,
$translate, $timeout) {

$scope.categories = null;
$scope.categorySelected = {id: $routeParams.categoryId};
Expand All @@ -21,6 +23,9 @@
$scope.selectCategory = function(c) {
$scope.cateroryUpdated = false;
$scope.categorySelected = c;
$timeout(function() {
$('#categoryname').focus();
}, 100);
};


Expand Down Expand Up @@ -71,6 +76,9 @@
'@id': '',
name: ''
};
$timeout(function() {
$('#categoryname').focus();
}, 100);
};

$scope.unselectCategory = function() {
Expand Down
11 changes: 10 additions & 1 deletion web-ui/src/main/resources/catalog/js/admin/HarvestController.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,44 @@
tabs: []
};
$scope.harvesterTypes = {};
$scope.harvesters = {};
$scope.harvesters = null;
$scope.harvesterSelected = null;
$scope.harvesterUpdated = false;
$scope.harvesterNew = false;
$scope.harvesterHistory = {};
$scope.isLoadingHarvester = false;
$scope.isLoadingHarvesterHistory = false;


var unbindStatusListener = null;


function loadHarvesters() {
$scope.isLoadingHarvester = true;
$scope.harvesters = null;
return $http.get('admin.harvester.list@json').success(function(data) {
if (data != 'null') {
$scope.harvesters = data;
gnUtilityService.parseBoolean($scope.harvesters);
$scope.isLoadingHarvester = false;
}
}).error(function(data) {
// TODO
$scope.isLoadingHarvester = false;
});
}


function loadHistory() {
$scope.isLoadingHarvesterHistory = true;
$scope.harvesterHistory = undefined;
$http.get('admin.harvester.history@json?uuid=' +
$scope.harvesterSelected.site.uuid).success(function(data) {
$scope.harvesterHistory = data.harvesthistory;
$scope.isLoadingHarvesterHistory = false;
}).error(function(data) {
// TODO
$scope.isLoadingHarvesterHistory = false;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
creatingThesaurus = false;
$scope.thesaurusSelected = t;
$scope.thesaurusSelectedActivated = t.activated == 'y';

$('#keywordFilter').focus();
searchThesaurusKeyword();
};

Expand Down
Loading

0 comments on commit e982aae

Please sign in to comment.