| /** |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| */ |
| package org.eclipse.osbp.xtext.datamart.common; |
| |
| import java.util.ArrayList; |
| import java.util.HashMap; |
| import java.util.Map; |
| import java.util.Set; |
| |
| import org.eclipse.osbp.preferences.EnumDatabaseVendor; |
| import org.eclipse.osbp.preferences.ProductConfiguration; |
| import org.eclipse.osbp.ui.api.datamart.IDataMart; |
| import org.eclipse.osbp.ui.api.user.IUser; |
| import org.eclipse.osbp.ui.api.datamart.IDataMart.EType; |
| |
| @SuppressWarnings("all") |
| public abstract class ADatamart<C> implements IDataMart { |
| public abstract C connect(); |
| public abstract HashMap<Integer,ArrayList<String>> getAxisMap(); |
| public abstract int getNumberOfAxes(); |
| public abstract HashMap<String, EType> getIdMap(); |
| public abstract HashMap<String, EType> getTypesMap(IUser user); |
| public String setFilters(final Map<String,String> filteredItems) { |
| return null; |
| } |
| /** |
| * @see {@link #enableFillerText(boolean)} |
| * @param filteredItems |
| * @return returns results from datamart. If filler text is enabled, the result will be generated via filler text. |
| */ |
| public abstract void disconnect(); |
| |
| protected EnumDatabaseVendor dbVendor = null; |
| private HashMap<String, String> filterMap = null; |
| |
| /** |
| * @return the map with all filters, which has to be initialized once |
| */ |
| private HashMap<String, String> getFilterMap() { |
| if (filterMap == null) { |
| String jndiName = ProductConfiguration.getPersistenceUnitJndiName(getPersistenceUnit()); |
| dbVendor = ProductConfiguration.getDataSource(jndiName).getDatabaseVendor(); |
| filterMap = initializeFilterMap(); |
| } |
| return filterMap; |
| } |
| |
| /** |
| * @return all filter ids |
| */ |
| protected Set<String> getFilterIds() { |
| return getFilterMap().keySet(); |
| } |
| |
| /** |
| * @param filterID |
| * @return the filter for the given filter id |
| */ |
| protected String getFilter(String filterID) { |
| String filter = getFilterMap().get(filterID); |
| if (filter != null) { |
| filter = dbVendor.applySqlSpecifications(filter); |
| } |
| return filter; |
| } |
| |
| /** |
| * @return count of filters |
| */ |
| protected int getFiltersCount() { |
| return getFilterMap().size(); |
| } |
| |
| /** |
| * @return the persistence unit used |
| */ |
| abstract protected String getPersistenceUnit(); |
| |
| /** |
| * @return the initialized filter map |
| */ |
| abstract protected HashMap<String, String> initializeFilterMap(); |
| } |