org.olap4j.OlapException Java Examples

The following examples show how to use org.olap4j.OlapException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MondrianSchemaRetriver.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Gets the name of the column of the measure
 *
 * @param member
 * @return
 * @throws SpagoBIEngineException
 */
public String getMeasureColumn(Member member) throws SpagoBIEngineException {
	String measure = member.getName();
	try {
		if ((member.getDimension().getDimensionType().equals(Type.MEASURE))) {
			for (int i = 0; i < editCube.measures.length; i++) {
				if (editCube.measures[i].name.equals(measure)) {
					return editCube.measures[i].column;
				}
			}
		}
	} catch (OlapException e) {
		logger.error("Error loading the measure linked to the member " + member.getUniqueName(), e);
		throw new SpagoBIEngineException("Error loading the measure linked to the member " + member.getUniqueName(), e);
	}

	return null;
}
 
Example #2
Source File: ServerCube.java    From olaper with MIT License 6 votes vote down vote up
@Override
public Member lookupMember(List<IdentifierSegment> nameParts)
		throws OlapException {
	
	Dimension dim = getDimensions().get(nameParts.get(0).getName());
	if(dim instanceof ServerMeasureDimension){
		String mp = nameParts.get(1).getName();
		for(Measure m : getMeasures()){
			if(m.getName()!=null && m.getName().equals(mp))
				return m;
		}
	}else if(dim instanceof ServerDimension && nameParts.size()>2){
		Hierarchy h = dim.getHierarchies().get(nameParts.get(1).getName());
		if(h!=null){
			Level level = h.getLevels().get(nameParts.get(2).getName());
			if(level!=null){
				if(level.getLevelType()==Type.ALL)
					return h.getDefaultMember();
				else if(nameParts.size()>3)
					return new LevelMember(level, nameParts.get(3).getName(), 0);
			}
		}
		
	}
	return null;
}
 
Example #3
Source File: SqlQuery.java    From olaper with MIT License 6 votes vote down vote up
protected void filterLayer(LevelMemberSet layer) throws OlapException {
	OlapOp func =layer.getFunction();
	if(func!=null){
		SetSubquery sub_query = func.query(mapping, layer);
		if(sub_query!=null){
			
			Condition condition = sub_query.condition();
			if(condition!=null)
				addCondition(condition);

			Condition having_condition = sub_query.havingCondition();
			if(having_condition!=null)
				addHavingCondition(having_condition);
			
		}
			

	}
}
 
Example #4
Source File: ResultAxis.java    From olaper with MIT License 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
public Set<ServerMeasure> collectAllUsedMeasures() throws OlapException{
	
	Set measures = new HashSet();
	for(LevelMemberSet layer : layers){
		if(layer.isMeasure()){
			measures.addAll(layer.getMembers());
		}
		measures.addAll(layer.getFunction().getAllMeasuresUsed());
	}
	
	return measures;
	
}
 
Example #5
Source File: OlapUtils.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * @see org.olap4j.metadata.Member#getChildMembers()
 */

public NamedList<? extends Member> getChildMembers() throws OlapException {
	if (isBaseMember()) {
		return baseMember.getChildMembers();
	}

	return children;
}
 
Example #6
Source File: OlapUtils.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * @see org.olap4j.metadata.Member#getChildMemberCount()
 */

public int getChildMemberCount() throws OlapException {
	if (isBaseMember()) {
		return baseMember.getChildMemberCount();
	}

	return 1;
}
 
Example #7
Source File: Colon.java    From olaper with MIT License 5 votes vote down vote up
@Override
public List<LevelMemberSet> memberSet() throws OlapException {

	List<LevelMemberSet> arg_set_from = createLevelMemberSet(node.getArgList().get(0));
	List<LevelMemberSet> arg_set_to = createLevelMemberSet(node.getArgList().get(1));
	
	member_from = arg_set_from.get(0).getMembers().get(0);
	member_to = arg_set_to.get(0).getMembers().get(0);

	if(member_from.getLevel()!=member_to.getLevel())
		throw new OlapException("Levels mismatch: "+node.toString());
	
	return Collections.singletonList(new LevelMemberSet(member_from.getLevel(), node, this));
}
 
Example #8
Source File: MemberResource.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
@POST
@Path("/properties")
@Produces("text/html; charset=UTF-8")

public String getProperties(@javax.ws.rs.core.Context HttpServletRequest req) throws OlapException, JSONException {

	String name = null;

	try {
		JSONObject paramsObj = RestUtilities.readBodyAsJSONObject(req);

		name = paramsObj.getString("memberUniqueName");
	} catch (Exception e) {
		logger.error("Error reading body", e);
	}

	WhatIfEngineInstance ei = getWhatIfEngineInstance();
	SpagoBIPivotModel model = (SpagoBIPivotModel) ei.getPivotModel();
	NonInternalPropertyCollector np = new NonInternalPropertyCollector();

	JSONArray propsArray = new JSONArray();
	Member m = CubeUtilities.getMember(model.getCube(), name);
	Level l = m.getLevel();
	List<Property> properties = np.getProperties(l);

	for (Property property : properties) {
		JSONObject obj = new JSONObject();
		obj.put("name", property.getName());
		obj.put("value", m.getPropertyFormattedValue(property));
		propsArray.put(obj);
	}
	return propsArray.toString();
}
 
Example #9
Source File: BracesInjector.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override

	public void injectField(Member parentMember, IdentifierNode calculatedNode) {

		try {
			if (contains(rootNode, parentMember) && isMeasureOrHasAnyChildren(parentMember)) {
				rootNode.getArgList().add(getCFPosition(parentMember.getChildMembers()), getCFNode(calculatedNode));

			}
		} catch (OlapException e) {
			logger.error("Error while injecting cf in braces", e);
			throw new SpagoBIEngineRuntimeException("Error while injecting cf in braces", e);
		}

	}
 
Example #10
Source File: OlapUtils.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * @see org.olap4j.metadata.Member#setProperty(org.olap4j.metadata.Property,
 *      java.lang.Object)
 */

public void setProperty(Property property, Object value) throws OlapException {
	if (isBaseMember()) {
		baseMember.setProperty(property, value);
	} else {
		throw new UnsupportedOperationException();
	}
}
 
Example #11
Source File: FilterTreeBuilder.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * @return
 */
public Set<NodeFilter> build() {
	Set<NodeFilter> nodes = new TreeSet<NodeFilter>();
	try {
		for (Member member : hierarchy.getRootMembers()) {

			nodes.add(new NodeFilter(member, nodeLimit, treeMembers, visibleMembers, showSiblings));
		}
	} catch (OlapException e) {
		logger.error("Error while creating filter tree", e);
		throw new SpagoBIRuntimeException("Error while creating filter tree", e);
	}

	return nodes;
}
 
Example #12
Source File: OlapUtils.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * @see org.olap4j.metadata.Member#getPropertyValue(org.olap4j.metadata.Property)
 */

public Object getPropertyValue(Property property) throws OlapException {
	if (isBaseMember()) {
		return baseMember.getPropertyValue(property);
	}

	return null;
}
 
Example #13
Source File: SqlConnector.java    From olaper with MIT License 5 votes vote down vote up
public Connection getConnection() throws OlapException{
	try {
		return dataSource.getConnection();
	} catch (SQLException e) {
		throw new OlapException("Fail to get connection", e);
	}		
}
 
Example #14
Source File: SqlMembersQuery.java    From olaper with MIT License 5 votes vote down vote up
@Override
public void process(ResultSet result) throws SQLException, OlapException {
	members = new ArrayList<Member>();
	while(result.next()){
		
		String key = result.getString(ID_ALIAS);
		String name = result.getString(NAME_ALIAS);
		
		members.add(new LevelMember(level, key, name, members.size()));
		
	}
}
 
Example #15
Source File: CubeUtilities.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Member getMember(Cube cube, String memberUniqueName) throws OlapException {
	Hierarchy hierarchy = null;
	NamedList<Hierarchy> hierarchies = cube.getHierarchies();

	for (int i = 0; i < hierarchies.size(); i++) {
		String hName = hierarchies.get(i).getUniqueName();
		if (memberUniqueName.startsWith(hName)) {
			hierarchy = hierarchies.get(i);
			break;
		}
	}

	return getMember(hierarchy.getLevels().get(0).getMembers(), memberUniqueName);
}
 
Example #16
Source File: ServerDatabase.java    From olaper with MIT License 5 votes vote down vote up
@Override
public NamedList<Catalog> getCatalogs() throws OlapException {
	
	NamedList<Catalog> list = MetadataUtils.catalogNamedList(new ArrayList<Catalog>());
    for(CatalogDefinition cdef: definition.catalogs){
    	list.add(new ServerCatalog(this, cdef));
    }

	return list;
}
 
