Package util

Class Queries

java.lang.Object
util.Queries

public class Queries extends Object
  • Constructor Details

    • Queries

      public Queries()
  • Method Details

    • getStringFromMap

      public static String getStringFromMap(Map<String,Object> map, String k)
    • getArrayListFromMap

      public static ArrayList getArrayListFromMap(Map<String,Object> map, String k)
    • getIntFromMap

      public static Integer getIntFromMap(Map<String,Object> map, String k)
    • getFloatFromMap

      public static Float getFloatFromMap(Map<String,Object> map, String k)
    • getStringFromObject

      public static String getStringFromObject(Object o)
    • getArrayListFromObject

      public static ArrayList getArrayListFromObject(Object o)
    • getIntFromObject

      public static Integer getIntFromObject(Object o)
    • getFloatFromObject

      public static Float getFloatFromObject(Object o)
    • safeGetFromStringArray

      public static String safeGetFromStringArray(String[] array, int index)
    • safeGetFromDoubleArray

      public static double safeGetFromDoubleArray(double[] array, int index)
    • getStringFromMapOrDefault

      public static String getStringFromMapOrDefault(Map<String,Object> map, String k, String def)
    • getStringFromObjectOrDefault

      public static String getStringFromObjectOrDefault(Object o, String def)
    • getStringFromStringMapOrDefault

      public static String getStringFromStringMapOrDefault(Map<String,String> map, String k, String def)
    • 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

      public static List<org.bson.Document> getLatest(String projectId, Constants.QMLevel QMLevel)
      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

      public static List<org.bson.Document> getLatestRelationsDate(String projectId)
      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

      public static List<String> 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

      public static boolean prepareSIIndex(String projectID)
      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

      public static boolean prepareQFIndex(String projectID)
      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.