use of com.haulmont.cuba.core.global.DevelopmentException in project cuba by cuba-platform.
the class RuntimePropertiesFrame method initDatasources.
protected void initDatasources(Map<String, Object> params) {
String dsId = (String) params.get("runtimeDs");
if (dsId == null)
throw new DevelopmentException("runtimeProperties initialization error: runtimeDs is not provided");
rds = (RuntimePropsDatasource) getDsContext().get(dsId);
if (rds == null)
throw new DevelopmentException("runtimeProperties initialization error: runtimeDs '" + dsId + "' does not exists");
String categoriesDsId = (String) params.get("categoriesDs");
if (categoriesDsId == null)
throw new DevelopmentException("runtimeProperties initialization error: categoriesDs is not provided");
categoriesDs = (CollectionDatasource) getDsContext().get(categoriesDsId);
if (categoriesDs == null)
throw new DevelopmentException("runtimeProperties initialization error: categoriesDs '" + categoriesDsId + "' does not exists");
}
use of com.haulmont.cuba.core.global.DevelopmentException in project cuba by cuba-platform.
the class DesktopComponentsFactory method createComponent.
@Override
public <T extends Component> T createComponent(Class<T> type) {
String name = names.get(type);
if (name == null) {
java.lang.reflect.Field nameField;
try {
nameField = type.getField("NAME");
name = (String) nameField.get(null);
} catch (NoSuchFieldException | IllegalAccessException ignore) {
}
if (name == null)
throw new DevelopmentException(String.format("Class '%s' doesn't have NAME field", type.getName()));
else
names.put(type, name);
}
return type.cast(createComponent(name));
}
use of com.haulmont.cuba.core.global.DevelopmentException in project cuba by cuba-platform.
the class WebComponentsFactory method createComponent.
@Override
public <T extends Component> T createComponent(Class<T> type) {
String name = names.get(type);
if (name == null) {
java.lang.reflect.Field nameField;
try {
nameField = type.getField("NAME");
name = (String) nameField.get(null);
} catch (NoSuchFieldException | IllegalAccessException ignore) {
}
if (name == null)
throw new DevelopmentException(String.format("Class '%s' doesn't have NAME field", type.getName()));
else
names.put(type, name);
}
return type.cast(createComponent(name));
}
use of com.haulmont.cuba.core.global.DevelopmentException in project cuba by cuba-platform.
the class WindowConfig method loadConfig.
@SuppressWarnings("unchecked")
protected void loadConfig(Element rootElem) {
for (Element element : (List<Element>) rootElem.elements("include")) {
String fileName = element.attributeValue("file");
if (!StringUtils.isBlank(fileName)) {
String incXml = resources.getResourceAsString(fileName);
if (incXml == null) {
log.warn("File {} not found, ignore it", fileName);
continue;
}
loadConfig(Dom4j.readDocument(incXml).getRootElement());
}
}
for (Element element : (List<Element>) rootElem.elements("screen")) {
String id = element.attributeValue("id");
if (StringUtils.isBlank(id)) {
log.warn("Invalid window config: 'id' attribute not defined");
continue;
}
ScreenAgent targetAgent = null;
String agent = element.attributeValue("agent");
if (StringUtils.isNotEmpty(agent)) {
targetAgent = activeScreenAgents.get(agent);
if (targetAgent == null) {
throw new DevelopmentException("Unable to find target screen agent", "agent", agent);
}
}
WindowInfo windowInfo = new WindowInfo(id, element, targetAgent);
List<WindowInfo> screenInfos = screens.get(id);
if (screenInfos == null) {
screenInfos = new ArrayList<>();
screens.put(id, screenInfos);
} else {
WindowInfo existingScreen = screenInfos.stream().filter(existingWindowInfo -> existingWindowInfo.getScreenAgent() == windowInfo.getScreenAgent()).findFirst().orElse(null);
if (existingScreen != null) {
screenInfos.remove(existingScreen);
}
}
screenInfos.add(windowInfo);
}
}
use of com.haulmont.cuba.core.global.DevelopmentException in project cuba by cuba-platform.
the class PropertyDatasourceImpl method getView.
@Override
public View getView() {
if (view == null) {
MetaClass metaMetaClass = masterDs.getMetaClass();
if (metadata.getTools().isPersistent(metaMetaClass) || metadata.getTools().isEmbeddable(metaMetaClass)) {
View masterView = masterDs.getView();
if (masterView == null) {
throw new DevelopmentException("No view for datasource " + masterDs.getId(), ParamsMap.of("masterDs", masterDs.getId(), "propertyDs", getId()));
}
ViewProperty property = masterView.getProperty(metaProperty.getName());
if (property == null) {
return null;
}
if (property.getView() == null) {
throw new DevelopmentException(String.format("Invalid view definition: %s. Property '%s' must have a view", masterView, property), ParamsMap.of("masterDs", masterDs.getId(), "propertyDs", getId(), "masterView", masterView, "property", property));
}
view = metadata.getViewRepository().findView(getMetaClass(), property.getView().getName());
// anonymous (nameless) view
if (view == null)
view = property.getView();
}
}
return view;
}
Aggregations