Example #17
Source File: CubeUtilities.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Searches in the cube for the hierarchy
 *
 * @param cube
 *            the cube
 * @param hierarchyUniqueName
 *            the unique name of the hierarchy to search
 * @return
 * @throws OlapException
 */
public static Hierarchy getHierarchy(Cube cube, String hierarchyUniqueName) throws OlapException {
	Hierarchy hierarchy = null;
	NamedList<Hierarchy> hierarchies = cube.getHierarchies();
	for (int i = 0; i < hierarchies.size(); i++) {
		String hName = hierarchies.get(i).getUniqueName();
		if (hName.equals(hierarchyUniqueName)) {
			hierarchy = hierarchies.get(i);
			break;
		}
	}
	return hierarchy;
}
 
Example #18
Source File: ServerDatabase.java    From olaper with MIT License 5 votes vote down vote up
public ServerDatabase(OlapConnection serverConnection, String url,
		Properties info) throws OlapException {
		
	this.serverConnection = serverConnection;
	this.url = url;
	try{
		this.definition = DatabaseDefinition.getDatabase(url);
	}catch(Exception ex){
		throw new OlapException("Failed to connect to "+url+", unable to read datasource due to "+ex.getMessage(), ex);
	}
		
}
 
Example #19
Source File: CrossNavigationManager.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
private static String getMemberPropertyValue(Member member, String propertyName) {
	logger.debug("IN: Member is " + member.getUniqueName() + ", propertyName is " + propertyName);
	String toReturn = null;
	Property property = member.getProperties().get(propertyName);
	if (property != null) {
		try {
			toReturn = member.getPropertyValue(property).toString();
		} catch (OlapException e) {
			logger.error("Error getting the property " + propertyName + " from the cube ", e);
			throw new SpagoBIEngineRuntimeException("Error getting the property " + propertyName + " ", e);
		}
	}
	logger.debug("OUT: returning " + toReturn);
	return toReturn;
}
 
Example #20
Source File: SbiMember.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
public SbiMember(Member member, boolean visible, String description) {

		this.uniqueName = member.getUniqueName();
		this.id = member.getUniqueName();
		this.name = member.getCaption();
		this.text = calculateText(member.getName(), member.getCaption());

		try {
			this.leaf = member.getChildMemberCount() == 0;
		} catch (OlapException e) {
			throw new SpagoBIEngineRuntimeException("Error getting the childs count for the member " + member.getUniqueName(), e);
		}
		this.visible = visible;
		this.qtip = description;
	}
 
Example #21
Source File: Colon.java    From olaper with MIT License 5 votes vote down vote up
@Override
public SetSubquery query(TableMapping mapping, LevelMemberSet layer)
		throws OlapException {
			
	LevelMapping lmap = mapping.getMapping(member_from.getLevel());
	
	return new SetSubquery(lmap.join, lmap.key_column, 
			((LevelMember)member_from).getKey(),
			((LevelMember)member_to).getKey());		
}
 
Example #22
Source File: SbiDimension.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
public SbiDimension(Dimension dimension, int axis, int positionInAxis) {
	super();
	this.name = dimension.getName();
	this.caption = dimension.getCaption();
	this.uniqueName = dimension.getUniqueName();
	this.axis = axis;
	this.hierarchies = new ArrayList<SbiHierarchy>();
	this.positionInAxis = positionInAxis;

	try {
		this.measure = dimension.getDimensionType().equals(Dimension.Type.MEASURE) ? 1 : 0;
	} catch (OlapException e) {
		logger.error("Error setting getting the type of the dimension", e);
	}
}
 
Example #23
Source File: AbstractUpdatingAlgotithmsDataManager.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
public String executeUpdate(Member[] members, double prop, Connection connection, Integer version) throws Exception {
	// list of the coordinates for the members
	List<IMemberCoordinates> memberCordinates = new ArrayList<IMemberCoordinates>();

	// init the query with the update set statement
	StringBuffer query = new StringBuffer();

	// gets the measures and the coordinates of the dimension members
	for (int i = 0; i < members.length; i++) {
		Member aMember = members[i];

		try {
			if (!(aMember.getDimension().getDimensionType().equals(Type.MEASURE))) {
				memberCordinates.add(retriver.getMemberCordinates(aMember));
			} else {
				buildUpdate(query, aMember, prop);
			}
		} catch (OlapException e) {
			logger.error("Error loading the type of the dimension of the member " + aMember.getUniqueName(), e);
			throw new SpagoBIEngineException("Error loading the type of the dimension of the member " + aMember.getUniqueName(), e);
		}
	}

	String whereClause = buildFromAndWhereClauseForCell(members, version, useInClause);
	query.append(whereClause);

	String queryString = query.toString();

	SqlUpdateStatement updateStatement = new SqlUpdateStatement(queryString);
	updateStatement.executeStatement(connection);

	return queryString.toString();

}
 
