Search in sources :

Example 1 with DataChannelFilter

use of org.apache.cayenne.DataChannelFilter in project cayenne by apache.

the class DataDomainProvider method createAndInitDataDomain.

@SuppressWarnings("deprecation")
protected DataDomain createAndInitDataDomain() throws Exception {
    DataChannelDescriptor descriptor = loadDescriptor();
    DataDomain dataDomain = createDataDomain(descriptor.getName());
    dataDomain.setMaxIdQualifierSize(runtimeProperties.getInt(Constants.SERVER_MAX_ID_QUALIFIER_SIZE_PROPERTY, -1));
    dataDomain.setQueryCache(new NestedQueryCache(queryCache));
    dataDomain.setEntitySorter(injector.getInstance(EntitySorter.class));
    dataDomain.setEventManager(injector.getInstance(EventManager.class));
    dataDomain.setDataRowStoreFactory(injector.getInstance(DataRowStoreFactory.class));
    dataDomain.initWithProperties(descriptor.getProperties());
    for (DataMap dataMap : descriptor.getDataMaps()) {
        dataDomain.addDataMap(dataMap);
    }
    dataDomain.getEntityResolver().applyDBLayerDefaults();
    dataDomain.getEntityResolver().setValueObjectTypeRegistry(valueObjectTypeRegistry);
    dataDomain.getEntityResolver().setValueComparisionStrategyFactory(valueComparisonStrategyFactory);
    for (DataNodeDescriptor nodeDescriptor : descriptor.getNodeDescriptors()) {
        addDataNode(dataDomain, nodeDescriptor);
    }
    // init default node
    DataNode defaultNode = null;
    if (descriptor.getDefaultNodeName() != null) {
        defaultNode = dataDomain.getDataNode(descriptor.getDefaultNodeName());
    }
    if (defaultNode == null) {
        Collection<DataNode> allNodes = dataDomain.getDataNodes();
        if (allNodes.size() == 1) {
            defaultNode = allNodes.iterator().next();
        }
    }
    if (defaultNode != null) {
        logger.info("setting DataNode '" + defaultNode.getName() + "' as default, used by all unlinked DataMaps");
        dataDomain.setDefaultNode(defaultNode);
    }
    // filters are deprecated, used here for backward compatibility
    for (DataChannelFilter filter : filters) {
        dataDomain.addFilter(filter);
    }
    for (DataChannelQueryFilter filter : queryFilters) {
        dataDomain.addQueryFilter(filter);
    }
    for (DataChannelSyncFilter filter : syncFilters) {
        dataDomain.addSyncFilter(filter);
    }
    for (Object listener : listeners) {
        dataDomain.addListener(listener);
    }
    return dataDomain;
}
Also used : DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) DataDomain(org.apache.cayenne.access.DataDomain) EntitySorter(org.apache.cayenne.map.EntitySorter) DataChannelFilter(org.apache.cayenne.DataChannelFilter) EventManager(org.apache.cayenne.event.EventManager) DataNodeDescriptor(org.apache.cayenne.configuration.DataNodeDescriptor) DataMap(org.apache.cayenne.map.DataMap) NestedQueryCache(org.apache.cayenne.cache.NestedQueryCache) DataNode(org.apache.cayenne.access.DataNode) DataChannelSyncFilter(org.apache.cayenne.DataChannelSyncFilter) DataChannelQueryFilter(org.apache.cayenne.DataChannelQueryFilter) DataRowStoreFactory(org.apache.cayenne.access.DataRowStoreFactory)

Aggregations

DataChannelFilter (org.apache.cayenne.DataChannelFilter)1 DataChannelQueryFilter (org.apache.cayenne.DataChannelQueryFilter)1 DataChannelSyncFilter (org.apache.cayenne.DataChannelSyncFilter)1 DataDomain (org.apache.cayenne.access.DataDomain)1 DataNode (org.apache.cayenne.access.DataNode)1 DataRowStoreFactory (org.apache.cayenne.access.DataRowStoreFactory)1 NestedQueryCache (org.apache.cayenne.cache.NestedQueryCache)1 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)1 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)1 EventManager (org.apache.cayenne.event.EventManager)1 DataMap (org.apache.cayenne.map.DataMap)1 EntitySorter (org.apache.cayenne.map.EntitySorter)1