Search in sources :

Example 51 with DataMap

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

the class FindAction method jumpToAttributeResult.

private static void jumpToAttributeResult(SearchResultEntry searchResultEntry, EditorView editor, DataChannelDescriptor domain) {
    DataMap map;
    Entity entity;
    if (searchResultEntry.getObject() instanceof Attribute) {
        map = ((Attribute) searchResultEntry.getObject()).getEntity().getDataMap();
        entity = ((Attribute) searchResultEntry.getObject()).getEntity();
    } else {
        map = ((Relationship) searchResultEntry.getObject()).getSourceEntity().getDataMap();
        entity = ((Relationship) searchResultEntry.getObject()).getSourceEntity();
    }
    buildAndSelectTreePath(map, entity, editor);
    if (searchResultEntry.getObject() instanceof Attribute) {
        AttributeDisplayEvent event = new AttributeDisplayEvent(editor.getProjectTreeView(), (Attribute) searchResultEntry.getObject(), entity, map, domain);
        event.setMainTabFocus(true);
        if (searchResultEntry.getObject() instanceof DbAttribute) {
            editor.getDbDetailView().currentDbAttributeChanged(event);
        } else {
            editor.getObjDetailView().currentObjAttributeChanged(event);
        }
    } else if (searchResultEntry.getObject() instanceof Relationship) {
        RelationshipDisplayEvent event = new RelationshipDisplayEvent(editor.getProjectTreeView(), (Relationship) searchResultEntry.getObject(), entity, map, domain);
        event.setMainTabFocus(true);
        if (searchResultEntry.getObject() instanceof DbRelationship) {
            editor.getDbDetailView().currentDbRelationshipChanged(event);
        } else {
            editor.getObjDetailView().currentObjRelationshipChanged(event);
        }
    }
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) DetectedDbEntity(org.apache.cayenne.map.DetectedDbEntity) Entity(org.apache.cayenne.map.Entity) DbEntity(org.apache.cayenne.map.DbEntity) EmbeddableAttributeDisplayEvent(org.apache.cayenne.modeler.event.EmbeddableAttributeDisplayEvent) AttributeDisplayEvent(org.apache.cayenne.modeler.event.AttributeDisplayEvent) DbAttribute(org.apache.cayenne.map.DbAttribute) ObjAttribute(org.apache.cayenne.map.ObjAttribute) Attribute(org.apache.cayenne.map.Attribute) EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute) Relationship(org.apache.cayenne.map.Relationship) DbRelationship(org.apache.cayenne.map.DbRelationship) ObjRelationship(org.apache.cayenne.map.ObjRelationship) DbRelationship(org.apache.cayenne.map.DbRelationship) DbAttribute(org.apache.cayenne.map.DbAttribute) DataMap(org.apache.cayenne.map.DataMap) RelationshipDisplayEvent(org.apache.cayenne.modeler.event.RelationshipDisplayEvent)

Example 52 with DataMap

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

the class GenerateCodeAction method performAction.

public void performAction(ActionEvent e) {
    Collection<DataMap> dataMaps;
    DataMap dataMap = getProjectController().getCurrentDataMap();
    if (dataMap != null) {
        dataMaps = new ArrayList<>();
        dataMaps.add(dataMap);
        new CodeGeneratorController(getApplication().getFrameController(), dataMaps).startup();
    } else if (getProjectController().getCurrentDataNode() != null) {
        Collection<String> nodeMaps = getProjectController().getCurrentDataNode().getDataMapNames();
        Project project = getProjectController().getProject();
        dataMaps = ((DataChannelDescriptor) project.getRootNode()).getDataMaps();
        Collection<DataMap> resultMaps = new ArrayList<>();
        for (DataMap map : dataMaps) {
            if (nodeMaps.contains(map.getName())) {
                resultMaps.add(map);
            }
        }
        new CodeGeneratorController(getApplication().getFrameController(), resultMaps).startup();
    } else {
        Project project = getProjectController().getProject();
        dataMaps = ((DataChannelDescriptor) project.getRootNode()).getDataMaps();
        new CodeGeneratorController(getApplication().getFrameController(), dataMaps).startup();
    }
}
Also used : Project(org.apache.cayenne.project.Project) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) CodeGeneratorController(org.apache.cayenne.modeler.dialog.codegen.CodeGeneratorController) Collection(java.util.Collection) DataMap(org.apache.cayenne.map.DataMap)

