All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.protempa.backend.AbstractCommonsDataSourceBackend Maven / Gradle / Ivy

There is a newer version: 5.2-Alpha-2
Show newest version
/*
 * #%L
 * Protempa Commons Backend Provider
 * %%
 * Copyright (C) 2012 - 2013 Emory University
 * %%
 * 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
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * 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.
 * #L%
 */
package org.protempa.backend;

import org.protempa.backend.annotations.BackendProperty;
import org.protempa.backend.dsb.AbstractDataSourceBackend;
import org.protempa.proposition.value.GranularityFactory;
import org.protempa.proposition.value.UnitFactory;

/**
 *
 * @author Andrew Post
 */
public abstract class AbstractCommonsDataSourceBackend
        extends AbstractDataSourceBackend  {

    @Override
    public void initialize(BackendInstanceSpec config)
        throws BackendInitializationException {
        super.initialize(config);
        CommonsBackend.initialize(this, config);
    }

    @Override
    public final String getDisplayName() {
        return CommonsBackend.backendInfo(this).displayName();
    }

    protected final String nameForErrors() {
        return CommonsBackend.nameForErrors(this);
    }

    @BackendProperty
    @Deprecated
    public final void setDataSourceBackendId(String id) {
        setId(id);
    }

    @Deprecated
    public final String getDataSourceBackendId () {
        return getId();
    }
    
    @BackendProperty
    @Override
    public final void setId(String id) {
        super.setId(id);
    }
    
    @Override
    public final String getId() {
        return super.getId();
    }

    @BackendProperty
    @Override
    public void setKeyType(String keyType) {
        super.setKeyType(keyType);
    }

    @Override
    public String getKeyType() {
        return super.getKeyType();
    }
    
    @BackendProperty(propertyName = "unitFactory")
    public void parseUnitFactory(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        setUnitFactory((UnitFactory) Class.forName(className).newInstance());
    }
    
    @BackendProperty(propertyName = "granularityFactory")
    public void parseGranularityFactory(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        setGranularityFactory((GranularityFactory) Class.forName(className).newInstance());
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy