Search in sources :

Example 1 with CallbackDescriptor

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

the class AbstractCallbackMethodsTab method rebuildTables.

/**
 * rebuilds table content
 */
protected void rebuildTables() {
    CallbackMap callbackMap = getCallbackMap();
    for (int i = 0; i < callbackTypes.length; i++) {
        CallbackType callbackType = callbackTypes[i];
        List<String> methods = new ArrayList<>();
        CallbackDescriptor descriptor = null;
        if (callbackMap != null && callbackType != null) {
            descriptor = callbackMap.getCallbackDescriptor(callbackType.getType());
            methods.addAll(descriptor.getCallbackMethods());
        }
        CallbackDescriptorTableModel model = new CallbackDescriptorTableModel(mediator, this, methods, descriptor, callbackType);
        tables[i].setModel(model);
    }
    for (CayenneTable table : tables) {
        tablePreferences.bind(table, MIN_SIZES, null, null);
    }
}
Also used : CayenneTable(org.apache.cayenne.modeler.util.CayenneTable) CallbackDescriptor(org.apache.cayenne.map.CallbackDescriptor) ArrayList(java.util.ArrayList) CallbackMap(org.apache.cayenne.map.CallbackMap)

Example 2 with CallbackDescriptor

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

the class ClassGenerationActionTest method assertCallbacks.

private void assertCallbacks(boolean isClient) throws Exception {
    ObjEntity testEntity1 = new ObjEntity("TE1");
    testEntity1.setClassName("org.example.TestClass1");
    int i = 0;
    for (CallbackDescriptor cb : testEntity1.getCallbackMap().getCallbacks()) {
        cb.addCallbackMethod("cb" + i++);
    }
    if (isClient) {
        cgenConfiguration.setClient(true);
        action = new TestClassGenerationAction(getUnitTestInjector().getInstance(ClassGenerationActionFactory.class).createAction(cgenConfiguration), writers);
    }
    cgenConfiguration.setMakePairs(true);
    List<String> generated = execute(new EntityArtifact(testEntity1));
    assertNotNull(generated);
    assertEquals(2, generated.size());
    String superclass = generated.get(0);
    assertTrue(superclass, superclass.contains("public abstract class _TestClass1"));
    for (int j = 0; j < i; j++) {
        assertTrue(superclass, superclass.contains("protected abstract void cb" + j + "();"));
    }
    String subclass = generated.get(1);
    for (int j = 0; j < i; j++) {
        assertTrue(subclass, subclass.contains("protected void cb" + j + "() {"));
    }
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) TestClassGenerationAction(org.apache.cayenne.gen.mock.TestClassGenerationAction) CallbackDescriptor(org.apache.cayenne.map.CallbackDescriptor)

Example 3 with CallbackDescriptor

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

the class ObjEntityHandler method createCallback.

private void createCallback(String type, Attributes attributes) {
    String methodName = attributes.getValue("method-name");
    CallbackDescriptor descriptor = getCallbackDescriptor(type);
    if (descriptor != null) {
        descriptor.addCallbackMethod(methodName);
    }
}
Also used : CallbackDescriptor(org.apache.cayenne.map.CallbackDescriptor)

Aggregations

CallbackDescriptor (org.apache.cayenne.map.CallbackDescriptor)3 ArrayList (java.util.ArrayList)1 TestClassGenerationAction (org.apache.cayenne.gen.mock.TestClassGenerationAction)1 CallbackMap (org.apache.cayenne.map.CallbackMap)1 ObjEntity (org.apache.cayenne.map.ObjEntity)1 CayenneTable (org.apache.cayenne.modeler.util.CayenneTable)1