Example 53 with DataMap

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

the class GenerateDBAction method performAction.

public void performAction(ActionEvent e) {
    Collection<DataMap> dataMaps;
    DataMap dataMap = getProjectController().getCurrentDataMap();
    if (dataMap != null) {
        dataMaps = new ArrayList<>();
        dataMaps.add(dataMap);
    } else {
        Project project = getProjectController().getProject();
        dataMaps = ((DataChannelDescriptor) project.getRootNode()).getDataMaps();
    }
    new DBGeneratorOptions(getProjectController(), "Generate DB Schema: Options", dataMaps).startupAction();
}
Also used : Project(org.apache.cayenne.project.Project) DBGeneratorOptions(org.apache.cayenne.modeler.dialog.db.gen.DBGeneratorOptions) DataMap(org.apache.cayenne.map.DataMap)

Example 54 with DataMap

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

the class LinkDataMapsAction method performAction.

@Override
public void performAction(ActionEvent e) {
    ProjectController mediator = getProjectController();
    DataChannelDescriptor dataChannelDescriptor = (DataChannelDescriptor) mediator.getProject().getRootNode();
    Collection<String> linkedDataMaps = new ArrayList<>();
    DataNodeDescriptor dataNodeDescriptor = mediator.getCurrentDataNode();
    for (DataNodeDescriptor dataNodeDesc : dataChannelDescriptor.getNodeDescriptors()) {
        linkedDataMaps.addAll(dataNodeDesc.getDataMapNames());
    }
    for (DataMap dataMap : dataChannelDescriptor.getDataMaps()) {
        if (!linkedDataMaps.contains(dataMap.getName())) {
            dataNodeDescriptor.getDataMapNames().add(dataMap.getName());
            mediator.fireDataNodeEvent(new DataNodeEvent(this, dataNodeDescriptor));
        }
    }
    application.getUndoManager().addEdit(new LinkDataMapsUndoableEdit(dataNodeDescriptor, linkedDataMaps, mediator));
}
Also used : DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) DataNodeEvent(org.apache.cayenne.configuration.event.DataNodeEvent) ArrayList(java.util.ArrayList) LinkDataMapsUndoableEdit(org.apache.cayenne.modeler.undo.LinkDataMapsUndoableEdit) DataNodeDescriptor(org.apache.cayenne.configuration.DataNodeDescriptor) ProjectController(org.apache.cayenne.modeler.ProjectController) DataMap(org.apache.cayenne.map.DataMap)

Example 55 with DataMap

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

the class MigrateAction method performAction.

public void performAction(ActionEvent e) {
    DataSourceWizard connectWizard = dataSourceWizardDialog("Migrate DB Schema: Connect to Database");
    if (connectWizard == null) {
        return;
    }
    DataMap map = getProjectController().getCurrentDataMap();
    if (map == null) {
        throw new IllegalStateException("No current DataMap selected.");
    }
    dialogShown = false;
    DbActionOptionsDialog optionsDialog = loaderOptionDialog(connectWizard);
    if (dialogShown && optionsDialog == null) {
        return;
    }
    String selectedCatalog = optionsDialog == null ? null : optionsDialog.getSelectedCatalog();
    String selectedSchema = optionsDialog == null ? null : optionsDialog.getSelectedSchema();
    MergerTokenFactoryProvider mergerTokenFactoryProvider = getApplication().getInjector().getInstance(MergerTokenFactoryProvider.class);
    // ... show dialog...
    new MergerOptions(getProjectController(), "Migrate DB Schema: Options", connectWizard.getConnectionInfo(), map, selectedCatalog, selectedSchema, mergerTokenFactoryProvider).startupAction();
}
Also used : DataSourceWizard(org.apache.cayenne.modeler.dialog.db.DataSourceWizard) MergerTokenFactoryProvider(org.apache.cayenne.dbsync.merge.factory.MergerTokenFactoryProvider) MergerOptions(org.apache.cayenne.modeler.dialog.db.merge.MergerOptions) DbActionOptionsDialog(org.apache.cayenne.modeler.dialog.db.DbActionOptionsDialog) 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