@Test public void shouldSetRecordHistoryFlag() { processor.process(AnotherSample.class); verify(crudEventsProcessor).setClazz(AnotherSample.class); verify(crudEventsProcessor).setTrackingDto(trackingDtoCaptor.capture()); verify(crudEventsProcessor).execute(bundle, schemaHolder); TrackingDto trackingDto = trackingDtoCaptor.getValue(); assertFalse(trackingDto.isRecordHistory()); processor.process(Sample.class); verify(crudEventsProcessor).setClazz(Sample.class); verify(crudEventsProcessor, times(2)).setTrackingDto(trackingDtoCaptor.capture()); verify(crudEventsProcessor, times(2)).execute(bundle, schemaHolder); trackingDto = trackingDtoCaptor.getValue(); assertTrue(trackingDto.isRecordHistory()); }
@Override protected void process(AnnotatedElement element) { BundleHeaders bundleHeaders = new BundleHeaders(getBundle()); EntityProcessorOutput entityProcessorOutput = new EntityProcessorOutput(); Class clazz = (Class) element; Class<Entity> ann = ReflectionsUtil.getAnnotationClass(clazz, Entity.class); Annotation annotation = AnnotationUtils.findAnnotation(clazz, ann); if (null != annotation) { String className = clazz.getName(); String name = ReflectionsUtil.getAnnotationValue( annotation, NAME, ClassName.getSimpleName(className) ); String module = ReflectionsUtil.getAnnotationValue( annotation, MODULE, bundleHeaders.getName(), bundleHeaders.getSymbolicName() ); String bundleSymbolicName = getBundle().getSymbolicName(); String namespace = ReflectionsUtil.getAnnotationValue(annotation, NAMESPACE); String tableName = ReflectionsUtil.getAnnotationValue(annotation, TABLE_NAME); boolean recordHistory = Boolean.parseBoolean(ReflectionsUtil.getAnnotationValue(annotation, HISTORY)); boolean nonEditable = Boolean.parseBoolean(ReflectionsUtil.getAnnotationValue(annotation, NON_EDITABLE)); EntityDto entity = getSchemaHolder().getEntityByClassName(className); RestOptionsDto restOptions = new RestOptionsDto(); TrackingDto tracking = new TrackingDto(); Collection<FieldDto> fields; if (entity == null) { LOGGER.debug("Creating DDE for {}", className); entity = new EntityDto( null, className, name, module, namespace, tableName, recordHistory, SecurityMode.EVERYONE, null, null, null, clazz.getSuperclass().getName(), Modifier.isAbstract(clazz.getModifiers()), false, bundleSymbolicName ); } else { LOGGER.debug("DDE for {} already exists, updating if necessary", className); AdvancedSettingsDto advancedSettings = getSchemaHolder().getAdvancedSettings(className); restOptions = advancedSettings.getRestOptions(); tracking = advancedSettings.getTracking(); entity.setBundleSymbolicName(bundleSymbolicName); entity.setModule(module); } if (!tracking.isModifiedByUser()) { tracking.setRecordHistory(recordHistory); tracking.setNonEditable(nonEditable); } setSecurityOptions(element, entity); setMaxFetchDepth(entity, annotation); entityProcessorOutput.setEntityProcessingResult(entity); fields = findFields(clazz, entity); String versionField = getVersionFieldName(clazz); addVersionMetadata(fields, versionField); addDefaultFields(entity, fields); restOptions = processRestOperations(clazz, restOptions); restOptions = findRestFields(clazz, restOptions, fields); updateUiChangedFields(fields, className); updateResults(entityProcessorOutput, clazz, fields, restOptions, tracking, versionField); add(entity); processingResult.add(entityProcessorOutput); MotechClassPool.registerDDE(entity.getClassName()); } else { LOGGER.debug("Did not find Entity annotation in class: {}", clazz.getName()); } }
EntityProcessor extends AbstractListProcessor<Entity, EntityDto> { @Override protected void process(AnnotatedElement element) { BundleHeaders bundleHeaders = new BundleHeaders(getBundle()); EntityProcessorOutput entityProcessorOutput = new EntityProcessorOutput(); Class clazz = (Class) element; Class<Entity> ann = ReflectionsUtil.getAnnotationClass(clazz, Entity.class); Annotation annotation = AnnotationUtils.findAnnotation(clazz, ann); if (null != annotation) { String className = clazz.getName(); String name = ReflectionsUtil.getAnnotationValue( annotation, NAME, ClassName.getSimpleName(className) ); String module = ReflectionsUtil.getAnnotationValue( annotation, MODULE, bundleHeaders.getName(), bundleHeaders.getSymbolicName() ); String bundleSymbolicName = getBundle().getSymbolicName(); String namespace = ReflectionsUtil.getAnnotationValue(annotation, NAMESPACE); String tableName = ReflectionsUtil.getAnnotationValue(annotation, TABLE_NAME); boolean recordHistory = Boolean.parseBoolean(ReflectionsUtil.getAnnotationValue(annotation, HISTORY)); boolean nonEditable = Boolean.parseBoolean(ReflectionsUtil.getAnnotationValue(annotation, NON_EDITABLE)); EntityDto entity = getSchemaHolder().getEntityByClassName(className); RestOptionsDto restOptions = new RestOptionsDto(); TrackingDto tracking = new TrackingDto(); Collection<FieldDto> fields; if (entity == null) { LOGGER.debug("Creating DDE for {}", className); entity = new EntityDto( null, className, name, module, namespace, tableName, recordHistory, SecurityMode.EVERYONE, null, null, null, clazz.getSuperclass().getName(), Modifier.isAbstract(clazz.getModifiers()), false, bundleSymbolicName ); } else { LOGGER.debug("DDE for {} already exists, updating if necessary", className); AdvancedSettingsDto advancedSettings = getSchemaHolder().getAdvancedSettings(className); restOptions = advancedSettings.getRestOptions(); tracking = advancedSettings.getTracking(); entity.setBundleSymbolicName(bundleSymbolicName); entity.setModule(module); } if (!tracking.isModifiedByUser()) { tracking.setRecordHistory(recordHistory); tracking.setNonEditable(nonEditable); } setSecurityOptions(element, entity); setMaxFetchDepth(entity, annotation); entityProcessorOutput.setEntityProcessingResult(entity); fields = findFields(clazz, entity); String versionField = getVersionFieldName(clazz); addVersionMetadata(fields, versionField); addDefaultFields(entity, fields); restOptions = processRestOperations(clazz, restOptions); restOptions = findRestFields(clazz, restOptions, fields); updateUiChangedFields(fields, className); updateResults(entityProcessorOutput, clazz, fields, restOptions, tracking, versionField); add(entity); processingResult.add(entityProcessorOutput); MotechClassPool.registerDDE(entity.getClassName()); } else { LOGGER.debug("Did not find Entity annotation in class: {}", clazz.getName()); } } }
EntityProcessor extends AbstractListProcessor<Entity, EntityDto> { @Override protected void process(AnnotatedElement element) { BundleHeaders bundleHeaders = new BundleHeaders(getBundle()); EntityProcessorOutput entityProcessorOutput = new EntityProcessorOutput(); Class clazz = (Class) element; Class<Entity> ann = ReflectionsUtil.getAnnotationClass(clazz, Entity.class); Annotation annotation = AnnotationUtils.findAnnotation(clazz, ann); if (null != annotation) { String className = clazz.getName(); String name = ReflectionsUtil.getAnnotationValue( annotation, NAME, ClassName.getSimpleName(className) ); String module = ReflectionsUtil.getAnnotationValue( annotation, MODULE, bundleHeaders.getName(), bundleHeaders.getSymbolicName() ); String bundleSymbolicName = getBundle().getSymbolicName(); String namespace = ReflectionsUtil.getAnnotationValue(annotation, NAMESPACE); String tableName = ReflectionsUtil.getAnnotationValue(annotation, TABLE_NAME); boolean recordHistory = Boolean.parseBoolean(ReflectionsUtil.getAnnotationValue(annotation, HISTORY)); boolean nonEditable = Boolean.parseBoolean(ReflectionsUtil.getAnnotationValue(annotation, NON_EDITABLE)); EntityDto entity = getSchemaHolder().getEntityByClassName(className); RestOptionsDto restOptions = new RestOptionsDto(); TrackingDto tracking = new TrackingDto(); Collection<FieldDto> fields; if (entity == null) { LOGGER.debug("Creating DDE for {}", className); entity = new EntityDto( null, className, name, module, namespace, tableName, recordHistory, SecurityMode.EVERYONE, null, null, null, clazz.getSuperclass().getName(), Modifier.isAbstract(clazz.getModifiers()), false, bundleSymbolicName ); } else { LOGGER.debug("DDE for {} already exists, updating if necessary", className); AdvancedSettingsDto advancedSettings = getSchemaHolder().getAdvancedSettings(className); restOptions = advancedSettings.getRestOptions(); tracking = advancedSettings.getTracking(); entity.setBundleSymbolicName(bundleSymbolicName); entity.setModule(module); } if (!tracking.isModifiedByUser()) { tracking.setRecordHistory(recordHistory); tracking.setNonEditable(nonEditable); } setSecurityOptions(element, entity); setMaxFetchDepth(entity, annotation); entityProcessorOutput.setEntityProcessingResult(entity); fields = findFields(clazz, entity); String versionField = getVersionFieldName(clazz); addVersionMetadata(fields, versionField); addDefaultFields(entity, fields); restOptions = processRestOperations(clazz, restOptions); restOptions = findRestFields(clazz, restOptions, fields); updateUiChangedFields(fields, className); updateResults(entityProcessorOutput, clazz, fields, restOptions, tracking, versionField); add(entity); processingResult.add(entityProcessorOutput); MotechClassPool.registerDDE(entity.getClassName()); } else { LOGGER.debug("Did not find Entity annotation in class: {}", clazz.getName()); } }  }
EntityProcessor extends AbstractListProcessor<Entity, EntityDto> { @Override protected void process(AnnotatedElement element) { BundleHeaders bundleHeaders = new BundleHeaders(getBundle()); EntityProcessorOutput entityProcessorOutput = new EntityProcessorOutput(); Class clazz = (Class) element; Class<Entity> ann = ReflectionsUtil.getAnnotationClass(clazz, Entity.class); Annotation annotation = AnnotationUtils.findAnnotation(clazz, ann); if (null != annotation) { String className = clazz.getName(); String name = ReflectionsUtil.getAnnotationValue( annotation, NAME, ClassName.getSimpleName(className) ); String module = ReflectionsUtil.getAnnotationValue( annotation, MODULE, bundleHeaders.getName(), bundleHeaders.getSymbolicName() ); String bundleSymbolicName = getBundle().getSymbolicName(); String namespace = ReflectionsUtil.getAnnotationValue(annotation, NAMESPACE); String tableName = ReflectionsUtil.getAnnotationValue(annotation, TABLE_NAME); boolean recordHistory = Boolean.parseBoolean(ReflectionsUtil.getAnnotationValue(annotation, HISTORY)); boolean nonEditable = Boolean.parseBoolean(ReflectionsUtil.getAnnotationValue(annotation, NON_EDITABLE)); EntityDto entity = getSchemaHolder().getEntityByClassName(className); RestOptionsDto restOptions = new RestOptionsDto(); TrackingDto tracking = new TrackingDto(); Collection<FieldDto> fields; if (entity == null) { LOGGER.debug("Creating DDE for {}", className); entity = new EntityDto( null, className, name, module, namespace, tableName, recordHistory, SecurityMode.EVERYONE, null, null, null, clazz.getSuperclass().getName(), Modifier.isAbstract(clazz.getModifiers()), false, bundleSymbolicName ); } else { LOGGER.debug("DDE for {} already exists, updating if necessary", className); AdvancedSettingsDto advancedSettings = getSchemaHolder().getAdvancedSettings(className); restOptions = advancedSettings.getRestOptions(); tracking = advancedSettings.getTracking(); entity.setBundleSymbolicName(bundleSymbolicName); entity.setModule(module); } if (!tracking.isModifiedByUser()) { tracking.setRecordHistory(recordHistory); tracking.setNonEditable(nonEditable); } setSecurityOptions(element, entity); setMaxFetchDepth(entity, annotation); entityProcessorOutput.setEntityProcessingResult(entity); fields = findFields(clazz, entity); String versionField = getVersionFieldName(clazz); addVersionMetadata(fields, versionField); addDefaultFields(entity, fields); restOptions = processRestOperations(clazz, restOptions); restOptions = findRestFields(clazz, restOptions, fields); updateUiChangedFields(fields, className); updateResults(entityProcessorOutput, clazz, fields, restOptions, tracking, versionField); add(entity); processingResult.add(entityProcessorOutput); MotechClassPool.registerDDE(entity.getClassName()); } else { LOGGER.debug("Did not find Entity annotation in class: {}", clazz.getName()); } }  @Override Class<Entity> getAnnotationType(); @Override List<EntityProcessorOutput> getProcessingResult(); @Autowired void setFieldProcessor(FieldProcessor fieldProcessor); @Autowired void setUIFilterableProcessor(UIFilterableProcessor uiFilterableProcessor); @Autowired void setUIDisplayableProcessor(UIDisplayableProcessor uiDisplayableProcessor); @Autowired void setRestIgnoreProcessor(RestIgnoreProcessor restIgnoreProcessor); @Autowired void setRestOperationsProcessor(RestOperationsProcessor restOperationsProcessor); @Autowired void setCrudEventsProcessor(CrudEventsProcessor crudEventsProcessor); @Autowired void setNonEditableProcessor(NonEditableProcessor nonEditableProcessor); }
EntityProcessor extends AbstractListProcessor<Entity, EntityDto> { @Override protected void process(AnnotatedElement element) { BundleHeaders bundleHeaders = new BundleHeaders(getBundle()); EntityProcessorOutput entityProcessorOutput = new EntityProcessorOutput(); Class clazz = (Class) element; Class<Entity> ann = ReflectionsUtil.getAnnotationClass(clazz, Entity.class); Annotation annotation = AnnotationUtils.findAnnotation(clazz, ann); if (null != annotation) { String className = clazz.getName(); String name = ReflectionsUtil.getAnnotationValue( annotation, NAME, ClassName.getSimpleName(className) ); String module = ReflectionsUtil.getAnnotationValue( annotation, MODULE, bundleHeaders.getName(), bundleHeaders.getSymbolicName() ); String bundleSymbolicName = getBundle().getSymbolicName(); String namespace = ReflectionsUtil.getAnnotationValue(annotation, NAMESPACE); String tableName = ReflectionsUtil.getAnnotationValue(annotation, TABLE_NAME); boolean recordHistory = Boolean.parseBoolean(ReflectionsUtil.getAnnotationValue(annotation, HISTORY)); boolean nonEditable = Boolean.parseBoolean(ReflectionsUtil.getAnnotationValue(annotation, NON_EDITABLE)); EntityDto entity = getSchemaHolder().getEntityByClassName(className); RestOptionsDto restOptions = new RestOptionsDto(); TrackingDto tracking = new TrackingDto(); Collection<FieldDto> fields; if (entity == null) { LOGGER.debug("Creating DDE for {}", className); entity = new EntityDto( null, className, name, module, namespace, tableName, recordHistory, SecurityMode.EVERYONE, null, null, null, clazz.getSuperclass().getName(), Modifier.isAbstract(clazz.getModifiers()), false, bundleSymbolicName ); } else { LOGGER.debug("DDE for {} already exists, updating if necessary", className); AdvancedSettingsDto advancedSettings = getSchemaHolder().getAdvancedSettings(className); restOptions = advancedSettings.getRestOptions(); tracking = advancedSettings.getTracking(); entity.setBundleSymbolicName(bundleSymbolicName); entity.setModule(module); } if (!tracking.isModifiedByUser()) { tracking.setRecordHistory(recordHistory); tracking.setNonEditable(nonEditable); } setSecurityOptions(element, entity); setMaxFetchDepth(entity, annotation); entityProcessorOutput.setEntityProcessingResult(entity); fields = findFields(clazz, entity); String versionField = getVersionFieldName(clazz); addVersionMetadata(fields, versionField); addDefaultFields(entity, fields); restOptions = processRestOperations(clazz, restOptions); restOptions = findRestFields(clazz, restOptions, fields); updateUiChangedFields(fields, className); updateResults(entityProcessorOutput, clazz, fields, restOptions, tracking, versionField); add(entity); processingResult.add(entityProcessorOutput); MotechClassPool.registerDDE(entity.getClassName()); } else { LOGGER.debug("Did not find Entity annotation in class: {}", clazz.getName()); } }  @Override Class<Entity> getAnnotationType(); @Override List<EntityProcessorOutput> getProcessingResult(); @Autowired void setFieldProcessor(FieldProcessor fieldProcessor); @Autowired void setUIFilterableProcessor(UIFilterableProcessor uiFilterableProcessor); @Autowired void setUIDisplayableProcessor(UIDisplayableProcessor uiDisplayableProcessor); @Autowired void setRestIgnoreProcessor(RestIgnoreProcessor restIgnoreProcessor); @Autowired void setRestOperationsProcessor(RestOperationsProcessor restOperationsProcessor); @Autowired void setCrudEventsProcessor(CrudEventsProcessor crudEventsProcessor); @Autowired void setNonEditableProcessor(NonEditableProcessor nonEditableProcessor);  }