001/**
002 * Copyright 2014 The Sculptor Project Team, including the original
003 * author or authors.
004 * 
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 * 
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 * 
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.sculptor.generator.cartridge.mongodb;
018
019import com.google.common.base.Objects;
020import javax.inject.Inject;
021import javax.inject.Named;
022import org.eclipse.xtext.xbase.lib.Extension;
023import org.sculptor.generator.configuration.MutableConfigurationProvider;
024import org.sculptor.generator.ext.Properties;
025import org.sculptor.generator.util.PropertiesBase;
026
027@SuppressWarnings("all")
028public class MongoDbProperties {
029  @Inject
030  @Extension
031  private PropertiesBase propertiesBase;
032  
033  @Inject
034  @Extension
035  private Properties properties;
036  
037  /**
038   * Prepare the default values with values inherited from the configuration.
039   */
040  @Inject
041  protected void initDerivedDefaults(@Named("Mutable Defaults") final MutableConfigurationProvider defaultConfiguration) {
042    defaultConfiguration.setString("package.mapper", "mapper");
043    String _fw = this.properties.fw("accessimpl.mongodb");
044    defaultConfiguration.setString("framework.accessimpl.package", _fw);
045    defaultConfiguration.setString("framework.accessimpl.prefix", "MongoDb");
046    defaultConfiguration.setString("framework.accessimpl.AccessBase", 
047      "org.sculptor.framework.accessimpl.mongodb.MongoDbAccessBase");
048    defaultConfiguration.setString("framework.accessimpl.AccessBaseWithException", 
049      "org.sculptor.framework.accessimpl.mongodb.MongoDbAccessBaseWithException");
050  }
051  
052  public boolean mongoDb() {
053    String _property = this.propertiesBase.getProperty("nosql.provider");
054    return Objects.equal(_property, "mongoDb");
055  }
056  
057  public String getMapperPackage() {
058    return this.propertiesBase.getProperty("package.mapper");
059  }
060}