com.adaptrex.core.ext.ExtConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of adaptrex-core Show documentation
Show all versions of adaptrex-core Show documentation
The Core Adaptrex Framework
package com.adaptrex.core.ext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.adaptrex.core.persistence.api.ORMPersistenceManager;
import com.adaptrex.core.services.AdaptrexServices;
/*
* TODO: Do we switch this to model only config and simplify throughout?
*/
public class ExtConfig {
private String namespace;
private String factoryName;
private String className;
private String modelName;
private List includes = new ArrayList();
private List excludes = new ArrayList();
private List associations = new ArrayList();
private ExtConfig parentConfig;
private ORMPersistenceManager orm;
private Class> entityClass;
private boolean touch;
public ExtConfig(String entityClassName) {
this(entityClassName, null);
};
public ExtConfig(String entityClassName, String factoryName) {
this.factoryName = factoryName;
this.orm = AdaptrexServices.getPersistenceManager(factoryName);
this.entityClass = this.orm.getEntityClass(entityClassName);
if (this.entityClass == null) {
throw new RuntimeException("Couldn't find EntityClass for " + entityClassName);
}
this.modelName = this.entityClass.getSimpleName();
}
public ExtConfig setParentConfig(ExtConfig parentConfig) {
this.parentConfig = parentConfig;
return this;
}
public ExtConfig setNamespace(String namespace) {
this.namespace = namespace;
return this;
}
public ExtConfig setClassName(String className) {
this.className = className;
return this;
}
public ExtConfig setModelName(String name) {
this.modelName = name;
return this;
}
public ExtConfig setIncludes(List include) {
this.includes = include;
return this;
}
public ExtConfig setExcludes(List exclude) {
this.excludes = exclude;
return this;
}
public ExtConfig setAssociations(List associations) {
this.associations = associations;
return this;
}
public ExtConfig setIncludes(String include) {
if (include == null) {return this;}
this.includes = Arrays.asList(include.split(","));
return this;
}
public ExtConfig setExcludes(String exclude) {
if (exclude == null) {return this;}
this.excludes = Arrays.asList(exclude.split(","));
return this;
}
public ExtConfig setAssociations(String associations) {
if (associations == null) {return this;}
this.associations = Arrays.asList(associations.split(","));
return this;
}
public ExtConfig getParentConfig() {
return parentConfig;
}
public String getNamespace() {
return namespace;
}
public String getFactoryName() {
return factoryName;
}
public String getClassName() {
return className;
}
public String getModelName() {
return modelName;
}
public List getIncludes() {
return includes;
}
public List getExcludes() {
return excludes;
}
public List getAssociations() {
return associations;
}
public ORMPersistenceManager getORMPersistenceManager() {
return orm;
}
public Class> getEntityClass() {
return entityClass;
}
public boolean isTouch() {
return touch;
}
public void setTouch(boolean touch) {
this.touch = touch;
}
}