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);
}
}
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 + "() {"));
}
}
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);
}
}
Aggregations