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

org.joinedworkz.common.strategies.TableNameStrategy Maven / Gradle / Ivy

There is a newer version: 1.3.46
Show newest version
package org.joinedworkz.common.strategies;

import javax.inject.Inject;
import javax.inject.Singleton;
import org.eclipse.xtext.xbase.lib.Extension;
import org.joinedworkz.common.helper.CmnModelHelper;
import org.joinedworkz.common.helper.NameHelper;
import org.joinedworkz.core.facility.AbstractStrategy;
import org.joinedworkz.core.model.CmnFieldContainer;
import org.joinedworkz.core.model.CmnModel;
import org.joinedworkz.core.model.CmnObject;

@Singleton
@SuppressWarnings("all")
public class TableNameStrategy extends AbstractStrategy {
  @Inject
  @Extension
  protected CmnModelHelper _cmnModelHelper;

  @Inject
  @Extension
  protected NameHelper _nameHelper;

  @Override
  public Object apply(final CmnObject obj) {
    if ((obj instanceof CmnFieldContainer)) {
      return this.defaultTableName(((CmnFieldContainer)obj));
    }
    return null;
  }

  public String defaultTableName(final CmnFieldContainer it) {
    CmnModel _model = this._cmnModelHelper.getModel(it);
    String _string = null;
    if (_model!=null) {
      _string=_model.getString("tableNamePrefix");
    }
    final String prefix = _string;
    final String tableName = this._nameHelper.camelCaseToUnderLineSeperated(it.getName()).toLowerCase();
    if ((prefix != null)) {
      return (prefix + tableName);
    } else {
      return tableName;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy