br.com.jarch.faces.controller.BaseController Maven / Gradle / Ivy
package br.com.jarch.faces.controller;
import br.com.jarch.core.crud.dynamic.IDynamicColumn;
import br.com.jarch.faces.util.JavaScriptUtils;
import br.com.jarch.faces.util.JsfUtils;
import br.com.jarch.core.model.IIdentity;
import br.com.jarch.core.model.MultiTenant;
import br.com.jarch.core.model.UserInformation;
import br.com.jarch.util.ReflectionUtils;
import javax.annotation.PostConstruct;
import javax.persistence.Table;
public abstract class BaseController implements IBaseController {
private boolean usageDynamicColumn;
@PostConstruct
private void initBaseController() {
try {
usageDynamicColumn = IDynamicColumn.class.isAssignableFrom(classEntity());
} catch (Exception ex) {
usageDynamicColumn = false;
}
}
@Override
public boolean isSystemTest() {
return UserInformation.getInstance().isExecutionSystemTest();
}
protected UserInformation getUserInformation() {
return UserInformation.getInstance();
}
protected MultiTenant getMultiTenant() {
return MultiTenant.getInstance();
}
@Override
public boolean isUsageDynamicColumn() {
return usageDynamicColumn;
}
@Override
public void listDynamicColumn(String pageName) {
pageName = JsfUtils.getOnlyNamePage(pageName);
if (usageDynamicColumn) {
configSessioDynamics();
JsfUtils.redirect("../dynamic/fieldDynamicList.jsf?pageName=" + pageName);
} else {
JavaScriptUtils.showMessageBodyWarningNoRedirect("Feature Coluna Dinâmica", "Não está ATIVA para essa APLICAÇÃO/FUNCIONALIDADE!");
}
}
@Override
public void insertDynamicColumn(String pageName) {
pageName = JsfUtils.getOnlyNamePage(pageName);
if (usageDynamicColumn) {
configSessioDynamics();
JsfUtils.redirect("../dynamic/fieldDynamicList.jsf?pageName=" + pageName + "&insert=S");
} else {
JavaScriptUtils.showMessageBodyWarningNoRedirect("Feature Coluna Dinâmica", "Não está ATIVA para essa APLICAÇÃO/FUNCIONALIDADE!");
}
}
@Override
public Class classEntity() {
return ReflectionUtils.getGenericClass(getClass(), 0);
}
private void configSessioDynamics() {
JsfUtils.setAttributeSession("jarch.dynamic.redirect", JsfUtils.getUrl());
String nameEntity = classEntity().getSimpleName();
JsfUtils.setAttributeSession("jarch.dynamic.classEntity", nameEntity);
String nameTable = classEntity().getAnnotation(Table.class).name().toUpperCase();
JsfUtils.setAttributeSession("jarch.dynamic.nameTable", nameTable);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy