Search in sources :

Example 1 with EmbeddableAttribute

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

the class BoxCellRenderer method setUpdatedValueAt.

@Override
public void setUpdatedValueAt(Object value, int row, int col) {
    EmbeddableAttribute attribute = getEmbeddableAttribute(row);
    if (col == DB_ATTRIBUTE) {
        attribute.setDbAttributeName(value != null ? value.toString() : null);
        fireTableCellUpdated(row, col);
        this.isAttributeOverrideChange = true;
        ((ObjAttributeInfoDialogView) ((ObjAttributeInfoDialog) eventSource).getView()).getSaveButton().setEnabled(true);
        if (value != null) {
            DbEntity currentEnt = ((ObjEntity) attr.getEntity()).getDbEntity();
            if (currentEnt != null) {
                DbAttribute dbAttr = (DbAttribute) currentEnt.getAttribute(value.toString());
                if (dbAttr != null) {
                    fireTableCellUpdated(DB_ATTRIBUTE_TYPE, col);
                }
            }
        }
        fireTableRowsUpdated(row, row);
    }
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) DbEntity(org.apache.cayenne.map.DbEntity) DbAttribute(org.apache.cayenne.map.DbAttribute) EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute)

Example 2 with EmbeddableAttribute

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

the class CreateAttributeAction method performAction.

/**
 * Creates ObjAttribute, DbAttribute depending on context.
 */
@Override
public void performAction(ActionEvent e) {
    ProjectController mediator = getProjectController();
    if (getProjectController().getCurrentEmbeddable() != null) {
        Embeddable embeddable = mediator.getCurrentEmbeddable();
        EmbeddableAttribute attr = new EmbeddableAttribute();
        attr.setName(NameBuilder.builder(attr, embeddable).name());
        createEmbAttribute(embeddable, attr);
        application.getUndoManager().addEdit(new CreateEmbAttributeUndoableEdit(embeddable, new EmbeddableAttribute[] { attr }));
    }
    if (getProjectController().getCurrentObjEntity() != null) {
        ObjEntity objEntity = mediator.getCurrentObjEntity();
        ObjAttribute attr = new ObjAttribute();
        attr.setName(NameBuilder.builder(attr, objEntity).name());
        createObjAttribute(mediator.getCurrentDataMap(), objEntity, attr);
        application.getUndoManager().addEdit(new CreateAttributeUndoableEdit((DataChannelDescriptor) mediator.getProject().getRootNode(), mediator.getCurrentDataMap(), objEntity, attr));
    } else if (getProjectController().getCurrentDbEntity() != null) {
        DbEntity dbEntity = getProjectController().getCurrentDbEntity();
        DbAttribute attr = new DbAttribute();
        attr.setName(NameBuilder.builder(attr, dbEntity).name());
        attr.setType(TypesMapping.NOT_DEFINED);
        attr.setEntity(dbEntity);
        createDbAttribute(mediator.getCurrentDataMap(), dbEntity, attr);
        application.getUndoManager().addEdit(new CreateAttributeUndoableEdit((DataChannelDescriptor) mediator.getProject().getRootNode(), mediator.getCurrentDataMap(), dbEntity, attr));
    }
}
Also used : CreateEmbAttributeUndoableEdit(org.apache.cayenne.modeler.undo.CreateEmbAttributeUndoableEdit) ObjEntity(org.apache.cayenne.map.ObjEntity) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) ObjAttribute(org.apache.cayenne.map.ObjAttribute) DbEntity(org.apache.cayenne.map.DbEntity) CreateAttributeUndoableEdit(org.apache.cayenne.modeler.undo.CreateAttributeUndoableEdit) DbAttribute(org.apache.cayenne.map.DbAttribute) EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute) ProjectController(org.apache.cayenne.modeler.ProjectController) Embeddable(org.apache.cayenne.map.Embeddable)

Example 3 with EmbeddableAttribute

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

the class FindAction method jumpToResult.

/**
 * Navigate to search result
 * Used also in {@link org.apache.cayenne.modeler.graph.action.EntityDisplayAction}
 */
public static void jumpToResult(FindAction.SearchResultEntry searchResultEntry) {
    EditorView editor = ((CayenneModelerFrame) Application.getInstance().getFrameController().getView()).getView();
    DataChannelDescriptor domain = (DataChannelDescriptor) Application.getInstance().getProject().getRootNode();
    if (searchResultEntry.getObject() instanceof Entity) {
        jumpToEntityResult((Entity) searchResultEntry.getObject(), editor, domain);
    } else if (searchResultEntry.getObject() instanceof QueryDescriptor) {
        jumpToQueryResult((QueryDescriptor) searchResultEntry.getObject(), editor, domain);
    } else if (searchResultEntry.getObject() instanceof Embeddable) {
        jumpToEmbeddableResult((Embeddable) searchResultEntry.getObject(), editor, domain);
    } else if (searchResultEntry.getObject() instanceof EmbeddableAttribute) {
        jumpToEmbeddableAttributeResult((EmbeddableAttribute) searchResultEntry.getObject(), editor, domain);
    } else if (searchResultEntry.getObject() instanceof Attribute || searchResultEntry.getObject() instanceof Relationship) {
        jumpToAttributeResult(searchResultEntry, editor, domain);
    }
}
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) EJBQLQueryDescriptor(org.apache.cayenne.map.EJBQLQueryDescriptor) SelectQueryDescriptor(org.apache.cayenne.map.SelectQueryDescriptor) QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) ProcedureQueryDescriptor(org.apache.cayenne.map.ProcedureQueryDescriptor) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) 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) EditorView(org.apache.cayenne.modeler.editor.EditorView) EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute) CayenneModelerFrame(org.apache.cayenne.modeler.CayenneModelerFrame) Embeddable(org.apache.cayenne.map.Embeddable)

Example 4 with EmbeddableAttribute

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

the class ObjAttributeInfoDialog method rebuildTable.

private void rebuildTable() {
    String typeName = null;
    Collection<EmbeddableAttribute> embAttrTempCopy = new ArrayList<>();
    if (attributeSaved.getType() != null) {
        typeName = attributeSaved.getType();
    }
    if (embeddableNames.contains(typeName)) {
        Collection<EmbeddableAttribute> embAttrTemp = stringToEmbeddables.get(typeName).getAttributes();
        for (EmbeddableAttribute temp : embAttrTemp) {
            EmbeddableAttribute at = new EmbeddableAttribute();
            at.setDbAttributeName(temp.getDbAttributeName());
            at.setName(temp.getName());
            at.setType(temp.getType());
            at.setEmbeddable(temp.getEmbeddable());
            embAttrTempCopy.add(at);
        }
    }
    embeddableModel = new OverrideEmbeddableAttributeTableModel(mediator, this, embAttrTempCopy, attributeSaved);
    view.getOverrideAttributeTable().setModel(embeddableModel);
    view.getOverrideAttributeTable().setRowHeight(25);
    view.getOverrideAttributeTable().setRowMargin(3);
    setUpTableStructure();
    if (view.getTypeComboBox().getSelectedItem() == null) {
        lastObjectType = "";
    } else {
        lastObjectType = view.getTypeComboBox().getSelectedItem();
    }
}
Also used : ArrayList(java.util.ArrayList) EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute)

Example 5 with EmbeddableAttribute

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

the class EmbeddableHandler method createEmbeddableAttribute.

private void createEmbeddableAttribute(Attributes attributes) {
    EmbeddableAttribute ea = new EmbeddableAttribute(attributes.getValue("name"));
    ea.setType(attributes.getValue("type"));
    ea.setDbAttributeName(attributes.getValue("db-attribute-name"));
    embeddable.addAttribute(ea);
}
Also used : EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute)

Aggregations

EmbeddableAttribute (org.apache.cayenne.map.EmbeddableAttribute)18 Embeddable (org.apache.cayenne.map.Embeddable)10 DbAttribute (org.apache.cayenne.map.DbAttribute)6 DbEntity (org.apache.cayenne.map.DbEntity)6 ObjEntity (org.apache.cayenne.map.ObjEntity)6 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)5 ObjAttribute (org.apache.cayenne.map.ObjAttribute)5 ProjectController (org.apache.cayenne.modeler.ProjectController)4 DataMap (org.apache.cayenne.map.DataMap)3 DbRelationship (org.apache.cayenne.map.DbRelationship)3 ObjRelationship (org.apache.cayenne.map.ObjRelationship)3 QueryDescriptor (org.apache.cayenne.map.QueryDescriptor)3 EmbeddableAttributeEvent (org.apache.cayenne.map.event.EmbeddableAttributeEvent)3 EmbeddableAttributeDisplayEvent (org.apache.cayenne.modeler.event.EmbeddableAttributeDisplayEvent)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)2 Procedure (org.apache.cayenne.map.Procedure)2 ProcedureParameter (org.apache.cayenne.map.ProcedureParameter)2 ObjCallbackMethod (org.apache.cayenne.modeler.editor.ObjCallbackMethod)2