Class ViewService
java.lang.Object
io.skipcheck.tm1.client.service.cube.ViewService
Views: a cube's public and private views (
ViewScope), native
(NativeView: subsets on columns, rows and titles) or MDX (MDXView).
They're read as View, so each comes back as its own type.
A native view's subsets are in complex properties, reached by expanding through the
tm1.NativeView type: list with tm1.NativeView/Columns/Subset,
or getNative(String, ViewScope, String, ODataQuery), which reads one view through the type. On TM1 11.8.35 the
type-cast expand works on a list holding MDX views too; an older server was reported to
fail it, and getNative doesn't depend on it.
Create a native view: each axis binds a subset, and every dimension of the cube has to be on one.
// Months across, regions down, and the cube's other dimensions as titles: every
// dimension of the cube must be on an axis. Each axis binds an existing subset.
ODataPath dimensions = ODataPath.of("Dimensions");
ODataPath months = dimensions.key("Month").nav("Hierarchies").key("Month").nav("Subsets").key("Quarters");
ODataPath regions = dimensions.key("Region").nav("Hierarchies").key("Region").nav("Subsets").key("Leaves");
ODataPath versions = dimensions.key("Version").nav("Hierarchies").key("Version");
ODataPath measures = dimensions.key("Measure").nav("Hierarchies").key("Measure");
return tm1.views()
.create("Sales", ViewScope.PUBLIC,
NativeViewPatch.builder()
.name("Revenue by Region")
.columns(List.of(ViewAxisSelectionPatch.builder().bindSubset(months).build()))
.rows(List.of(ViewAxisSelectionPatch.builder().bindSubset(regions).build()))
.titles(List.of(
ViewTitlePatch.builder()
.bindSubset(versions.nav("Subsets").key("All"))
.bindSelected(versions.nav("Elements").key("Actual"))
.build(),
ViewTitlePatch.builder()
.bindSubset(measures.nav("Subsets").key("All"))
.bindSelected(measures.nav("Elements").key("Revenue"))
.build()))
.suppressEmptyRows(true)
.build());
Create an MDX view from its query:
// An MDX view is its query
String mdx = "SELECT {[Month].[Month].[Jan], [Month].[Month].[Feb]} ON 0,"
+ " {TM1FILTERBYLEVEL({TM1SUBSETALL([Region].[Region])}, 0)} ON 1 FROM [Sales]"
+ " WHERE ([Version].[Version].[Actual], [Measure].[Measure].[Revenue])";
return tm1.views()
.create("Sales", ViewScope.PRIVATE, MDXViewPatch.builder().name("My Revenue").mdx(mdx).build());
List a cube's views, telling the kinds apart by type:
// Each view comes back as its own type
return tm1.views().list("Sales", ViewScope.PUBLIC, ODataQuery.none()).map(view -> {
if (view instanceof MDXView mdxView) {
return view.name() + ": " + mdxView.mdx();
}
if (view instanceof NativeView) {
return view.name() + ": native";
}
return view.name() + ": unknown kind";
});
Read the subsets on a native view's axes:
// A native view's axes are complex properties: expand them by path, through the
// view's type
return tm1.views()
.getNative("Sales", ViewScope.PUBLIC, "Revenue by Region",
ODataQuery.none().expand("Columns/Subset").expand("Rows/Subset"))
.flatMapMany(view -> Flux.concat(Flux.fromIterable(view.columns()), Flux.fromIterable(view.rows())))
.map(axis -> axis.subset().uniqueName());
-
Constructor Summary
ConstructorsConstructorDescriptionViewService(Tm1Session session) A service sending its requests throughsession. -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<View> POST Cubes('c')/Views: creates a view; the patch's type says which kind (MDXViewPatch,NativeViewPatch), and a native view's axes bind subsets.reactor.core.publisher.Mono<Cube> cube(String cube, ViewScope scope, String view, ODataQuery query) GET Cubes('c')/Views('v')/Cube.reactor.core.publisher.Mono<Void> DELETE Cubes('c')/Views('v'); its subsets stay.reactor.core.publisher.Mono<View> get(String cube, ViewScope scope, String view, ODataQuery query) GET Cubes('c')/Views('v').reactor.core.publisher.Mono<NativeView> getNative(String cube, ViewScope scope, String view, ODataQuery query) GET Cubes('c')/Views('v')/tm1.NativeView: reads a native view through its type, so its axes can be expanded:Columns/Subset,Rows/Subset,Titles/Subset,Titles/Selected.reactor.core.publisher.Flux<View> list(String cube, ViewScope scope, ODataQuery query) GET Cubes('c')/Views(or the private ones), streamed.reactor.core.publisher.Mono<Void> PATCH Cubes('c')/Views('v'): changes the properties the patch sets, such as an MDX view'sMDX.reactor.core.publisher.Mono<Void> PATCH Cubes('c')/Views('v')withIf-Match.
-
Constructor Details
-
ViewService
A service sending its requests throughsession.- Parameters:
session- the session
-
-
Method Details
-
list
@Tm1Endpoint("Navigation Cube/Views") @Tm1Endpoint("Navigation Cube/PrivateViews") public reactor.core.publisher.Flux<View> list(String cube, ViewScope scope, ODataQuery query) GET Cubes('c')/Views(or the private ones), streamed.- Parameters:
cube- the cube's namescope- which viewsquery- what to select, expand, filter and order; a native view's axes expand through its type, astm1.NativeView/Columns/Subset- Returns:
- the views, each as its own type
-
get
@Tm1Endpoint("Navigation Cube/Views") @Tm1Endpoint("Navigation Cube/PrivateViews") public reactor.core.publisher.Mono<View> get(String cube, ViewScope scope, String view, ODataQuery query) GET Cubes('c')/Views('v').- Parameters:
cube- the cube's namescope- where the view isview- the view's namequery- what to select and expand- Returns:
- the view as its own type, or a
Tm1NotFoundExceptionif there's none
-
getNative
@Tm1Endpoint("Navigation Cube/Views") @Tm1Endpoint("Navigation Cube/PrivateViews") @Tm1Endpoint("Navigation ViewAxisSelection/Subset") @Tm1Endpoint("Navigation ViewTitle/Subset") @Tm1Endpoint("Navigation ViewTitle/Selected") public reactor.core.publisher.Mono<NativeView> getNative(String cube, ViewScope scope, String view, ODataQuery query) GET Cubes('c')/Views('v')/tm1.NativeView: reads a native view through its type, so its axes can be expanded:Columns/Subset,Rows/Subset,Titles/Subset,Titles/Selected. They're complex properties, so TM1 wants paths, not nested options.- Parameters:
cube- the cube's namescope- where the view isview- the view's namequery- what to select and expand- Returns:
- the native view, or an error if it's an MDX view
-
create
@Tm1Endpoint("Navigation Cube/Views") @Tm1Endpoint("Navigation Cube/PrivateViews") public reactor.core.publisher.Mono<View> create(String cube, ViewScope scope, ViewPatch view) POST Cubes('c')/Views: creates a view; the patch's type says which kind (MDXViewPatch,NativeViewPatch), and a native view's axes bind subsets. TM1 (11.8) refuses a native view that leaves any of the cube's dimensions off its columns, rows and titles (400, "All cube dimensions must be placed on an axis").- Parameters:
cube- the cube's namescope- where to create itview- the new view; it needs a name- Returns:
- the view as created
-
update
@Tm1Endpoint("Navigation Cube/Views") @Tm1Endpoint("Navigation Cube/PrivateViews") public reactor.core.publisher.Mono<Void> update(String cube, ViewScope scope, String view, ViewPatch patch) PATCH Cubes('c')/Views('v'): changes the properties the patch sets, such as an MDX view'sMDX.- Parameters:
cube- the cube's namescope- where the view isview- the view's namepatch- the changes, of the view's kind- Returns:
- completes when the view is changed
-
update
@Tm1Endpoint("Navigation Cube/Views") @Tm1Endpoint("Navigation Cube/PrivateViews") public reactor.core.publisher.Mono<Void> update(String cube, ViewScope scope, String view, ViewPatch patch, String etag) PATCH Cubes('c')/Views('v')withIf-Match.- Parameters:
cube- the cube's namescope- where the view isview- the view's namepatch- the changes, of the view's kindetag- the ETag the view was read with- Returns:
- completes when the view is changed, or a
Tm1PreconditionFailedExceptionif it had changed
-
delete
@Tm1Endpoint("Navigation Cube/Views") @Tm1Endpoint("Navigation Cube/PrivateViews") public reactor.core.publisher.Mono<Void> delete(String cube, ViewScope scope, String view) DELETE Cubes('c')/Views('v'); its subsets stay.- Parameters:
cube- the cube's namescope- where the view isview- the view's name- Returns:
- completes when the view is deleted
-
cube
@Tm1Endpoint("Navigation View/Cube") public reactor.core.publisher.Mono<Cube> cube(String cube, ViewScope scope, String view, ODataQuery query) GET Cubes('c')/Views('v')/Cube.- Parameters:
cube- the cube's namescope- where the view isview- the view's namequery- what to select and expand- Returns:
- the view's cube
-