Search in sources :

Example 46 with DataMap

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

the class CreateDbEntityAction method performAction.

/**
 * Creates new DbEntity, adds it to the current DataMap, fires DbEntityEvent and DbEntityDisplayEvent.
 */
public void performAction(ActionEvent e) {
    ProjectController mediator = getProjectController();
    DataMap map = mediator.getCurrentDataMap();
    DbEntity entity = new DbEntity();
    entity.setName(NameBuilder.builder(entity, map).name());
    createEntity(map, entity);
    application.getUndoManager().addEdit(new CreateDbEntityUndoableEdit(map, entity));
}
Also used : CreateDbEntityUndoableEdit(org.apache.cayenne.modeler.undo.CreateDbEntityUndoableEdit) DbEntity(org.apache.cayenne.map.DbEntity) ProjectController(org.apache.cayenne.modeler.ProjectController) DataMap(org.apache.cayenne.map.DataMap)

Example 47 with DataMap

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

the class CreateProcedureAction method performAction.

public void performAction(ActionEvent e) {
    ProjectController mediator = getProjectController();
    DataMap map = mediator.getCurrentDataMap();
    Procedure procedure = new Procedure();
    procedure.setName(NameBuilder.builder(procedure, map).name());
    createProcedure(map, procedure);
    application.getUndoManager().addEdit(new CreateProcedureUndoableEdit(map, procedure));
}
Also used : Procedure(org.apache.cayenne.map.Procedure) ProjectController(org.apache.cayenne.modeler.ProjectController) CreateProcedureUndoableEdit(org.apache.cayenne.modeler.undo.CreateProcedureUndoableEdit) DataMap(org.apache.cayenne.map.DataMap)

Example 48 with DataMap

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

the class BaseGraphBuilder method buildGraph.

@Override
public void buildGraph(ProjectController mediator, DataChannelDescriptor domain, boolean doLayout) {
    if (graph != null) {
        // graph already built, exiting silently
        return;
    }
    graph = new JGraph();
    GraphModel model = new DefaultGraphModel();
    graph.setModel(model);
    setProjectController(mediator);
    setDataDomain(domain);
    GraphLayoutCache view = new GraphLayoutCache(model, new DefaultCellViewFactory());
    graph.setGraphLayoutCache(view);
    addMouseListeners();
    entityCells = new HashMap<>();
    createdObjects = new ArrayList<>();
    relCells = new HashMap<>();
    /*
         * an array for entities that are not connected to anyone. We add them
         * separately so that layout doesn't touch them
         */
    List<DefaultGraphCell> isolatedObjects = new ArrayList<>();
    /*
         * 1. Add all entities
         */
    for (DataMap map : domain.getDataMaps()) {
        DefaultGraphCell mapCell = new DefaultGraphCell();
        createdObjects.add(mapCell);
        for (Entity entity : getEntities(map)) {
            DefaultGraphCell cell = createEntityCell(entity);
            // mapCell.add(cell);
            // cell.setParent(mapCell);
            List<DefaultGraphCell> array = !isIsolated(domain, entity) ? createdObjects : isolatedObjects;
            array.add(cell);
            // port
            array.add((DefaultGraphCell) cell.getChildAt(0));
        }
    }
    /*
         * 2. Add all relationships
         */
    for (DataMap map : domain.getDataMaps()) {
        for (Entity entity : getEntities(map)) {
            DefaultGraphCell sourceCell = entityCells.get(entity.getName());
            postProcessEntity(entity, sourceCell);
        }
    }
    view.insert(createdObjects.toArray());
    setLayout(doLayout);
    /*
         * Adding isolated objects
         * 
         * We're placing them so that they will take maximum space in left top
         * corner. The sample order is below:
         * 
         * 1 2 6 7... 3 5 8 ... 4 9... 10 ...
         */
    addIsolatedObjects(isolatedObjects);
    view.insert(isolatedObjects.toArray());
    graph.getModel().addUndoableEditListener(this);
}
Also used : JGraph(org.jgraph.JGraph) Entity(org.apache.cayenne.map.Entity) DefaultCellViewFactory(org.jgraph.graph.DefaultCellViewFactory) DefaultGraphCell(org.jgraph.graph.DefaultGraphCell) GraphLayoutCache(org.jgraph.graph.GraphLayoutCache) DefaultGraphModel(org.jgraph.graph.DefaultGraphModel) GraphModel(org.jgraph.graph.GraphModel) ArrayList(java.util.ArrayList) DefaultGraphModel(org.jgraph.graph.DefaultGraphModel) DataMap(org.apache.cayenne.map.DataMap)

Example 49 with DataMap

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

the class FindAction method jumpToEmbeddableResult.

private static void jumpToEmbeddableResult(Embeddable embeddable, EditorView editor, DataChannelDescriptor domain) {
    DataMap map = embeddable.getDataMap();
    buildAndSelectTreePath(map, embeddable, editor);
    EmbeddableDisplayEvent event = new EmbeddableDisplayEvent(editor.getProjectTreeView(), embeddable, map, domain);
    event.setMainTabFocus(true);
    editor.currentEmbeddableChanged(event);
}
Also used : EmbeddableDisplayEvent(org.apache.cayenne.modeler.event.EmbeddableDisplayEvent) DataMap(org.apache.cayenne.map.DataMap)

Example 50 with DataMap

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

the class FindAction method search.

private List<SearchResultEntry> search(String searchStr) {
    Pattern pattern = Pattern.compile(searchStr, Pattern.CASE_INSENSITIVE);
    List<SearchResultEntry> result = new ArrayList<>();
    for (DataMap dataMap : ((DataChannelDescriptor) getProjectController().getProject().getRootNode()).getDataMaps()) {
        searchInQueryDescriptors(pattern, result, dataMap);
        searchInEmbeddables(pattern, result, dataMap);
        searchInDbEntities(pattern, result, dataMap);
        searchInObjEntities(pattern, result, dataMap);
    }
    Collections.sort(result);
    return result;
}
Also used : Pattern(java.util.regex.Pattern) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) ArrayList(java.util.ArrayList) 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