Java Code Examples for org.olap4j.metadata.Member#getLevel()

The following examples show how to use org.olap4j.metadata.Member#getLevel() . 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: CrossNavigationManager.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
private static String getLevelValue(Member member, String levelName) {
	logger.debug("IN: Member is " + member.getUniqueName() + ", levelName is " + levelName);
	String toReturn = null;
	Level level = member.getLevel();
	logger.debug("Member level is " + level.getUniqueName());
	if (level.getUniqueName().equals(levelName)) {
		level.getName();
		logger.debug("Member level matches input level name " + levelName + "!!");
		toReturn = member.getName();
	} else {
		logger.debug("Member level does NOT match input level name " + levelName + "!!");
		// look for parent member at parent level
		Member parent = member.getParentMember();
		if (parent == null) {
			return null;
		} else {
			return getLevelValue(parent, levelName);
		}
	}
	logger.debug("OUT: returning " + toReturn);
	return toReturn;
}
 
Example 2
Source File: SortedMemberAddingStrategy.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public int compare( final Member o1, final Member o2 ) {
  Dimension d1 = o1.getLevel().getDimension();
  Dimension d2 = o2.getLevel().getDimension();
  int dimOrder = Integer.compare( getDimensionPositionOnAxis( d1 ), getDimensionPositionOnAxis( d2 ) );
  if ( dimOrder != 0 ) {
    return dimOrder;
  }

  Hierarchy h1 = o1.getHierarchy();
  Hierarchy h2 = o2.getHierarchy();
  int hierarchyOrder = h1.getName().compareTo( h2.getName() );
  if ( hierarchyOrder != 0 ) {
    return hierarchyOrder;
  }

  Level level1 = o1.getLevel();
  Level level2 = o2.getLevel();
  int levelOrder = Integer.compare( level1.getDepth(), level2.getDepth() );
  if ( levelOrder != 0 ) {
    return levelOrder;
  }
  return o1.getLevel().getUniqueName().compareTo( o2.getLevel().getUniqueName() );
}
 
Example 3
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 4
Source File: CrossNavigationManager.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
public static String buildClickableUrl(Member member, List<TargetClickable> targetsClickable) {
	logger.debug("IN");
	Level level = member.getLevel();
	String url = new String();
	for (TargetClickable tc : targetsClickable) {
		if (tc.getUniqueName().equalsIgnoreCase(level.getUniqueName())) {
			StringBuffer targetDocumentParameters = new StringBuffer();
			for (Map.Entry<String, String> entry : tc.getParametersList().entrySet()) {
				String key = entry.getKey();
				String value = entry.getValue();
				targetDocumentParameters.append(key);
				targetDocumentParameters.append(":");
				targetDocumentParameters.append(value);
				targetDocumentParameters.append(",");
			}

			if (targetDocumentParameters.length() > 0) {
				int index = targetDocumentParameters.lastIndexOf(",");
				targetDocumentParameters.setLength(index);
			}

			String documentParametersUnformatted = (targetDocumentParameters.toString());

			logger.debug("Composing cross nav url. Parameters unformatted = " + documentParametersUnformatted);
			String newName = getLevelValue(member, tc.getUniqueName());
			newName = "'" + StringEscapeUtils.escapeJavaScript(newName) + "'";
			Object[] args = new Object[] { newName };
			url = MessageFormat.format(documentParametersUnformatted, args);
			logger.debug("Composing cross nav url. Parameters formatted = " + url);

			url = "parent.execExternalCrossNavigation({" + (url) + "});";

			return url;
		} else {
			url = null;
		}
	}
	return url;
}
 
Example 5
Source File: MondrianSchemaRetriver.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * For each level starting from the root to the Get the map between the
 * hierarchy of the member( root member, child, granchild, .... member) and
 * the level. We need this information because we want to know table and
 * column linked to the members
 *
 * @param member
 * @param mondrianHierarchy
 * @return the map Level-->Member of the level
 */
public Map<TableEntry, Member> getMemberColumnMap(Member member, MondrianDef.Hierarchy mondrianHierarchy) {

	logger.debug("IN");

	Map<TableEntry, Member> mapTableEntryValue = new HashMap<TableEntry, Member>();
	// int memberDepth = member.getDepth();
	Level memberLevel = member.getLevel();

	// get all the levels starting from the root to the one that contains
	// the passed member
	List<MondrianDef.Level> memberValues = getLevels(memberLevel, mondrianHierarchy);

	// Create a Map that links the member with the level that contains it
	Member aMember = member;
	for (int i = memberValues.size() - 1; i >= 0; i--) {
		MondrianDef.Level aLevel = memberValues.get(i);
		String table = aLevel.table;
		if (table == null) {
			table = getTableName(mondrianHierarchy);
		}
		mapTableEntryValue.put(new TableEntry(aLevel.column, table), aMember);
		aMember = aMember.getParentMember();
	}

	logger.debug("OUT");
	return mapTableEntryValue;
}
 
Example 6
Source File: OlapUtils.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * @param member
 * @param cube
 */
RaggedMemberWrapper(Member member, Cube cube) {
	this.baseMember = member;
	this.level = member.getLevel();
	this.ancestors = new LinkedList<Member>();

	List<IdentifierSegment> segments = Collections.unmodifiableList(IdentifierParser.parseIdentifier(member.getUniqueName()));
	List<IdentifierSegment> resolvableSegments = new LinkedList<IdentifierSegment>();

	int i = 0;
	int count = segments.size();

	List<Level> levels = member.getHierarchy().getLevels();

	for (IdentifierSegment segment : segments) {
		resolvableSegments.add(segment);

		Level currentLevel = levels.get(i);

		Member ancestor;

		try {
			ancestor = cube.lookupMember(resolvableSegments);

			if (ancestor == null && i == 0) {
				ancestor = member.getHierarchy().getDefaultMember();
			}
		} catch (OlapException e) {
			throw new PivotException(e);
		}

		if (i == 0 && ancestor == null) {
			throw new PivotException("Can't determine top level parent for the ragged member : " + member.getUniqueName());
		}

		i++;

		if (i >= count) {
			this.uniqueName = getUniqueName(resolvableSegments);
		} else if (ancestor == null) {
			String currentName = getUniqueName(segments.subList(0, i));

			ancestor = new RaggedMemberWrapper(currentName, currentLevel, new LinkedList<Member>(ancestors), baseMember, topMember);
			ancestors.add(0, ancestor);

			resolvableSegments.remove(segment);
		} else {
			ancestors.add(0, ancestor);

			this.topMember = ancestor;
		}
	}

	if (topMember == null) {
		throw new IllegalArgumentException("Unable to find a non-ragged ancestor of the specified member : " + member);
	}
}
 
Example 7
Source File: LevelMemberSet.java    From olaper with MIT License 4 votes vote down vote up
public LevelMemberSet(Member member, ParseTreeNode node, OlapOp function) {		
	this.level = member.getLevel();
	this.node = node;
	this.function = function;
	members.add(member);		
}