Example #24
Source File: ServerDimension.java    From olaper with MIT License 5 votes vote down vote up
private void readHierarchies() throws OlapException {
	
	hierarchies = MetadataUtils.metadataNamedList(new ArrayList<Hierarchy>());  
	
	Map<String, AttributeDefinition> attributeMap = new HashMap<String, AttributeDefinition>();
	
    if(definition.attributes!=null)        
    for(AttributeDefinition cdef: definition.attributes){
    	attributeMap.put(cdef.name, cdef);
    	if(cdef.auto_hierarchy){
    		hierarchies.add(new ServerHierarchy(this, cdef,  Collections.singletonList((NamedElement)cdef)));
    	}
    }
    
    if(definition.hierarchies!=null)
    for(HierarchyDefinition hdef : definition.hierarchies){
    	
    	List<NamedElement> levelDefs = new ArrayList<NamedElement>();
    	for(String level : hdef.levels){	
    		AttributeDefinition attr_def = attributeMap.get(level);
    		if(attr_def==null)
    			throw new OlapException("Fail to find attribute "+level+" used in dimension "+ getName());
    		levelDefs.add(attr_def);
    	}
    	
    	hierarchies.add(new ServerHierarchy(this, hdef, levelDefs));
    }
}
 
Example #25
Source File: OlapFunction.java    From olaper with MIT License 5 votes vote down vote up
@Override
public Collection<ServerMeasure> getAllMeasuresUsed() throws OlapException {
	if(node instanceof CallNode){
		Set<ServerMeasure> result = new HashSet<ServerMeasure>();
		for(IdentifierNode inode : ParseUtils.getAllIdentifiers((CallNode) node)){
			Member m = cube.lookupMember(inode.getSegmentList());
			if(m instanceof ServerMeasure)
				result.add((ServerMeasure) m);
		}
		return result;
	}else
		return Collections.emptyList();
}
 
Example #26
Source File: WhatIfHTMLRendereCallback.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
private void initializeInternal(TableRenderContext context) {
	if (!this.initialized) {
		this.measureOnRows = true;
		this.initialized = true;
		this.positionMeasureMap = new HashMap<Integer, String>();

		// check if the measures are in the rows or in the columns
		List<Member> columnMembers = null;
		Position p = context.getColumnPosition();
		if (p != null) {
			columnMembers = p.getMembers();
		}

		try {
			if (columnMembers != null) {
				for (int i = 0; i < columnMembers.size(); i++) {
					Member member = columnMembers.get(i);
					if (member.getDimension().getDimensionType().equals(Dimension.Type.MEASURE)) {
						this.measureOnRows = false;
					}
				}
			}
		} catch (OlapException e) {
			throw new SpagoBIEngineRuntimeException("Erro getting the measure of a rendered cell ", e);
		}
	}
}
 
Example #27
Source File: BottomCount.java    From olaper with MIT License 5 votes vote down vote up
@Override
public SetSubquery query(TableMapping mapping, LevelMemberSet layer)
		throws OlapException {
	SetSubquery ss = super.query(mapping, layer);
	layer.getSorter().setDirectionString("ASC");
	return ss;
}
 
Example #28
Source File: OlapUtils.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * @param member
 * @return
 */
public static boolean isVisible(Member member) {
	try {
		if (member.getDimension().getDimensionType() == Type.MEASURE) {
			return member.isVisible();
		}
	} catch (OlapException e) {
		throw new PivotException(e);
	}

	return true;
}
 
Example #29
Source File: LevelMember.java    From olaper with MIT License 4 votes vote down vote up
@Override
public void setProperty(Property property, Object value)
		throws OlapException {
}
 
Example #30
Source File: Olap4jXmlaQueryExecuter.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected void handleCellErrors(Cell currentCell) throws JRException
{
	log.error(currentCell.getValue());
	
	throw new JRException((OlapException) currentCell.getValue());
}