Exemplo n.º 1
0
  /** Builds the set of paths between all the couple of vertexes */
  private void buildPaths() {

    logger.debug("IN");

    allGraphPaths = new HashSet<GraphPath<IModelEntity, Relationship>>();
    paths = new HashSet<EntitiesPath>();

    // build all the path between entities
    Iterator<IModelEntity> vertexesIter = entities.iterator();

    // First loop for the source of the path
    while (vertexesIter.hasNext()) {
      IModelEntity startVertex = vertexesIter.next();
      logger.debug("Building the list of path starting from " + startVertex.getName());
      // inner loop for the target of the path
      Iterator<IModelEntity> vertexesInnerIter = entities.iterator();
      while (vertexesInnerIter.hasNext()) {
        IModelEntity endVertex = vertexesInnerIter.next();
        if (!startVertex.equals(endVertex)) {
          EntitiesPath entitiesPath = new EntitiesPath(startVertex, endVertex);
          if (!this.paths.contains(entitiesPath)) {
            logger.debug(
                "Building the list of path between the vertexes ["
                    + startVertex.getName()
                    + ","
                    + endVertex.getName()
                    + "]");
            KShortestPaths<IModelEntity, Relationship> kshortestPath =
                new KShortestPaths<IModelEntity, Relationship>(graph, startVertex, maxPathLength);
            List<GraphPath<IModelEntity, Relationship>> graphPaths =
                kshortestPath.getPaths(endVertex);

            // if there is at least one path between the 2 vertex
            if (graphPaths != null) {
              entitiesPath.setPaths(graphPaths);

              // updating the class variables
              this.paths.add(entitiesPath);
              for (int i = 0; i < graphPaths.size(); i++) {
                GraphPath<IModelEntity, Relationship> path = graphPaths.get(i);
                if (!containsPath(this.allGraphPaths, path)) {
                  this.allGraphPaths.add(path);
                }
              }
            }
          }
        }
      }
    }
    logger.debug("OUT");
  }
Exemplo n.º 2
0
  private IModelField getColumnModelField(Column column, IModelEntity entity) {
    if (column.getSubEntity()
        != null) { // in case it is a subEntity attribute, look for the field inside it

      // In order to recover subentities the new way if DEFAULT_MAX_RECURSION_LEVEL is set to zero
      /*
      	QbeEngineInstance engineInstance = getEngineInstance();
      QbeTemplate template = engineInstance.getTemplate();
      // takes the only datamart's name configured
      String modelName = (String) template.getDatamartNames().get(0);
      IModelStructure md = getDataSource().getModelStructure();
      IModelEntity	subEntity  = md.getEntity(column.getSubEntity()); */

      String entityUName = entity.getUniqueName();
      String subEntityKey =
          entityUName.substring(0, entityUName.lastIndexOf("::"))
              + "::"
              + column.getSubEntity()
              + "("
              + column.getForeignKey()
              + ")";
      IModelEntity subEntity = entity.getSubEntity(subEntityKey);
      if (subEntity == null) {
        throw new SpagoBIEngineServiceException(
            getActionName(),
            "Sub-entity ["
                + column.getSubEntity()
                + "] not found in entity ["
                + entity.getName()
                + "]!");
      }
      entity = subEntity;
    }
    logger.debug(
        "Looking for attribute " + column.getField() + " in entity " + entity.getName() + " ...");
    List<IModelField> fields = entity.getAllFields();
    Iterator<IModelField> it = fields.iterator();
    while (it.hasNext()) {
      IModelField field = it.next();
      if (field.getName().equals(column.getField())) {
        return field;
      }
    }
    return null;
  }
Exemplo n.º 3
0
 /**
  * Get all the paths passing from the passed vertex
  *
  * @param vertex
  * @return
  */
 private Set<GraphPath<IModelEntity, Relationship>> getPathsOfAmbigousEntities(
     IModelEntity vertex) {
   logger.debug("IN");
   logger.debug("Getting all the paths passing through the vertex " + vertex.getName());
   Iterator<GraphPath<IModelEntity, Relationship>> iter = getAllGraphPaths().iterator();
   Set<GraphPath<IModelEntity, Relationship>> toReturn =
       new HashSet<GraphPath<IModelEntity, Relationship>>();
   while (iter.hasNext()) {
     GraphPath<IModelEntity, Relationship> path = iter.next();
     if (containsVertex(path, vertex)) {
       toReturn.add(path);
     }
   }
   logger.debug("The path passing through the vertex are " + toReturn.size());
   logger.debug("OUT");
   return toReturn;
 }