Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2014 JBoss Inc Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 package org.dashbuilder.dataset.client;
 import  org.dashbuilder.dataset.DataSet;
 import  org.dashbuilder.dataset.DataSetFactory;
 import  org.dashbuilder.dataset.DataSetLookup;
 import  org.dashbuilder.dataset.DataSetManager;
 import  org.dashbuilder.dataset.DataSetMetadata;
 import  org.dashbuilder.common.client.StringUtils;
 import  org.dashbuilder.dataset.engine.SharedDataSetOpEngine;
 import  org.dashbuilder.dataset.engine.index.DataSetIndex;
Client implementation of a DataSetManager. It hold as map of data sets in memory. It is designed to manipulate not quite big data sets. For big data sets the backend implementation is better,
 public class ClientDataSetManager implements DataSetManager {
     public static ClientDataSetManager get() {
         IOCBeanDef<ClientDataSetManagerbeanDef = beans.iterator().next();
         return beanDef.getInstance();
     @Inject SharedDataSetOpEngine dataSetOpEngine;
     public DataSet createDataSet(String uuid) {
         DataSet dataSet = DataSetFactory.newDataSet();
         return dataSet;
     public DataSet getDataSet(String uuid) {
         DataSetIndex index = .getIndexRegistry().get(uuid);
         if (index == nullreturn null;
         return index.getDataSet();
     public void registerDataSet(DataSet dataSet) {
         if (dataSet != null) {
     public DataSet removeDataSet(String uuid) {
         DataSet dataSet = getDataSet(uuid);
         return dataSet;
     public DataSetMetadata getDataSetMetadata(String uuid) {
         DataSet dataSet = getDataSet(uuid);
         if (dataSet == nullreturn null;
         return dataSet.getMetadata();
     public DataSet lookupDataSet(DataSetLookup lookup) {
         String uuid = lookup.getDataSetUUID();
         if (StringUtils.isEmpty(uuid)) return null;
         // Get the target data set
         DataSetIndex dataSetIndex = .getIndexRegistry().get(uuid);
         if (dataSetIndex == nullreturn null;
         DataSet dataSet = dataSetIndex.getDataSet();
         // Apply the list of operations specified (if any).
         if (!lookup.getOperationList().isEmpty()) {
             dataSet = .execute(dataSetIndex.getDataSet(), lookup.getOperationList());
         // Trim the data set as requested.
         dataSet = dataSet.trim(lookup.getRowOffset(), lookup.getNumberOfRows());
         return dataSet;
    public DataSet[] lookupDataSets(DataSetLookup[] lookup) {
        DataSet[] result = new DataSet[lookup.length];
        for (int i = 0; i < lookup.length; i++) {
            result[i] = lookupDataSet(lookup[i]);
        return result;
    public DataSetMetadata lookupDataSetMetadata(DataSetLookup lookup) {
        DataSet dataSet = lookupDataSet(lookup);
        if (dataSet == nullreturn null;
        return dataSet.getMetadata();
New to GrepCode? Check out our FAQ X