Package org.saiku.service.util.exception

Examples of org.saiku.service.util.exception.SaikuServiceException


            }
          }
        }
      }
    } catch (Exception e) {
      throw new SaikuServiceException("Cannot remove level" + uniqueLevelName + "from dimension " + dimensionName, e);
    }
    return true;
  }
View Full Code Here


        query.moveDimension(dimension, newAxis);
      } else {
        query.moveDimension(dimension, newAxis, position);
      }
    } catch (Exception e) {
      throw new SaikuServiceException("Cannot move dimension:" + dimensionName + " to axis: " + axisName, e);
    }
  }
View Full Code Here

        for (QueryDimension dim : qaxis.getDimensions()) {
          dimsel.add(ObjectUtil.convertDimensionSelection(dim, query));
        }
      }
    } catch (SaikuOlapException e) {
      throw new SaikuServiceException("Cannot get dimension selections", e);
    }
    return dimsel;
  }
View Full Code Here

        }
      } else {
        throw new SaikuOlapException("Cannot find axis with name:" + axis);
      }
    } catch (SaikuOlapException e) {
      throw new SaikuServiceException("Cannot get dimension selections", e);
    }
  }
View Full Code Here

    try {
      IQuery query = getIQuery(queryName);
      query.clearAxis(axisName);
      return query;
    } catch (SaikuOlapException e) {
      throw new SaikuServiceException("Cannot clear for query: " + queryName + " axis: " + axisName, e);
    }
  }
View Full Code Here

      List<SaikuDimensionSelection> filterSelections = getAxisSelection(queryName, "FILTER");
      SaikuTag t = new SaikuTag(tagName, dimensions, tuples, filterSelections);
      return t;

    } catch (Exception e) {
      throw new SaikuServiceException("Error addTag:" + tagName + " for query: " + queryName, e);
    }
  }
View Full Code Here

  public IQuery zoomIn(String queryName, @Nullable List<List<Integer>> realPositions) {
    try {
      IQuery query = getIQuery(queryName);
      CellSet cs = query.getCellset();
      if (cs == null) {
        throw new SaikuServiceException("Cannot zoom in if last cellset is null");
      }
      if (realPositions == null || realPositions.size() == 0) {
        throw new SaikuServiceException("Cannot zoom in if zoom in position is empty");
      }

      Map<Dimension, Set<Member>> memberSelection = new HashMap<Dimension, Set<Member>>();
      for (List<Integer> position : realPositions) {
        for (int k = 0; k < position.size(); k++) {
          Position p = cs.getAxes().get(k).getPositions().get(position.get(k));
          List<Member> members = p.getMembers();
          for (Member m : members) {
            Dimension d = m.getDimension();
            if (!memberSelection.containsKey(d)) {
              Set<Member> mset = new HashSet<Member>();
              memberSelection.put(d, mset);
            }
            memberSelection.get(d).add(m);
          }
        }
      }

      for (Dimension d : memberSelection.keySet()) {
        QueryDimension a = query.getDimension(d.getName());
        a.clearInclusions();
        for (Member m : memberSelection.get(d)) {
          a.include(m);
        }
      }

      return query;
    } catch (Exception e) {
      throw new SaikuServiceException("Error zoom in on query: " + queryName, e);
    }

  }
View Full Code Here


      IQuery query = getIQuery(queryName);
      CellSet cs = query.getCellset();
      if (cs == null) {
        throw new SaikuServiceException("Cannot get filter of result if last cellset is null");
      }

      CellDataSet result = OlapResultSetUtil.cellSet2Matrix(cs, query.getFormatter());

      List<SimpleCubeElement> members = new ArrayList<SimpleCubeElement>();
      Set<MetadataElement> mset = new HashSet<MetadataElement>();

      Cube cube = query.getCube();
      Hierarchy h = cube.getHierarchies().get(hierarchyName);
      if (h == null) {
        throw new Exception("Cannot find hierarchy in cube " + cube.getName() + " with name " + hierarchyName);
      }
      Dimension d = h.getDimension();
      Level l = h.getLevels().get(levelName);
      if (l == null) {
        throw new Exception("Cannot find level in hierarchy " + h.getName() + " with name " + levelName);
      }
      SimpleCubeElement hierarchy = new SimpleCubeElement(h.getName(), h.getUniqueName(), h.getCaption());
      SimpleCubeElement dimension = new SimpleCubeElement(d.getName(), d.getUniqueName(), d.getCaption());

      Long start = new Date().getTime();

      // try headers first
      AbstractBaseCell[][] headers = result.getCellSetHeaders();
      if (headers != null && headers.length > 0 && headers[0].length > 0) {
        for (AbstractBaseCell[] header : headers) {
          for (int k = 0; k < headers[0].length; k++) {
            if (header[k] == null) {
              continue;
            }
            MemberCell mc = (MemberCell) header[k];
            if (mc.getUniqueName() != null) {
              if (mc.getHierarchy().equals(hierarchy.getUniqueName()) && mc.getLevel().equals(l.getUniqueName())) {
                String mu = mc.getUniqueName();
                List<IdentifierSegment> memberList = IdentifierNode.parseIdentifier(mu).getSegmentList();
                Member m = cube.lookupMember(memberList);
                mset.add(m);
              }
            }
          }
        }
      }
      Long header = new Date().getTime();

      if (mset.size() == 0) {
        // try body next
        AbstractBaseCell[][] body = result.getCellSetBody();
        if (body != null && body.length > 0 && body[0].length > 0) {
          for (AbstractBaseCell[] aBody : body) {
            for (int k = 0; k < body[0].length; k++) {
              if (aBody[k] == null) {
                continue;
              }
              AbstractBaseCell ac = aBody[k];
              if (ac instanceof DataCell) {
                break;
              }
              if (ac instanceof MemberCell) {
                MemberCell mc = (MemberCell) aBody[k];
                if (mc.getUniqueName() != null) {
                  if (mc.getHierarchy().equals(hierarchy.getUniqueName()) && mc.getLevel().equals(l.getUniqueName())) {
                    String mu = mc.getUniqueName();
                    List<IdentifierSegment> memberList = IdentifierNode.parseIdentifier(mu).getSegmentList();
                    Member m = cube.lookupMember(memberList);
                    mset.add(m);
                  }
                }
              }
            }
          }
        }
      }
      Long body = new Date().getTime();


      // fallback - check inclusions (probably they are only on filter)
      if (mset.size() == 0) {
//List<CellSetAxis> axes = new ArrayList<CellSetAxis>();
//axes.addAll(cs.getAxes());
//axes.add(cs.getFilterAxis());
//for (CellSetAxis axis : axes) {
//int posIndex = 0;
//for (Hierarchy he : axis.getAxisMetaData().getHierarchies()) {
//if (he.getName().equals(hierarchyName)) {
//if (hierarchy == null) {
//hierarchy = new SimpleCubeElement(he.getName(),
// he.getUniqueName(),  he.getCaption());
//dimension = new SimpleCubeElement(d.getName(),
// d.getUniqueName(), d.getCaption());
//}
//if (he.getLevels().size() == 1) {
//break;
//}
//
//for (Position pos : axis.getPositions()) {
//Member m = pos.getMembers().get(posIndex);
//if (m.getLevel().getName().equals(levelName)) {
//mset.add(m);
//}
//}
//break;
//}
//posIndex++;
//}
//}
        if (mset.size() == 0) {
          QueryDimension qd = query.getDimension(dimensionName);
          if (qd != null && qd.getAxis().getLocation() != null) {
            for (Selection sel : qd.getInclusions()) {
              if (sel.getRootElement() instanceof Member) {
                Member m = (Member) sel.getRootElement();
                if (m.getLevel().getName().equals(levelName)) {
                  mset.add(m);
                }
              }
            }
          }
        }
      }
      Long end = new Date().getTime();

//System.out.println("Header Time: " + new Double(header - start).intValue());
//System.out.println("Body   Time: " + new Double(body - header).intValue());
//System.out.println("Rest   Time: " + new Double(end- body).intValue());
      members = ObjectUtil.convert2Simple(mset);
      Collections.sort(members, new SaikuUniqueNameComparator());
      LOG.debug("Create Filters: Found members in the result or query: " + members.size());

      return new SaikuFilter(filtername, null, dimension, hierarchy, members);
    } catch (Exception e) {
      throw new SaikuServiceException("Error getFilter:" + filtername + " for query: " + queryName, e);
    }
  }
View Full Code Here

  private IQuery getIQuery(String queryName) {
    if (queries.containsKey(queryName)) {
      return queries.get(queryName);
    }
    throw new SaikuServiceException("No query found using name: " + queryName);
  }
View Full Code Here

  @NotNull
  public List<SaikuConnection> getAllConnections() throws SaikuServiceException {
    try {
      return metaExplorer.getAllConnections();
    } catch (SaikuOlapException e) {
      throw new SaikuServiceException("Cannot retrieve all connections", e);
    }
  }
View Full Code Here

TOP

Related Classes of org.saiku.service.util.exception.SaikuServiceException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.