blob: de48efb5c455164d3e9fd6a7b313e116050fe843 [file] [log] [blame]
/**
*
* 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.reportdsl.oda.datamart.impl;
import org.eclipse.birt.report.model.api.SessionHandle;
import org.eclipse.datatools.connectivity.oda.IConnection;
import org.eclipse.datatools.connectivity.oda.IDriver;
import org.eclipse.datatools.connectivity.oda.LogConfiguration;
import org.eclipse.datatools.connectivity.oda.OdaException;
import org.eclipse.datatools.connectivity.oda.util.manifest.DataTypeMapping;
import org.eclipse.datatools.connectivity.oda.util.manifest.ExtensionManifest;
import org.eclipse.datatools.connectivity.oda.util.manifest.ManifestExplorer;
/**
* Implementation class of IDriver for an ODA runtime driver.
*/
public class Driver implements IDriver {
static String ODA_DATA_SOURCE_ID = "org.eclipse.osbp.xtext.reportdsl.oda.datamart"; //$NON-NLS-1$
public Driver() {
super();
SessionHandle.setBirtResourcePath("i18n/I18N");
}
/*
* @see org.eclipse.datatools.connectivity.oda.IDriver#getConnection(java.lang.String)
*/
public IConnection getConnection( String dataSourceType ) throws OdaException {
// assumes that this driver supports only one type of data source,
// ignores the specified dataSourceType
return new Connection();
}
/*
* @see org.eclipse.datatools.connectivity.oda.IDriver#setLogConfiguration(org.eclipse.datatools.connectivity.oda.LogConfiguration)
*/
public void setLogConfiguration( LogConfiguration logConfig ) throws OdaException {
// do nothing; assumes simple driver has no logging
}
/*
* @see org.eclipse.datatools.connectivity.oda.IDriver#getMaxConnections()
*/
public int getMaxConnections() throws OdaException {
return 0; // no limit
}
/*
* @see org.eclipse.datatools.connectivity.oda.IDriver#setAppContext(java.lang.Object)
*/
public void setAppContext( Object context ) throws OdaException {
// System.err.println(this.getClass().getSimpleName()+".setAppContext: "+(context == null ? "<null>" : context.toString()));
// do nothing; assumes no support for pass-through context
}
/**
* Returns the object that represents this extension's manifest.
* @throws OdaException
*/
static ExtensionManifest getManifest() throws OdaException {
return ManifestExplorer.getInstance().getExtensionManifest( ODA_DATA_SOURCE_ID );
}
/**
* Returns the native data type name of the specified code, as
* defined in this data source extension's manifest.
* @param nativeTypeCode the native data type code
* @return corresponding native data type name
* @throws OdaException if lookup fails
*/
static String getNativeDataTypeName( int nativeDataTypeCode ) throws OdaException {
DataTypeMapping typeMapping = getManifest().getDataSetType( null ).getDataTypeMapping( nativeDataTypeCode );
if( typeMapping != null ) {
return typeMapping.getNativeType();
}
throw new OdaException( String.format(
"%s.getNativeDataTypeName(%d):\nNative data type code %d could not be found in the DataTypeMapping",
Driver.class.getCanonicalName(),
nativeDataTypeCode,
nativeDataTypeCode
)); //$NON-NLS-1$
}
}