metrics update
This commit is contained in:
parent
c6b8ad5639
commit
ede8bbf48e
|
@ -70,7 +70,7 @@ public class Admin extends BaseController {
|
||||||
userDatasetProfile.setRole(0);
|
userDatasetProfile.setRole(0);
|
||||||
getApiContext().getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
|
getApiContext().getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
|
||||||
datasetProfileManager.storeDatasetProfileUsers(datasetProfile, profile);
|
datasetProfileManager.storeDatasetProfileUsers(datasetProfile, profile);
|
||||||
MetricsManager.increaseValue("totalTemplates", 1);
|
MetricsManager.increaseValue("argos_dataset_templates", 1, "total");
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId());
|
return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ public class Admin extends BaseController {
|
||||||
eu.eudat.data.entities.DatasetProfile datasetProfile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(datasetprofile);
|
eu.eudat.data.entities.DatasetProfile datasetProfile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(datasetprofile);
|
||||||
datasetProfileManager.storeDatasetProfileUsers(datasetProfile, profile);
|
datasetProfileManager.storeDatasetProfileUsers(datasetProfile, profile);
|
||||||
if (datasetProfile.getStatus() == 1 && oldStatus == 0) {
|
if (datasetProfile.getStatus() == 1 && oldStatus == 0) {
|
||||||
MetricsManager.increaseValue("activeTemplates", 1);
|
MetricsManager.increaseValue("argos_dataset_templates", 1, "active");
|
||||||
}
|
}
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.NO_MESSAGE));
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class Login {
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<PrincipalModel>> externallogin(@RequestBody LoginInfo credentials) throws GeneralSecurityException, NullEmailException {
|
ResponseEntity<ResponseItem<PrincipalModel>> externallogin(@RequestBody LoginInfo credentials) throws GeneralSecurityException, NullEmailException {
|
||||||
logger.info("Trying To Login With " + credentials.getProvider());
|
logger.info("Trying To Login With " + credentials.getProvider());
|
||||||
MetricsManager.increaseValue("usersLoggedIn", 1);
|
MetricsManager.increaseValue("argos_users", 1, "loggedin");
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<PrincipalModel>().payload(customAuthenticationProvider.authenticate(credentials)).status(ApiMessageCode.SUCCESS_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<PrincipalModel>().payload(customAuthenticationProvider.authenticate(credentials)).status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ public class Login {
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<PrincipalModel>> nativelogin(@RequestBody Credentials credentials) throws NullEmailException {
|
ResponseEntity<ResponseItem<PrincipalModel>> nativelogin(@RequestBody Credentials credentials) throws NullEmailException {
|
||||||
logger.info(credentials.getUsername() + " Trying To Login");
|
logger.info(credentials.getUsername() + " Trying To Login");
|
||||||
MetricsManager.increaseValue("usersLoggedIn", 1);
|
MetricsManager.increaseValue("argos_users", 1, "loggedin");
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<PrincipalModel>().payload(userManager.authenticate(this.nonVerifiedUserAuthenticationService, credentials)).status(ApiMessageCode.SUCCESS_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<PrincipalModel>().payload(userManager.authenticate(this.nonVerifiedUserAuthenticationService, credentials)).status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ public class Login {
|
||||||
ResponseEntity<ResponseItem<Principal>> logout(Principal principal) {
|
ResponseEntity<ResponseItem<Principal>> logout(Principal principal) {
|
||||||
this.nonVerifiedUserAuthenticationService.Logout(principal.getToken());
|
this.nonVerifiedUserAuthenticationService.Logout(principal.getToken());
|
||||||
logger.info(principal + " Logged Out");
|
logger.info(principal + " Logged Out");
|
||||||
MetricsManager.decreaseValue("usersLoggedIn", 1);
|
MetricsManager.decreaseValue("argos_users", 1, "loggedin");
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Principal>().status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Principal>().status(ApiMessageCode.NO_MESSAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class UserGuideController {
|
||||||
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
|
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
|
||||||
public ResponseEntity getUserGuide(@PathVariable(name = "lang") String lang) throws IOException {
|
public ResponseEntity getUserGuide(@PathVariable(name = "lang") String lang) throws IOException {
|
||||||
long files = Files.list(Paths.get(this.environment.getProperty("userguide.path"))).count();
|
long files = Files.list(Paths.get(this.environment.getProperty("userguide.path"))).count();
|
||||||
MetricsManager.calculateValue("languages", (int) files);
|
MetricsManager.calculateValue("argos_languages", (int) files, null);
|
||||||
Stream<Path> walk = Files.walk(Paths.get(this.environment.getProperty("userguide.path")));
|
Stream<Path> walk = Files.walk(Paths.get(this.environment.getProperty("userguide.path")));
|
||||||
List<String> result = walk.filter(Files::isRegularFile)
|
List<String> result = walk.filter(Files::isRegularFile)
|
||||||
.map(Path::toString).collect(Collectors.toList());
|
.map(Path::toString).collect(Collectors.toList());
|
||||||
|
|
|
@ -376,7 +376,7 @@ public class DataManagementPlanManager {
|
||||||
|
|
||||||
setNotification = true;
|
setNotification = true;
|
||||||
} else {
|
} else {
|
||||||
MetricsManager.increaseValue("draftDMPs", 1);
|
MetricsManager.increaseValue("argos_managed_dmps", 1, "draft");
|
||||||
}
|
}
|
||||||
|
|
||||||
DMP newDmp = dataManagementPlan.toDataModel();
|
DMP newDmp = dataManagementPlan.toDataModel();
|
||||||
|
@ -500,7 +500,7 @@ public class DataManagementPlanManager {
|
||||||
if (dataManagementPlan.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue() && dmp1.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()))
|
if (dataManagementPlan.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue() && dmp1.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()))
|
||||||
throw new Exception("DMP is finalized, therefore cannot be edited.");
|
throw new Exception("DMP is finalized, therefore cannot be edited.");
|
||||||
} else {
|
} else {
|
||||||
MetricsManager.increaseValue("draftDMPs", 1);
|
MetricsManager.increaseValue("argos_managed_dmps", 1, "draft");
|
||||||
}
|
}
|
||||||
List<Dataset> datasets = new ArrayList<>();
|
List<Dataset> datasets = new ArrayList<>();
|
||||||
DMP tempDMP = dataManagementPlan.toDataModel();
|
DMP tempDMP = dataManagementPlan.toDataModel();
|
||||||
|
@ -616,7 +616,7 @@ public class DataManagementPlanManager {
|
||||||
newDmp.setDataset(new HashSet<>(databaseRepository.getDatasetDao().getWithCriteria(criteria1).toList()));
|
newDmp.setDataset(new HashSet<>(databaseRepository.getDatasetDao().getWithCriteria(criteria1).toList()));
|
||||||
|
|
||||||
this.updateIndex(newDmp);
|
this.updateIndex(newDmp);
|
||||||
MetricsManager.increaseValue("draftDMPs", 1);
|
MetricsManager.increaseValue("argos_managed_dmps", 1, "draft");
|
||||||
|
|
||||||
return newDmp.getId();
|
return newDmp.getId();
|
||||||
}
|
}
|
||||||
|
@ -630,16 +630,16 @@ public class DataManagementPlanManager {
|
||||||
DMP oldDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(uuid);
|
DMP oldDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(uuid);
|
||||||
switch (oldDmp.getStatus()) {
|
switch (oldDmp.getStatus()) {
|
||||||
case 0:
|
case 0:
|
||||||
MetricsManager.decreaseValue("draftDMPs", 1);
|
MetricsManager.decreaseValue("argos_managed_dmps", 1, "draft");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (oldDmp.getDoi() != null) {
|
if (oldDmp.getDoi() != null) {
|
||||||
MetricsManager.decreaseValue("doiedDMPs", 1);
|
MetricsManager.decreaseValue("argos_managed_dmps", 1, "doied");
|
||||||
}
|
}
|
||||||
if (oldDmp.isPublic()) {
|
if (oldDmp.isPublic()) {
|
||||||
MetricsManager.decreaseValue("publishedDMPs", 1);
|
MetricsManager.decreaseValue("argos_managed_dmps", 1, "published");
|
||||||
}
|
}
|
||||||
MetricsManager.decreaseValue("finalizedDMPs", 1);
|
MetricsManager.decreaseValue("argos_managed_dmps", 1, "finalized");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
oldDmp.setStatus(DMP.DMPStatus.DELETED.getValue());
|
oldDmp.setStatus(DMP.DMPStatus.DELETED.getValue());
|
||||||
|
@ -679,7 +679,7 @@ public class DataManagementPlanManager {
|
||||||
else {
|
else {
|
||||||
researcher.setCreationUser(user);
|
researcher.setCreationUser(user);
|
||||||
researcherRepository.createOrUpdate(researcher);
|
researcherRepository.createOrUpdate(researcher);
|
||||||
MetricsManager.increaseValue("researchers", 1);
|
MetricsManager.increaseValue("argos_researchers", 1, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -759,14 +759,14 @@ public class DataManagementPlanManager {
|
||||||
project.setType(Project.ProjectType.EXTERNAL.getValue());
|
project.setType(Project.ProjectType.EXTERNAL.getValue());
|
||||||
if (project.getId() == null) project.setId(UUID.randomUUID());
|
if (project.getId() == null) project.setId(UUID.randomUUID());
|
||||||
projectDao.createOrUpdate(project);
|
projectDao.createOrUpdate(project);
|
||||||
MetricsManager.increaseValue("projects", 1);
|
MetricsManager.increaseValue("argos_projects", 1, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
project.setType(Project.ProjectType.EXTERNAL.getValue());
|
project.setType(Project.ProjectType.EXTERNAL.getValue());
|
||||||
if (project.getId() == null) project.setId(UUID.randomUUID());
|
if (project.getId() == null) project.setId(UUID.randomUUID());
|
||||||
projectDao.createOrUpdate(project);
|
projectDao.createOrUpdate(project);
|
||||||
MetricsManager.increaseValue("projects", 1);
|
MetricsManager.increaseValue("argos_projects", 1, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -843,7 +843,7 @@ public class DataManagementPlanManager {
|
||||||
return newDataset;
|
return newDataset;
|
||||||
}).thenApplyAsync(item -> {
|
}).thenApplyAsync(item -> {
|
||||||
futures.add(datasetDao.createOrUpdateAsync(item).whenComplete(((dataset1, throwable) -> {
|
futures.add(datasetDao.createOrUpdateAsync(item).whenComplete(((dataset1, throwable) -> {
|
||||||
MetricsManager.increaseValue("draftDatasets", 1);
|
MetricsManager.increaseValue("argos_managed_dataset_descriptions", 1, "draft");
|
||||||
eu.eudat.elastic.entities.Dataset datasetElastic = new eu.eudat.elastic.entities.Dataset();
|
eu.eudat.elastic.entities.Dataset datasetElastic = new eu.eudat.elastic.entities.Dataset();
|
||||||
datasetElastic.setId(dataset1.getId().toString());
|
datasetElastic.setId(dataset1.getId().toString());
|
||||||
datasetElastic.setLabel(dataset1.getLabel());
|
datasetElastic.setLabel(dataset1.getLabel());
|
||||||
|
@ -901,7 +901,7 @@ public class DataManagementPlanManager {
|
||||||
dmp.setPublic(true);
|
dmp.setPublic(true);
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp);
|
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp);
|
||||||
this.updateIndex(dmp);
|
this.updateIndex(dmp);
|
||||||
MetricsManager.increaseValue("publishedDMPs", 1);
|
MetricsManager.increaseValue("argos_managed_dmps", 1, "published");
|
||||||
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
|
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
|
||||||
criteria.setGroupIds(Collections.singletonList(dmp.getGroupId()));
|
criteria.setGroupIds(Collections.singletonList(dmp.getGroupId()));
|
||||||
criteria.setAllVersions(true);
|
criteria.setAllVersions(true);
|
||||||
|
@ -914,7 +914,7 @@ public class DataManagementPlanManager {
|
||||||
tags = elastic.getTags();
|
tags = elastic.getTags();
|
||||||
}
|
}
|
||||||
this.datasetManager.updateTags(dataset, tags);
|
this.datasetManager.updateTags(dataset, tags);
|
||||||
MetricsManager.increaseValue("publishedDatasets", 1);
|
MetricsManager.increaseValue("argos_managed_dataset_descriptions", 1, "published");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
@ -936,8 +936,8 @@ public class DataManagementPlanManager {
|
||||||
dmp.setStatus(DMP.DMPStatus.FINALISED.getValue());
|
dmp.setStatus(DMP.DMPStatus.FINALISED.getValue());
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp);
|
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp);
|
||||||
this.updateIndex(dmp);
|
this.updateIndex(dmp);
|
||||||
MetricsManager.decreaseValue("draftDMPs", 1);
|
MetricsManager.decreaseValue("argos_managed_dmps", 1, "draft");
|
||||||
MetricsManager.increaseValue("finalizedDMPs", 1);
|
MetricsManager.increaseValue("argos_managed_dmps", 1, "finalized");
|
||||||
List<Dataset> indexDatasets = new ArrayList<>();
|
List<Dataset> indexDatasets = new ArrayList<>();
|
||||||
if (datasetsToBeFinalized != null && datasetsToBeFinalized.getUuids() != null && !datasetsToBeFinalized.getUuids().isEmpty()) {
|
if (datasetsToBeFinalized != null && datasetsToBeFinalized.getUuids() != null && !datasetsToBeFinalized.getUuids().isEmpty()) {
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
||||||
|
@ -987,8 +987,8 @@ public class DataManagementPlanManager {
|
||||||
sendNotification(dmp, user, NotificationType.DMP_FINALISED);
|
sendNotification(dmp, user, NotificationType.DMP_FINALISED);
|
||||||
}
|
}
|
||||||
this.updateDatasetsIndex(indexDatasets);
|
this.updateDatasetsIndex(indexDatasets);
|
||||||
MetricsManager.decreaseValue("draftDatasets", indexDatasets.size());
|
MetricsManager.decreaseValue("argos_managed_dataset_descriptions", indexDatasets.size(), "draft");
|
||||||
MetricsManager.increaseValue("finalizedDatasets", indexDatasets.size());
|
MetricsManager.increaseValue("argos_managed_dataset_descriptions", indexDatasets.size(), "finalized");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void undoFinalize(UUID id, Principal principal) throws Exception {
|
public void undoFinalize(UUID id, Principal principal) throws Exception {
|
||||||
|
@ -1000,8 +1000,8 @@ public class DataManagementPlanManager {
|
||||||
dmp.setStatus(DMP.DMPStatus.ACTIVE.getValue());
|
dmp.setStatus(DMP.DMPStatus.ACTIVE.getValue());
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp);
|
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp);
|
||||||
this.updateIndex(dmp);
|
this.updateIndex(dmp);
|
||||||
MetricsManager.decreaseValue("finalizedDMPs", 1);
|
MetricsManager.decreaseValue("argos_managed_dmps", 1, "finalized");
|
||||||
MetricsManager.increaseValue("draftDMPs", 1);
|
MetricsManager.increaseValue("argos_managed_dmps", 1, "draft");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateUsers(UUID id, List<UserInfoListingModel> users, Principal principal) throws Exception {
|
public void updateUsers(UUID id, List<UserInfoListingModel> users, Principal principal) throws Exception {
|
||||||
|
@ -2094,6 +2094,16 @@ public class DataManagementPlanManager {
|
||||||
return apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getWithCritetia(criteria).count();
|
return apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getWithCritetia(criteria).count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long countAllFunders() {
|
||||||
|
FunderCriteria criteria = new FunderCriteria();
|
||||||
|
return apiContext.getOperationsContext().getDatabaseRepository().getFunderDao().getWithCritetia(criteria).count();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long countAllGrants() {
|
||||||
|
GrantCriteria criteria = new GrantCriteria();
|
||||||
|
return apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getWithCriteria(criteria).count();
|
||||||
|
}
|
||||||
|
|
||||||
/*public DataTableData<DataManagementPlanListingModel> getPublicPaged(DataManagmentPlanPublicTableRequest dataManagementPlanPublicTableRequest, String fieldsGroup, Principal principal) throws Exception {
|
/*public DataTableData<DataManagementPlanListingModel> getPublicPaged(DataManagmentPlanPublicTableRequest dataManagementPlanPublicTableRequest, String fieldsGroup, Principal principal) throws Exception {
|
||||||
dataManagementPlanPublicTableRequest.setQuery(databaseRepository.getDmpDao().asQueryable().withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class)));
|
dataManagementPlanPublicTableRequest.setQuery(databaseRepository.getDmpDao().asQueryable().withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class)));
|
||||||
QueryableList<DMP> items = dataManagementPlanPublicTableRequest.applyCriteria();
|
QueryableList<DMP> items = dataManagementPlanPublicTableRequest.applyCriteria();
|
||||||
|
|
|
@ -591,7 +591,7 @@ public class DatasetManager {
|
||||||
sendNotification = true;
|
sendNotification = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MetricsManager.increaseValue("draftDatasets", 1);
|
MetricsManager.increaseValue("argos_managed_dataset_descriptions", 1, "draft");
|
||||||
}
|
}
|
||||||
if (dmp.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()) && datasetWizardModel.getId() != null)
|
if (dmp.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()) && datasetWizardModel.getId() != null)
|
||||||
throw new Exception("DMP is finalized, therefore Dataset cannot be edited.");
|
throw new Exception("DMP is finalized, therefore Dataset cannot be edited.");
|
||||||
|
@ -826,7 +826,7 @@ public class DatasetManager {
|
||||||
if (dataset.getStatus() != eu.eudat.data.entities.Dataset.Status.FINALISED.getValue())
|
if (dataset.getStatus() != eu.eudat.data.entities.Dataset.Status.FINALISED.getValue())
|
||||||
throw new Exception("You cannot make public a Dataset That Has not Been Finalised");
|
throw new Exception("You cannot make public a Dataset That Has not Been Finalised");
|
||||||
datasetDao.createOrUpdate(dataset);
|
datasetDao.createOrUpdate(dataset);
|
||||||
MetricsManager.increaseValue("publishedDatasets", 1);
|
MetricsManager.increaseValue("argos_managed_dataset_descriptions", 1, "published");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<byte[]> getDocument(String id, VisibilityRuleService visibilityRuleService, String contentType, Principal principal) throws IllegalAccessException, IOException, InstantiationException {
|
public ResponseEntity<byte[]> getDocument(String id, VisibilityRuleService visibilityRuleService, String contentType, Principal principal) throws IllegalAccessException, IOException, InstantiationException {
|
||||||
|
@ -915,7 +915,7 @@ public class DatasetManager {
|
||||||
createServicesIfTheyDontExist(entity);
|
createServicesIfTheyDontExist(entity);
|
||||||
createExternalDatasetsIfTheyDontExist(entity);
|
createExternalDatasetsIfTheyDontExist(entity);
|
||||||
|
|
||||||
MetricsManager.increaseValue("draftDatasets", 1);
|
MetricsManager.increaseValue("argos_managed_dataset_descriptions", 1, "draft");
|
||||||
return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(entity);
|
return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class DatasetProfileManager {
|
||||||
DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().detachEntity(profile);
|
apiContext.getOperationsContext().getDatabaseRepository().detachEntity(profile);
|
||||||
profile.setId(null);
|
profile.setId(null);
|
||||||
MetricsManager.increaseValue("totalTemplates", 1);
|
MetricsManager.increaseValue("argos_dataset_templates", 1, "total");
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ public class DatasetProfileManager {
|
||||||
File localFile = convert(multiPartFile);
|
File localFile = convert(multiPartFile);
|
||||||
eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile profile = xmlBuilder.build(localFile);
|
eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile profile = xmlBuilder.build(localFile);
|
||||||
Files.deleteIfExists(localFile.toPath());
|
Files.deleteIfExists(localFile.toPath());
|
||||||
MetricsManager.increaseValue("totalTemplates", 1);
|
MetricsManager.increaseValue("argos_dataset_templates", 1, "total");
|
||||||
return profile;
|
return profile;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
|
|
|
@ -21,44 +21,56 @@ import java.util.stream.Stream;
|
||||||
public class MetricsManager {
|
public class MetricsManager {
|
||||||
private final static Logger logger = LoggerFactory.getLogger(MetricsManager.class);
|
private final static Logger logger = LoggerFactory.getLogger(MetricsManager.class);
|
||||||
private static Map<String, Gauge> gauges = Stream.of( new Object[][]{
|
private static Map<String, Gauge> gauges = Stream.of( new Object[][]{
|
||||||
{"usersLoggedIn", Gauge.build("users_logged_in", "Number of current logged in users").register()},
|
{"argos_managed_dmps", Gauge.build().name("argos_managed_dmps").help("Number of managed DMPs").labelNames("status").register()},
|
||||||
{"projects", Gauge.build("projects", "Number of registered Projects").register()},
|
|
||||||
{"draftDMPs", Gauge.build("draft_dmps", "Number of draft DMPs").register()},
|
{"argos_funders", Gauge.build().name("argos_funders").help("Number of registered Funders").register()},
|
||||||
{"finalizedDMPs", Gauge.build("finalized_dmps", "Number of finalized DMPs").register()},
|
{"argos_grants", Gauge.build().name("argos_grants").help("Number of registered Grants").register()},
|
||||||
{"publishedDMPs", Gauge.build("published_dmps", "Number of published DMPs").register()},
|
{"argos_projects", Gauge.build().name("argos_projects").help("Number of registered Projects").register()},
|
||||||
{"doiedDMPs", Gauge.build("doied_dmps", "Number of DMPs with DOI").register()},
|
{"argos_researchers", Gauge.build().name("argos_researchers").help("Number of Colaborators/Researchers").register()},
|
||||||
{"draftDatasets", Gauge.build("draft_datasets", "Number of draft Datasets").register()},
|
|
||||||
{"finalizedDatasets", Gauge.build("finalized_datasets", "Number of finalized Datasets").register()},
|
{"argos_managed_dataset_descriptions", Gauge.build().name("argos_managed_dataset_descriptions").help("Number of managed Dataset Descriptions").labelNames("status").register()},
|
||||||
{"publishedDatasets", Gauge.build("published_datasets", "Number of published Datasets").register()},
|
|
||||||
{"doiedDatasets", Gauge.build("doied_datasets", "Number of Datasets with DOI").register()},
|
{"argos_dataset_templates", Gauge.build().name("argos_dataset_templates").help("Number of dataset Templates").labelNames("status").register()},
|
||||||
{"researchers", Gauge.build("researchers", "Number of Colaborators/Researchers").register()},
|
|
||||||
{"totalTemplates", Gauge.build("total_templates", "Number of total Templates").register()},
|
{"argos_users", Gauge.build().name("argos_users").help("Number of users").labelNames("type").register()},
|
||||||
{"activeTemplates", Gauge.build("active_templates", "Number of active Templates").register()},
|
|
||||||
{"usedTemplates", Gauge.build("used_templates", "Number of used Templates").register()},
|
{"argos_languages", Gauge.build().name("argos_languages").help("Number of Languages").register()},
|
||||||
{"languages", Gauge.build("languages", "Number of Languages").register()},
|
|
||||||
{"totalUsers", Gauge.build("total_users", "Total Number of Users").register()}
|
|
||||||
}).collect(Collectors.toMap(data -> (String)data[0], data -> (Gauge) data[1]));
|
}).collect(Collectors.toMap(data -> (String)data[0], data -> (Gauge) data[1]));
|
||||||
|
|
||||||
public static void increaseValue(String name, int amount) {
|
public static void increaseValue(String name, int amount, String label) {
|
||||||
gauges.get(name).inc(amount);
|
|
||||||
|
if(label != null) {
|
||||||
|
gauges.get(name).labels(label).inc(amount);
|
||||||
|
} else {
|
||||||
|
gauges.get(name).inc(amount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void decreaseValue(String name, int amount) {
|
public static void decreaseValue(String name, int amount, String label) {
|
||||||
gauges.get(name).dec(amount);
|
if(label != null) {
|
||||||
|
gauges.get(name).labels(label).dec(amount);
|
||||||
|
} else {
|
||||||
|
gauges.get(name).dec(amount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Integer getValue(String name) {
|
public static Integer getValue(String name, String label) {
|
||||||
return Double.valueOf(gauges.get(name).get()).intValue();
|
if(label != null) {
|
||||||
|
return Double.valueOf(gauges.get(name).labels(label).get()).intValue();
|
||||||
|
} else {
|
||||||
|
return Double.valueOf(gauges.get(name).get()).intValue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void calculateValue(String name, int amount) {
|
public static void calculateValue(String name, int amount, String label) {
|
||||||
Integer orig = getValue(name);
|
Integer orig = getValue(name, label);
|
||||||
int diff = orig - amount;
|
int diff = orig - amount;
|
||||||
if (diff != 0) {
|
if (diff != 0) {
|
||||||
if (diff > 0) {
|
if (diff > 0) {
|
||||||
decreaseValue(name, diff);
|
decreaseValue(name, diff, label);
|
||||||
} else {
|
} else {
|
||||||
increaseValue(name, Math.abs(diff));
|
increaseValue(name, Math.abs(diff), label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,23 +95,31 @@ public class MetricsManager {
|
||||||
@Scheduled(initialDelay = 1000 * 60 * 60, fixedDelay = 1000 * 60 * 60)
|
@Scheduled(initialDelay = 1000 * 60 * 60, fixedDelay = 1000 * 60 * 60)
|
||||||
public void init() throws IOException {
|
public void init() throws IOException {
|
||||||
logger.info("Start calculating Metrics");
|
logger.info("Start calculating Metrics");
|
||||||
calculateValue("draftDMPs", (int) dataManagementPlanManager.countAllDrafts());
|
calculateValue("argos_managed_dmps", (int) dataManagementPlanManager.countAllDrafts(), "draft");
|
||||||
calculateValue("finalizedDMPs", (int) dataManagementPlanManager.countAllFinalized());
|
calculateValue("argos_managed_dmps", (int) dataManagementPlanManager.countAllFinalized(), "finalized");
|
||||||
calculateValue("publishedDMPs", (int) dataManagementPlanManager.countAllPublished());
|
calculateValue("argos_managed_dmps", (int) dataManagementPlanManager.countAllPublished(), "published");
|
||||||
calculateValue("doiedDMPs", (int) dataManagementPlanManager.countAllDoied());
|
calculateValue("argos_managed_dmps", (int) dataManagementPlanManager.countAllDoied(), "doied");
|
||||||
calculateValue("projects", (int) dataManagementPlanManager.countAllProjects());
|
|
||||||
calculateValue("researchers", (int) dataManagementPlanManager.countAllResearchers());
|
calculateValue("argos_funders", (int) dataManagementPlanManager.countAllFunders(), null);
|
||||||
calculateValue("draftDatasets", (int) datasetManager.countAllDraft());
|
calculateValue("argos_grants", (int) dataManagementPlanManager.countAllGrants(), null);
|
||||||
calculateValue("finalizedDatasets", (int) datasetManager.countAllFinalized());
|
calculateValue("argos_projects", (int) dataManagementPlanManager.countAllProjects(), null);
|
||||||
calculateValue("publishedDatasets", (int) datasetManager.countAllPublic());
|
calculateValue("argos_researchers", (int) dataManagementPlanManager.countAllResearchers(), null);
|
||||||
calculateValue("doiedDatasets", (int) datasetManager.countAllWithDoi());
|
|
||||||
calculateValue("totalTemplates", (int) datasetProfileManager.countAlldraft());
|
calculateValue("argos_managed_dataset_descriptions", (int) datasetManager.countAllDraft(), "draft");
|
||||||
calculateValue("activeTemplates", (int) datasetProfileManager.countAllFinalized());
|
calculateValue("argos_managed_dataset_descriptions", (int) datasetManager.countAllFinalized(), "finalized");
|
||||||
calculateValue("usedTemplates", (int) datasetProfileManager.countAllUsed());
|
calculateValue("argos_managed_dataset_descriptions", (int) datasetManager.countAllPublic(), "published");
|
||||||
calculateValue("usersLoggedIn", userManager.countActiveUsers().intValue());
|
calculateValue("argos_managed_dataset_descriptions", (int) datasetManager.countAllWithDoi(), "doied");
|
||||||
calculateValue("totalUsers", userManager.countAllUsers().intValue());
|
|
||||||
|
calculateValue("argos_dataset_templates", (int) datasetProfileManager.countAlldraft(), "total");
|
||||||
|
calculateValue("argos_dataset_templates", (int) datasetProfileManager.countAllFinalized(), "active");
|
||||||
|
calculateValue("argos_dataset_templates", (int) datasetProfileManager.countAllUsed(), "used");
|
||||||
|
|
||||||
|
calculateValue("argos_users", (int) userManager.countActiveUsers().intValue(), "loggedin");
|
||||||
|
calculateValue("argos_users", (int) userManager.countAllUsers().intValue(), "total");
|
||||||
|
|
||||||
long files = Files.list(Paths.get(this.environment.getProperty("userguide.path"))).count();
|
long files = Files.list(Paths.get(this.environment.getProperty("userguide.path"))).count();
|
||||||
calculateValue("languages", (int) files);
|
calculateValue("argos_languages", (int) files, null);
|
||||||
|
|
||||||
logger.info("Metrics calculation Completed");
|
logger.info("Metrics calculation Completed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue