Search in sources :

Example 61 with ObjEntity

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

the class ObjEntityTab method getDuplicatedAttributes.

private List<ObjAttribute> getDuplicatedAttributes(ObjEntity superEntity) {
    List<ObjAttribute> result = new LinkedList<>();
    ObjEntity entity = mediator.getCurrentObjEntity();
    for (ObjAttribute attribute : entity.getAttributes()) {
        if (superEntity.getAttribute(attribute.getName()) != null) {
            result.add(attribute);
        }
    }
    return result;
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) ObjAttribute(org.apache.cayenne.map.ObjAttribute) LinkedList(java.util.LinkedList)

Example 62 with ObjEntity

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

the class ObjEntityTab method setComment.

private void setComment(String value) {
    ObjEntity entity = mediator.getCurrentObjEntity();
    if (entity == null) {
        return;
    }
    ObjectInfo.putToMetaData(mediator.getApplication().getMetaData(), entity, ObjectInfo.COMMENT, value);
    mediator.fireObjEntityEvent(new EntityEvent(this, entity));
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) EntityEvent(org.apache.cayenne.map.event.EntityEvent)

Example 63 with ObjEntity

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

the class ClassesTabController method getProblem.

/**
 * Returns the first encountered validation problem for an antity matching the name or
 * null if the entity is valid or the entity is not present.
 */
public JLabel getProblem(Object obj) {
    String name = null;
    if (obj instanceof ObjEntity) {
        name = ((ObjEntity) obj).getName();
    } else if (obj instanceof Embeddable) {
        name = ((Embeddable) obj).getClassName();
    }
    ValidationFailure validationFailure = null;
    if (lastValidationResult != null) {
        List<ValidationFailure> failures = lastValidationResult.getFailures(name);
        if (!failures.isEmpty()) {
            validationFailure = failures.get(0);
        }
    }
    JLabel labelIcon = new JLabel();
    labelIcon.setVisible(true);
    if (validationFailure != null) {
        labelIcon.setIcon(ERROR_ICON);
        labelIcon.setToolTipText(validationFailure.getDescription());
    }
    return labelIcon;
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) JLabel(javax.swing.JLabel) Embeddable(org.apache.cayenne.map.Embeddable) ValidationFailure(org.apache.cayenne.validation.ValidationFailure)

Example 64 with ObjEntity

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

the class ClassesTabController method getItemName.

public JLabel getItemName(Object obj) {
    String className;
    Icon icon;
    if (obj instanceof Embeddable) {
        className = ((Embeddable) obj).getClassName();
        icon = CellRenderers.iconForObject(new Embeddable());
    } else if (obj instanceof ObjEntity) {
        className = ((ObjEntity) obj).getName();
        icon = CellRenderers.iconForObject(new ObjEntity());
    } else {
        className = ((DataMap) obj).getName();
        icon = CellRenderers.iconForObject(new DataMap());
    }
    JLabel labelIcon = new JLabel();
    labelIcon.setIcon(icon);
    labelIcon.setVisible(true);
    labelIcon.setText(className);
    return labelIcon;
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) JLabel(javax.swing.JLabel) Icon(javax.swing.Icon) Embeddable(org.apache.cayenne.map.Embeddable) DataMap(org.apache.cayenne.map.DataMap)

Example 65 with ObjEntity

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

the class RawQueryPropertiesPanel method initController.

protected void initController() {
    super.initController();
    dataObjects.addItemListener(e -> setFetchingDataObjects(dataObjects.isSelected()));
    entities.addActionListener(event -> {
        ObjEntity entity = (ObjEntity) entities.getModel().getSelectedItem();
        setEntity(entity);
    });
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity)

Aggregations

ObjEntity (org.apache.cayenne.map.ObjEntity)294 Test (org.junit.Test)110 DbEntity (org.apache.cayenne.map.DbEntity)72 ObjAttribute (org.apache.cayenne.map.ObjAttribute)68 ObjRelationship (org.apache.cayenne.map.ObjRelationship)62 DataMap (org.apache.cayenne.map.DataMap)57 DbAttribute (org.apache.cayenne.map.DbAttribute)37 DbRelationship (org.apache.cayenne.map.DbRelationship)29 CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)27 ObjectId (org.apache.cayenne.ObjectId)26 ClassDescriptor (org.apache.cayenne.reflect.ClassDescriptor)22 ArrayList (java.util.ArrayList)19 Embeddable (org.apache.cayenne.map.Embeddable)18 EntityResolver (org.apache.cayenne.map.EntityResolver)17 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)16 Expression (org.apache.cayenne.exp.Expression)15 Persistent (org.apache.cayenne.Persistent)12 EntityEvent (org.apache.cayenne.map.event.EntityEvent)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)12 Entity (org.apache.cayenne.map.Entity)11