Package util
Class Queries
java.lang.Object
util.Queries
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.bson.DocumentbuildBulkWriteRequest(String projectID, String evaluationDate, String relation, Boolean metrics, String sourceID, String targetID, double value, String sourceCategory, double weight, String targetValue) Build a BulkWriteRequest to create or update documents in the Relations collection.static ArrayListgetArrayListFromMap(Map<String, Object> map, String k) static ArrayListGet the currently existing collections in the database.static List<org.bson.Document>getFactorMetricsRelations(String projectId, String evaluationDate) Get the existing relations' (Metric -> Factor) documents in a provided date.static FloatgetFloatFromMap(Map<String, Object> map, String k) static Floatstatic IntegergetIntFromMap(Map<String, Object> map, String k) static Integerstatic List<org.bson.Document>getLatest(String projectId, Constants.QMLevel QMLevel) Get the latest evaluations of the entities in a certain QMLevel.static List<org.bson.Document>getLatest(Constants.QMLevel QMLevel, String projectId, String parent) Get the latest evaluations of the entities in a certain QMLevel.static List<org.bson.Document>getLatestElement(String projectId, Constants.QMLevel QMLevel, String elementId) Get the latest evaluation of a specific entity.static List<org.bson.Document>getLatestRelationsDate(String projectId) Get the latest relations (the last evaluation of each existing relation).static List<org.bson.Document>getRanged(Constants.QMLevel QMLevel, String projectId, String parent, LocalDate dateFrom, LocalDate dateTo) Get the evaluations that belong to a specified time range, for a certain QMLevel.static List<org.bson.Document>getRanged(Constants.QMLevel QMLevel, String projectId, LocalDate dateFrom, LocalDate dateTo) Get the evaluations that belong to a specified time range, for a certain QMLevel.static List<org.bson.Document>getRangedElement(String projectId, Constants.QMLevel QMLevel, String elementId, LocalDate from, LocalDate to) Get the evaluations that belong to a specified time range, for a specific entity.static List<org.bson.Document>getRelations(LocalDate dateFrom, LocalDate dateTo, String projectId) Get the relations that belong to a specified time range.static StringgetStringFromMap(Map<String, Object> map, String k) static Stringstatic Stringstatic StringgetStringFromObjectOrDefault(Object o, String def) static Stringstatic booleanprepareQFIndex(String projectID) Create the Factors' index, if it does not exist already.static booleanprepareSIIndex(String projectID) Create the Strategic Indicators' index, if it does not exist already.static doublesafeGetFromDoubleArray(double[] array, int index) static StringsafeGetFromStringArray(String[] array, int index) static booleansetFactorSIRelationIndex(String projectID, String[] factorID, double[] weight, double[] sourceValue, String[] sourceCategories, String strategicIndicatorID, LocalDate evaluationDate, String targetValue) Create or update the relations between Factors and Strategic Indicators.static com.mongodb.client.result.UpdateResultFunction that updates the factors' index with the information of the strategic indicators using a concrete factor evaluation.static com.mongodb.client.result.UpdateResultsetFactorValue(Constants.QMLevel QMLevel, String hardID, String projectId, String factorID, String factorName, String factorDescription, LocalDate evaluationDate, Float value, String info, EstimationEvaluationDTO estimation, List<String> missingMetrics, long datesMismatch, List<String> indicators) Update the information of an existing Factor.static booleansetMetricQFRelationIndex(String projectID, String[] metricID, double[] weight, double[] sourceValue, String[] sourceCategories, String qualityFactorID, LocalDate evaluationDate, String targetValue) Create or update the relations between Metrics and Factors.static com.mongodb.client.result.UpdateResultFunction that updates the metrics' index with the information of the quality factor using a concrete metric evaluation.static com.mongodb.client.result.UpdateResultsetStrategicIndicatorValue(Constants.QMLevel QMLevel, String hardID, String projectId, String strategicIndicatorID, String strategicIndicatorName, String strategicIndicatorDescription, LocalDate evaluationDate, Float value, String info, EstimationEvaluationDTO estimation, List<String> missingFactors, long datesMismatch) Update the information of an existing Strategic Indicator.
-
Constructor Details
-
Queries
public Queries()
-
-
Method Details
-
getStringFromMap
-
getArrayListFromMap
-
getIntFromMap
-
getFloatFromMap
-
getStringFromObject
-
getArrayListFromObject
-
getIntFromObject
-
getFloatFromObject
-
safeGetFromStringArray
-
safeGetFromDoubleArray
public static double safeGetFromDoubleArray(double[] array, int index) -
getStringFromMapOrDefault
-
getStringFromObjectOrDefault
-
getStringFromStringMapOrDefault
-
getLatest
public static List<org.bson.Document> getLatest(Constants.QMLevel QMLevel, String projectId, String parent) Get the latest evaluations of the entities in a certain QMLevel.- Parameters:
QMLevel- The QMLevel (metrics, factors or strategic_indicators).projectId- The ID of the project.parent- The parent of the entities to retrieve (if any).- Returns:
- A Document list containing the latest evaluations, one evaluation for each entity.
-
getLatest
Get the latest evaluations of the entities in a certain QMLevel.- Parameters:
QMLevel- The QMLevel (metrics, factors or strategic_indicators).projectId- The ID of the project.- Returns:
- A Document list containing the latest evaluations, one evaluation for each entity.
-
getLatestElement
public static List<org.bson.Document> getLatestElement(String projectId, Constants.QMLevel QMLevel, String elementId) Get the latest evaluation of a specific entity.- Parameters:
QMLevel- The QMLevel (metrics, factors or strategic_indicators).projectId- The ID of the project.elementId- The ID of the entity to get the evaluation from.- Returns:
- A Document list containing the latest evaluation of said entity.
-
getRanged
public static List<org.bson.Document> getRanged(Constants.QMLevel QMLevel, String projectId, String parent, LocalDate dateFrom, LocalDate dateTo) Get the evaluations that belong to a specified time range, for a certain QMLevel.- Parameters:
QMLevel- The QMLevel (metrics, factors or strategic_indicators).projectId- The ID of the project.parent- The ID of the parent the entity has to be associated with.dateFrom- The starting date of the filtering time range.dateTo- The ending date of the filtering time range.- Returns:
- The Document list containing the filtered evaluations.
-
getRanged
public static List<org.bson.Document> getRanged(Constants.QMLevel QMLevel, String projectId, LocalDate dateFrom, LocalDate dateTo) Get the evaluations that belong to a specified time range, for a certain QMLevel.- Parameters:
QMLevel- The QMLevel (metrics, factors or strategic_indicators).projectId- The ID of the project.dateFrom- The starting date of the filtering time range.dateTo- The ending date of the filtering time range.- Returns:
- The Document list containing the filtered evaluations.
-
getRangedElement
public static List<org.bson.Document> getRangedElement(String projectId, Constants.QMLevel QMLevel, String elementId, LocalDate from, LocalDate to) Get the evaluations that belong to a specified time range, for a specific entity.- Parameters:
QMLevel- The QMLevel (metrics, factors or strategic_indicators).projectId- The ID of the project.elementId- The ID of the entity we want to retrieve the evaluations from.from- The starting date of the filtering time range.to- The ending date of the filtering time range.- Returns:
- The Document list containing the filtered evaluations.
-
getRelations
public static List<org.bson.Document> getRelations(LocalDate dateFrom, LocalDate dateTo, String projectId) Get the relations that belong to a specified time range.- Parameters:
projectId- The ID of the project.dateFrom- The starting date of the filtering time range.dateTo- The ending date of the filtering time range.- Returns:
- The Document list containing the filtered relations.
-
getLatestRelationsDate
Get the latest relations (the last evaluation of each existing relation).- Parameters:
projectId- The ID of the project.- Returns:
- The Document list containing the latest relations.
-
setStrategicIndicatorValue
public static com.mongodb.client.result.UpdateResult setStrategicIndicatorValue(Constants.QMLevel QMLevel, String hardID, String projectId, String strategicIndicatorID, String strategicIndicatorName, String strategicIndicatorDescription, LocalDate evaluationDate, Float value, String info, EstimationEvaluationDTO estimation, List<String> missingFactors, long datesMismatch) Update the information of an existing Strategic Indicator.- Parameters:
QMLevel- The QMLevel of the entity, which in this case is Strategic Indicators.
-
setFactorValue
public static com.mongodb.client.result.UpdateResult setFactorValue(Constants.QMLevel QMLevel, String hardID, String projectId, String factorID, String factorName, String factorDescription, LocalDate evaluationDate, Float value, String info, EstimationEvaluationDTO estimation, List<String> missingMetrics, long datesMismatch, List<String> indicators) Update the information of an existing Factor.- Parameters:
QMLevel- The QMLevel of the entity, which in this case is Factors.
-
setFactorStrategicIndicatorRelation
public static com.mongodb.client.result.UpdateResult setFactorStrategicIndicatorRelation(FactorEvaluationDTO factor) Function that updates the factors' index with the information of the strategic indicators using a concrete factor evaluation. These entries already exist in the factors' index.- Parameters:
factor- The FactorEvaluationDTO that contains the Strategic Indicators associated to that factor.
-
setMetricQualityFactorRelation
public static com.mongodb.client.result.UpdateResult setMetricQualityFactorRelation(MetricEvaluationDTO metric) Function that updates the metrics' index with the information of the quality factor using a concrete metric evaluation. These entries already exist in the metrics' index.- Parameters:
metric- The MetricEvaluationDTO that contains the Factors associated to that metric.
-
setFactorSIRelationIndex
public static boolean setFactorSIRelationIndex(String projectID, String[] factorID, double[] weight, double[] sourceValue, String[] sourceCategories, String strategicIndicatorID, LocalDate evaluationDate, String targetValue) Create or update the relations between Factors and Strategic Indicators.- Returns:
- A boolean indicating if the operation could be performed correctly.
-
setMetricQFRelationIndex
public static boolean setMetricQFRelationIndex(String projectID, String[] metricID, double[] weight, double[] sourceValue, String[] sourceCategories, String qualityFactorID, LocalDate evaluationDate, String targetValue) Create or update the relations between Metrics and Factors.- Returns:
- A boolean indicating if the operation could be performed correctly.
-
buildBulkWriteRequest
public static org.bson.Document buildBulkWriteRequest(String projectID, String evaluationDate, String relation, Boolean metrics, String sourceID, String targetID, double value, String sourceCategory, double weight, String targetValue) Build a BulkWriteRequest to create or update documents in the Relations collection.- Returns:
- The created BulkWriteRequest as a Document.
-
getCollections
Get the currently existing collections in the database.- Returns:
- A list containing the collections' names.
-
getFactorMetricsRelations
public static List<org.bson.Document> getFactorMetricsRelations(String projectId, String evaluationDate) Get the existing relations' (Metric -> Factor) documents in a provided date.- Parameters:
projectId- The ID of the project.evaluationDate- The date we want the relations to belong to.- Returns:
- A list of Documents which contains the filtered relations.
-
prepareSIIndex
Create the Strategic Indicators' index, if it does not exist already.- Parameters:
projectID- The ID of the project.- Returns:
- A boolean indicating if the index was created correctly.
-
prepareQFIndex
Create the Factors' index, if it does not exist already.- Parameters:
projectID- The ID of the project.- Returns:
- A boolean indicating if the index was created correctly.
-