📄 cube.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 Valentine Stepanenko (valentine.stepanenko@zsoft.ru)
* @version 1.0
*/
package com.prudsys.pdm.Olap.Metadata;
import java.util.Collection;
import java.util.Iterator;
import java.util.Vector;
import javax.olap.OLAPException;
import com.prudsys.pdm.Olap.OlapEngine;
/**
* A Cube is a collection of analytic values (i.e., measures) that share the same
* dimensionality. This dimensionality is specified by a set of unique Dimensions
* from the Schema. Each unique combination of members in the Cartesian product
* of the Cube?s Dimensions identifies precisely one data cell within a
* multidimensional structure.
*
*
*
* Synonyms: Multidimensional Array, Hypercube, Hypervolume.
*/
public class Cube extends com.prudsys.pdm.Cwm.Core.Class implements javax.olap.serversidemetadata.Cube
{
// -----------------------------------------------------------------------
// Variables declarations from CWM
// -----------------------------------------------------------------------
/**
* If true, then this Cube is a Virtual Cube (i.e., it has no physical
* realization).
*/
public com.prudsys.pdm.Cwm.Core.Boolean isVirtual = new com.prudsys.pdm.Cwm.Core.Boolean();
/** The schema owning the cube. */
public Schema schema;
/** Object to assign dimensions to the cube. */
public CubeDimensionAssociation cubeDimensionAssociation[];
/** Cube region. */
public CubeRegion cubeRegion[];
// -----------------------------------------------------------------------
// Variables declarations from XELOPES extension
// -----------------------------------------------------------------------
/** Reference to OLAP engine object. */
protected OlapEngine olapEngine;
/** Contains the dimensions used in the cube. */
protected Vector dimensions = new Vector();
// -----------------------------------------------------------------------
// Constructors from CWM
// -----------------------------------------------------------------------
/**
* Empty constructor.
*/
public Cube()
{
}
// -----------------------------------------------------------------------
// Constructors from XELOPES extension
// -----------------------------------------------------------------------
/**
* Constructor with reference to OLAP engine object.
*
* @param olapEngine OLAP engine object
*/
public Cube(OlapEngine olapEngine) {
this.olapEngine = olapEngine;
}
// -----------------------------------------------------------------------
// JMI methods from CWM
// -----------------------------------------------------------------------
public Collection getCubeDimensionAssociation() throws OLAPException
{
return com.prudsys.pdm.Cwm.Core.CWMTools.ArrayToList(cubeDimensionAssociation);
}
public void setCubeDimensionAssociation(Collection cubeDimensionAssociation) throws OLAPException
{
this.cubeDimensionAssociation = new CubeDimensionAssociation[ cubeDimensionAssociation.size() ];
Iterator it = cubeDimensionAssociation.iterator();
for (int i = 0; i < cubeDimensionAssociation.size(); i++)
this.cubeDimensionAssociation[i] = (CubeDimensionAssociation) it.next();
}
public void addCubeDimensionAssociation( javax.olap.metadata.CubeDimensionAssociation input) {
int size = (cubeDimensionAssociation == null) ? 0 : cubeDimensionAssociation.length;
CubeDimensionAssociation[] oldData = cubeDimensionAssociation;
cubeDimensionAssociation = new CubeDimensionAssociation[size+1];
if (size > 0) System.arraycopy(oldData, 0, cubeDimensionAssociation, 0, size);
cubeDimensionAssociation[size] = (CubeDimensionAssociation) input;
}
public void removeCubeDimensionAssociation( javax.olap.metadata.CubeDimensionAssociation input) throws OLAPException
{
int size = (cubeDimensionAssociation == null) ? 0 : cubeDimensionAssociation.length;
if (size == 0)
return;
int ipos = -1;
for (int i = 0; i < size; i++)
if (cubeDimensionAssociation[i].equals(input)) {
ipos = i;
break;
}
if (ipos == -1)
return;
CubeDimensionAssociation[] oldData = cubeDimensionAssociation;
cubeDimensionAssociation = new CubeDimensionAssociation[size-1];
for (int i = 0; i < ipos; i++)
cubeDimensionAssociation[i] = oldData[i];
for (int i = ipos+1; i < size; i++)
cubeDimensionAssociation[i-1] = oldData[i];
}
public java.lang.Boolean getIsVirtual() throws OLAPException
{
return isVirtual.getBoolean();
}
public void setIsVirtual(Boolean isVirtual) throws OLAPException
{
com.prudsys.pdm.Cwm.Core.Boolean b = new com.prudsys.pdm.Cwm.Core.Boolean();
b.setBoolean(isVirtual);
this.isVirtual =b ;
}
public boolean isVirtualValue() throws OLAPException
{
return isVirtual.isBooleanValue();
}
public void setIsVirtual(boolean isVirtual) throws OLAPException
{
this.setIsAbstract( new Boolean(isVirtual) );
}
public javax.olap.metadata.Schema getSchema() throws OLAPException
{
return schema;
}
public void setSchema(javax.olap.metadata.Schema schema) throws OLAPException
{
this.schema = (Schema) schema;
}
public Collection getCubeRegion() throws OLAPException
{
return com.prudsys.pdm.Cwm.Core.CWMTools.ArrayToList(cubeDimensionAssociation);
}
public void setCubeRegion(Collection cubeRegion) throws OLAPException
{
this.cubeRegion = new CubeRegion[ cubeRegion.size() ];
Iterator it = cubeRegion.iterator();
for (int i = 0; i < cubeRegion.size(); i++)
this.cubeRegion[i] = (CubeRegion) it.next();
}
public void addCubeRegion( javax.olap.serversidemetadata.CubeRegion input) throws OLAPException
{
int size = (cubeRegion == null) ? 0 : cubeRegion.length;
CubeRegion[] oldData = cubeRegion;
cubeRegion = new CubeRegion[size+1];
if (size > 0) System.arraycopy(oldData, 0, cubeRegion, 0, size);
cubeRegion[size] = (CubeRegion) input;
}
public void removeCubeRegion( javax.olap.serversidemetadata.CubeRegion input) throws OLAPException
{
int size = (cubeRegion == null) ? 0 : cubeRegion.length;
if (size == 0)
return;
int ipos = -1;
for (int i = 0; i < size; i++)
if (cubeRegion[i].equals(input)) {
ipos = i;
break;
}
if (ipos == -1)
return;
CubeRegion[] oldData = cubeRegion;
cubeRegion = new CubeRegion[size-1];
for (int i = 0; i < ipos; i++)
cubeRegion[i] = oldData[i];
for (int i = ipos+1; i < size; i++)
cubeRegion[i-1] = oldData[i];
}
public String toString() {
String s = "Cube name = " + getName() + " \n";
if (ownedElement != null) {
s = s + "#measures = " + ownedElement.length + " : ";
for (int i = 0; i < ownedElement.length; i++) {
if (ownedElement[i] instanceof Measure) {
s = s + ownedElement[i].getName() + ", ";
}
}
s = s.substring(0, s.length()-2);
s = s + "\n";
}
if (cubeDimensionAssociation != null) {
s = s + "#cubeDimensionAssociations = " + cubeDimensionAssociation.length + " :\n";
for (int i = 0; i < cubeDimensionAssociation.length; i++) {
s = s + cubeDimensionAssociation[i].toString() + "\n";
}
}
return s;
}
// -----------------------------------------------------------------------
// Methods from XELOPES extension
// -----------------------------------------------------------------------
/**
* Adds new dimension to cube. Internally, a CubeDimensionAssociation object
* is created and used for this association.
*
* @param dimension new dimension
* @exception OLAPException can't add dimension to cube
*/
public void addDimension(Dimension dimension) throws OLAPException {
CubeDimensionAssociation dimAsso = (CubeDimensionAssociation)
olapEngine.getCubeDimensionAssociation().createCubeDimensionAssociation();
dimAsso.setDimension(dimension);
addCubeDimensionAssociation(dimAsso);
dimensions.addElement(dimension);
}
/**
* Returns vector of dimensions.
*
* @return vector of dimensions
*/
public Vector getDimensions() {
return dimensions;
}
/**
* Returns the number of dimension attributes.
*
* @return number of dimension attributes
*/
public int getNumberOfDimensions() {
return dimensions.size();
}
/**
* Returns dimension that corresponds to specified index.
*
* @param index specified dimension index
* @return attribute of this index, null if not found
*/
public Dimension getDimensionAttribute(int index) {
if (index < 0 || index >= dimensions.size())
return null;
return (Dimension) dimensions.elementAt(index);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -