Search in sources :

Example 41 with DataMap

use of org.apache.cayenne.map.DataMap in project cayenne by apache.

the class ProjectController method updateEntityResolver.

public void updateEntityResolver() {
    Collection<DataMap> dataMaps = ((DataChannelDescriptor) project.getRootNode()).getDataMaps();
    entityResolver.setDataMaps(dataMaps);
    for (DataMap dataMap : dataMaps) {
        dataMap.setNamespace(entityResolver);
    }
}
Also used : DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) DataMap(org.apache.cayenne.map.DataMap)

Example 42 with DataMap

use of org.apache.cayenne.map.DataMap in project cayenne by apache.

the class ProjectController method getDataMapPreferences.

/**
 * Returns preferences object for the current DataMap. If no preferences
 * exist for the current DataMap, a new Preferences object is created. If no
 * DataMap is currently selected, an exception is thrown. An optional
 * nameSuffix allows to address more than one defaults instance for a single
 * DataMap.
 */
public DataMapDefaults getDataMapPreferences(String nameSuffix) {
    DataMap map = getCurrentDataMap();
    if (map == null) {
        throw new CayenneRuntimeException("No DataMap selected");
    }
    Preferences pref;
    if (nameSuffix == null || nameSuffix.length() == 0) {
        pref = getPreferenceForDataDomain().node("DataMap").node(map.getName());
    } else {
        pref = getPreferenceForDataDomain().node("DataMap").node(map.getName()).node(nameSuffix);
    }
    return (DataMapDefaults) application.getCayenneProjectPreferences().getProjectDetailObject(DataMapDefaults.class, pref);
}
Also used : CayenneRuntimeException(org.apache.cayenne.CayenneRuntimeException) DataMapDefaults(org.apache.cayenne.modeler.pref.DataMapDefaults) ProjectStatePreferences(org.apache.cayenne.modeler.pref.ProjectStatePreferences) Preferences(java.util.prefs.Preferences) DataMap(org.apache.cayenne.map.DataMap)

Example 43 with DataMap

use of org.apache.cayenne.map.DataMap in project cayenne by apache.

the class ProjectController method getEmbeddablesInCurrentDataDomain.

public ArrayList<Embeddable> getEmbeddablesInCurrentDataDomain() {
    DataChannelDescriptor dataChannelDescriptor = (DataChannelDescriptor) getProject().getRootNode();
    Collection<DataMap> maps = dataChannelDescriptor.getDataMaps();
    Iterator<DataMap> it = maps.iterator();
    ArrayList<Embeddable> embs = new ArrayList<>();
    while (it.hasNext()) {
        embs.addAll(it.next().getEmbeddables());
    }
    return embs;
}
Also used : DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) ArrayList(java.util.ArrayList) DataMap(org.apache.cayenne.map.DataMap) Embeddable(org.apache.cayenne.map.Embeddable)

Example 44 with DataMap

use of org.apache.cayenne.map.DataMap in project cayenne by apache.

the class ProjectFileChangeTracker method reconfigure.

/**
 * Reloads files to watch from the project. Useful when project's structure
 * has changed
 */
public void reconfigure() {
    pauseWatching();
    removeAllFiles();
    Project project = mediator.getProject();
    // check if project exists and has been saved at least once.
    if (project != null && project.getConfigurationResource() != null) {
        String projectPath = project.getConfigurationResource().getURL().getPath() + File.separator;
        addFile(projectPath);
        Iterator<DataMap> it = ((DataChannelDescriptor) project.getRootNode()).getDataMaps().iterator();
        while (it.hasNext()) {
            DataMap dm = it.next();
            if (dm.getConfigurationSource() != null) {
                // if DataMap is in separate file, monitor it
                addFile(dm.getConfigurationSource().getURL().getPath());
            }
        }
    }
    resumeWatching();
}
Also used : Project(org.apache.cayenne.project.Project) DataMap(org.apache.cayenne.map.DataMap)

Example 45 with DataMap

use of org.apache.cayenne.map.DataMap in project cayenne by apache.

the class TreeDragSource method dragOver.

public void dragOver(DragSourceDragEvent dsde) {
    TreePath sourcePath = sourceTree.getSelectionPath();
    DefaultMutableTreeNode sourceParent = (DefaultMutableTreeNode) sourcePath.getLastPathComponent();
    TreePath path = dt.getPath();
    if (path == null) {
        dsde.getDragSourceContext().setCursor(DragSource.DefaultLinkNoDrop);
        return;
    }
    DefaultMutableTreeNode parent = (DefaultMutableTreeNode) path.getLastPathComponent();
    if (sourceParent.getUserObject() instanceof DataMap && parent.getUserObject() instanceof DataNodeDescriptor) {
        dsde.getDragSourceContext().setCursor(DragSource.DefaultLinkDrop);
    } else {
        dsde.getDragSourceContext().setCursor(DragSource.DefaultLinkNoDrop);
    }
}
Also used : TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DataNodeDescriptor(org.apache.cayenne.configuration.DataNodeDescriptor) DataMap(org.apache.cayenne.map.DataMap)

Aggregations

DataMap (org.apache.cayenne.map.DataMap)233 Test (org.junit.Test)88 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)48 DbEntity (org.apache.cayenne.map.DbEntity)48 ObjEntity (org.apache.cayenne.map.ObjEntity)45 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)22 URL (java.net.URL)21 URLResource (org.apache.cayenne.resource.URLResource)20 ArrayList (java.util.ArrayList)19 CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)19 MergerToken (org.apache.cayenne.dbsync.merge.token.MergerToken)17 QueryDescriptor (org.apache.cayenne.map.QueryDescriptor)16 DataMapEvent (org.apache.cayenne.configuration.event.DataMapEvent)15 File (java.io.File)14 Procedure (org.apache.cayenne.map.Procedure)14 Embeddable (org.apache.cayenne.map.Embeddable)13 Injector (org.apache.cayenne.di.Injector)12 DbAttribute (org.apache.cayenne.map.DbAttribute)11 EntityResolver (org.apache.cayenne.map.EntityResolver)11 Entity (org.apache.cayenne.map.Entity)10