📄 dimensionstepmanager.java
字号:
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: XELOPES Data Mining Library
* Description: The XELOPES library is an open platform-independent and data-source-independent library for Embedded Data Mining.
* Copyright: Copyright (c) 2002 Prudential Systems Software GmbH
* Company: ZSoft (www.zsoft.ru), Prudsys (www.prudsys.com)
* @author Michael Thess
* @version 1.2
*/
package com.prudsys.pdm.Olap.Query.Core;
import java.util.Collection;
import java.util.List;
import javax.olap.OLAPException;
import javax.olap.query.enumerations.DimensionStepTypeEnum;
import javax.olap.query.enumerations.SetActionType;
import javax.olap.query.enumerations.SetActionTypeEnum;
import com.prudsys.pdm.Cwm.JMIList;
import com.prudsys.pdm.Input.Multidimensional.OrderAttribute;
import com.prudsys.pdm.Input.Predicates.CompoundPredicate;
import com.prudsys.pdm.Input.Predicates.Predicate;
import com.prudsys.pdm.Olap.Query.DimensionFilters.AttributeFilter;
import com.prudsys.pdm.Olap.Query.Sorting.AttributeSort;
/**
* Dimension step manager class.
*/
public class DimensionStepManager extends NamedObject implements javax.olap.query.querycoremodel.DimensionStepManager {
// -----------------------------------------------------------------------
// Variables declarations
// -----------------------------------------------------------------------
/** Reference to dimension view owning this manager. */
protected DimensionView dimensionView;
/** List of dimension steps of manager. */
protected JMIList dimensionStep = new JMIList();
/** Predicate for selection. */
protected Predicate predicate = null;
/** Order attribute for ordering. */
protected OrderAttribute orderAttribute = null;
// -----------------------------------------------------------------------
// Constructors
// -----------------------------------------------------------------------
/**
* Empty constructor.
*/
public DimensionStepManager() {
}
/**
* Dimension step manager from dimension view.
*
* @param dimensionView associated dimension view
*/
public DimensionStepManager(DimensionView dimensionView) {
this.dimensionView = dimensionView;
}
// -----------------------------------------------------------------------
// Getter and setter methods
// -----------------------------------------------------------------------
public javax.olap.query.querycoremodel.DimensionView getDimensionView() throws OLAPException {
return dimensionView;
}
public void setSegment(Collection input) throws OLAPException {
throw new UnsupportedOperationException();
}
public Collection getSegment() throws OLAPException {
throw new UnsupportedOperationException();
}
public void addSegment(javax.olap.query.querycoremodel.Segment input) throws OLAPException {
throw new UnsupportedOperationException();
}
public void removeSegment(javax.olap.query.querycoremodel.Segment input) throws OLAPException {
throw new UnsupportedOperationException();
}
public void setDimensionStep(Collection input) throws OLAPException {
dimensionStep.set(input);
}
public List getDimensionStep() throws OLAPException {
return dimensionStep.get();
}
public void removeDimensionStep(javax.olap.query.querycoremodel.DimensionStep input) throws OLAPException {
dimensionStep.remove(input);
}
public void moveDimensionStepBefore(javax.olap.query.querycoremodel.DimensionStep before, javax.olap.query.querycoremodel.DimensionStep input) throws OLAPException {
dimensionStep.moveBefore(before, input);
}
public void moveDimensionStepAfter(javax.olap.query.querycoremodel.DimensionStep before, javax.olap.query.querycoremodel.DimensionStep input) throws OLAPException {
dimensionStep.moveAfter(before, input);
}
public javax.olap.query.querycoremodel.DimensionStep createDimensionStep(javax.olap.query.enumerations.DimensionStepType stepType) throws OLAPException {
DimensionStep ds = new DimensionStep(this);
if (stepType == DimensionStepTypeEnum.ATTRIBUTEFILTER) {
ds = new AttributeFilter(this);
}
else if (stepType == DimensionStepTypeEnum.ATTRIBUTESORT) {
ds = new AttributeSort(this);
}
else if (stepType == DimensionStepTypeEnum.DATABASEDMEMBERFILTER) {
throw new UnsupportedOperationException();
}
else if (stepType == DimensionStepTypeEnum.DATABASEDSORT) {
throw new UnsupportedOperationException();
}
else if (stepType == DimensionStepTypeEnum.DRILLFILTER) {
throw new UnsupportedOperationException();
}
else if (stepType == DimensionStepTypeEnum.EXCEPTIONMEMBERFILTER) {
throw new UnsupportedOperationException();
}
else if (stepType == DimensionStepTypeEnum.HIERARCHYFILTER) {
throw new UnsupportedOperationException();
}
else if (stepType == DimensionStepTypeEnum.HIERARCHICALSORT) {
throw new UnsupportedOperationException();
}
else if (stepType == DimensionStepTypeEnum.LEVELFILTER) {
throw new UnsupportedOperationException();
}
else if (stepType == DimensionStepTypeEnum.MEMBERLISTFILTER) {
throw new UnsupportedOperationException();
}
else if (stepType == DimensionStepTypeEnum.RANKINGMEMBERFILTER) {
throw new UnsupportedOperationException();
}
else if (stepType == DimensionStepTypeEnum.SINGLEMEMBERFILTER) {
throw new UnsupportedOperationException();
}
else {
throw new OLAPException("unknown dimension step type " + stepType);
}
dimensionStep.add(ds);
return ds;
}
public javax.olap.query.querycoremodel.DimensionStep createDimensionStepBefore(javax.olap.query.enumerations.DimensionStepType stepType, javax.olap.query.querycoremodel.DimensionStep member) throws OLAPException {
return (javax.olap.query.querycoremodel.DimensionStep) dimensionStep.addBefore(member, new DimensionStep(this) );
}
public javax.olap.query.querycoremodel.DimensionStep createDimensionStepAfter(javax.olap.query.enumerations.DimensionStepType stepType, javax.olap.query.querycoremodel.DimensionStep member) throws OLAPException {
return (javax.olap.query.querycoremodel.DimensionStep) dimensionStep.addAfter(member, new DimensionStep(this));
}
// -----------------------------------------------------------------------
// Construct selection predicate and order attribute
// -----------------------------------------------------------------------
public Predicate getPredicate() throws OLAPException {
predicate = null;
for (int i = 0; i < dimensionStep.size(); i++) {
DimensionStep ds = (DimensionStep) dimensionStep.get(i);
if ( ! (ds instanceof DimensionFilter) )
continue;
DimensionFilter df = (DimensionFilter) ds;
Predicate pred = df.getPredicate();
if (pred == null)
continue;
SetActionType setAction = df.getSetAction();
if (setAction == SetActionTypeEnum.INITIAL) {
predicate = pred;
}
else if (setAction == SetActionTypeEnum.APPEND) {
CompoundPredicate cp = new CompoundPredicate(CompoundPredicate.OR, 2);
cp.setPredicate(predicate, 0);
cp.setPredicate(pred, 1);
predicate = cp;
}
else if (setAction == SetActionTypeEnum.PREPEND) {
CompoundPredicate cp = new CompoundPredicate(CompoundPredicate.OR, 2);
cp.setPredicate(pred, 0);
cp.setPredicate(predicate, 1);
predicate = cp;
}
else if (setAction == SetActionTypeEnum.INTERSECTION) {
CompoundPredicate cp = new CompoundPredicate(CompoundPredicate.AND, 2);
cp.setPredicate(predicate, 0);
cp.setPredicate(pred, 1);
predicate = cp;
}
else if (setAction == SetActionTypeEnum.DIFFERENCE) {
CompoundPredicate cp = new CompoundPredicate(CompoundPredicate.XOR, 2);
cp.setPredicate(predicate, 0);
cp.setPredicate(pred, 1);
predicate = cp;
}
else if (setAction == SetActionTypeEnum.INSERT) {
throw new OLAPException("DimensionStep " + i + ": INSERT action type not supported");
}
else
throw new OLAPException("DimensionStep " + i + ": unknown set action type");
}
return predicate;
}
public OrderAttribute getOrderAttribute() throws OLAPException {
orderAttribute = null;
for (int i = 0; i < dimensionStep.size(); i++) {
DimensionStep ds = (DimensionStep) dimensionStep.get(i);
if (! (ds instanceof DimensionSort))
continue;
DimensionSort dt = (DimensionSort) ds;
OrderAttribute ord = dt.getOrderAttribute();
if (ord == null)
continue;
orderAttribute = ord;
}
return orderAttribute;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -