Skip to content

Commit

Permalink
MONDRIAN: Fixed <Member>.Properties("CAPTION")
Browse files Browse the repository at this point in the history
Bugid:1694994

[git-p4: depot-paths = "//open/mondrian/": change = 9066]
  • Loading branch information
thiyagu committed Apr 9, 2007
1 parent 6bd0d59 commit f4daf26
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main/mondrian/olap/Property.java
Expand Up @@ -53,6 +53,9 @@
* </ul>
*/
public class Property extends EnumeratedValues.BasicValue {

private static final String CAPTION_STRING = "CAPTION";

public enum Datatype {
TYPE_STRING,
TYPE_NUMERIC,
Expand Down Expand Up @@ -528,12 +531,27 @@ public static Property lookup(int ordinal) {
* @return Property with given name, or null if not found.
*/
public static Property lookup(String name, boolean matchCase) {
name = mapIntrinsicPropertyCaption(name, matchCase);
if (!matchCase) {
return enumeration.getValueIgnoreCase(name, false);
} else {
return enumeration.getValue(name, false);
}
}

private static String mapIntrinsicPropertyCaption(String name,
boolean matchCase) {
if (matchCase) {
if (name.equals(CAPTION_STRING)) {
return MEMBER_CAPTION.name;
}
} else {
if (name.equalsIgnoreCase(CAPTION_STRING)) {
return MEMBER_CAPTION.name;
}
}
return name;
}
}

// End Property.java
21 changes: 21 additions & 0 deletions testsrc/main/mondrian/test/BasicQueryTest.java
Expand Up @@ -5546,6 +5546,27 @@ public void testQueryIterationLimit()
executeQuery(queryString);
}

public void testGetCaptionUsingMemberDotCaption() {
assertQueryReturns("SELECT Filter(Store.allmembers, " +
"[store].currentMember.caption = \"USA\") on 0 FROM SALES",
fold("Axis #0:\n" +
"{}\n" +
"Axis #1:\n" +
"{[Store].[All Stores].[USA]}\n" +
"Row #0: 266,773\n"));
}

public void testGetCaptionUsingMemberDotPropertiesCaption() {
assertQueryReturns("SELECT Filter(Store.allmembers, " +
"[store].currentMember.properties(\"caption\") = \"USA\") " +
"on 0 FROM SALES",
fold("Axis #0:\n" +
"{}\n" +
"Axis #1:\n" +
"{[Store].[All Stores].[USA]}\n" +
"Row #0: 266,773\n"));
}

/**
* A simple user-defined function which adds one to its argument, but
* sleeps 1 ms before doing so.
Expand Down
3 changes: 3 additions & 0 deletions testsrc/main/mondrian/test/PropertiesTest.java
Expand Up @@ -80,6 +80,9 @@ public void testMandatoryMemberProperties() {
stringPropValue = (String)member.getPropertyValue("MEMBER_CAPTION");
assertEquals(member.getCaption(), stringPropValue);

stringPropValue = (String)member.getPropertyValue("CAPTION");
assertEquals(member.getCaption(), stringPropValue);

intPropValue = (Integer)member.getPropertyValue("MEMBER_ORDINAL");
assertEquals(new Integer(member.getOrdinal()), intPropValue);

Expand Down

0 comments on commit f4daf26

Please sign in to comment.