From 928eddf9245d64d321991db01aebda48584fb78d Mon Sep 17 00:00:00 2001 From: gorefest Date: Fri, 18 Oct 2013 19:03:07 +0200 Subject: [PATCH 01/16] version corrected --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 379ad59..25fab82 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ 4.0.1.2 3.6.0 UTF-8 - 0.6.2-SNAPSHOT + 0.6 From 9488278f26a6f648a21e623697cb74d84f190846 Mon Sep 17 00:00:00 2001 From: gorefest Date: Wed, 23 Oct 2013 09:47:44 +0200 Subject: [PATCH 02/16] tutorial 4 : IOC and DI --- ..._baracus_baracus_framework_apklib_0_6.xml} | 8 +- baracus-tutorial.iml | 3 +- .../AndroidManifest.xml | 6 - .../META-INF/MANIFEST.MF | 4 - .../gen/net/mantucon/baracus/BuildConfig.java | 8 - .../gen/net/mantucon/baracus/Manifest.java | 7 - .../gen/net/mantucon/baracus/R.java | 7 - .../res/values/attrs.xml | 12 - .../res/values/strings.xml | 9 - .../mantucon/baracus/annotations/Bean.java | 18 - .../baracus/context/AnnotationScanner.java | 85 --- .../context/BaracusApplicationContext.java | 709 ------------------ .../baracus/context/BeanContainer.java | 388 ---------- .../mantucon/baracus/context/Exceptions.java | 35 - .../baracus/context/ManagedActivity.java | 30 - .../baracus/context/ManagedFragment.java | 57 -- .../baracus/dao/BaracusOpenHelper.java | 186 ----- .../src/net/mantucon/baracus/dao/BaseDao.java | 390 ---------- .../baracus/dao/ConfigurationDao.java | 75 -- .../mantucon/baracus/dao/PersistenceModel.uml | 13 - .../errorhandling/CustomErrorHandler.java | 28 - .../baracus/errorhandling/ErrorHandler.java | 39 - .../errorhandling/ErrorHandlingFactory.java | 228 ------ .../baracus/errorhandling/ErrorSeverity.java | 14 - .../errorhandling/StandardErrorHandler.java | 26 - .../errorhandling/TextEditErrorHandler.java | 40 - .../baracus/lifecycle/Destroyable.java | 18 - .../baracus/lifecycle/Initializeable.java | 20 - .../mantucon/baracus/migr8/MigrationStep.java | 30 - .../baracus/migr8/ModelVersion000.java | 30 - .../baracus/model/ConfigurationParameter.java | 85 --- .../baracus/orm/AbstractModelBase.java | 160 ---- .../src/net/mantucon/baracus/orm/Field.java | 84 --- .../net/mantucon/baracus/orm/FieldList.java | 163 ---- .../mantucon/baracus/orm/Identifiable.java | 19 - .../mantucon/baracus/orm/LazyCollection.java | 190 ----- .../mantucon/baracus/orm/LazyReference.java | 51 -- .../mantucon/baracus/orm/ObjectReference.java | 36 - .../net/mantucon/baracus/orm/Reference.java | 22 - .../mantucon/baracus/orm/ReferenceLoader.java | 42 -- .../net/mantucon/baracus/orm/Timestamped.java | 20 - .../ConfigurationChangeListener.java | 27 - .../signalling/DataChangeAwareComponent.java | 17 - .../DataSetChangeAwareComponent.java | 17 - .../signalling/DeleteAwareComponent.java | 14 - .../baracus/signalling/GenericEvent.java | 11 - .../GenericEventAwareComponent.java | 12 - .../baracus/ui/ConstrainedEditText.java | 66 -- .../net/mantucon/baracus/ui/ErrorView.java | 107 --- .../net/mantucon/baracus/util/DBBackup.java | 175 ----- .../net/mantucon/baracus/util/DateUtil.java | 95 --- .../src/net/mantucon/baracus/util/Logger.java | 324 -------- .../net/mantucon/baracus/util/StringUtil.java | 150 ---- .../baracus/validation/AbstractValidator.java | 27 - .../baracus/validation/ConstrainedView.java | 15 - .../baracus/validation/ValidatableView.java | 18 - .../baracus/validation/ValidationFactory.java | 200 ----- .../baracus/validation/Validator.java | 25 - .../validation/builtins/DateFromNow.java | 60 -- .../builtins/NumberMustBeGreaterThanZero.java | 57 -- .../builtins/StringIsNumericDouble.java | 51 -- .../builtins/StringIsNumericInteger.java | 50 -- .../validation/builtins/StringNotEmpty.java | 37 - ...mantucon.baracus_baracus-framework_0.6.iml | 41 + .../baracus/HelloAndroidActivity.java | 3 + .../application/ApplicationContext.java | 3 + .../baracus/service/ConfigurationService.java | 76 ++ 67 files changed, 129 insertions(+), 4944 deletions(-) rename .idea/libraries/{Maven__net_mantucon_baracus_baracus_framework_apklib_0_6_2_SNAPSHOT.xml => Maven__net_mantucon_baracus_baracus_framework_apklib_0_6.xml} (59%) delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/AndroidManifest.xml delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/META-INF/MANIFEST.MF delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/gen/net/mantucon/baracus/BuildConfig.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/gen/net/mantucon/baracus/Manifest.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/gen/net/mantucon/baracus/R.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/res/values/attrs.xml delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/res/values/strings.xml delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/annotations/Bean.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/AnnotationScanner.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/BaracusApplicationContext.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/BeanContainer.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/Exceptions.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/ManagedActivity.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/ManagedFragment.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/BaracusOpenHelper.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/BaseDao.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/ConfigurationDao.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/PersistenceModel.uml delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/CustomErrorHandler.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/ErrorHandler.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/ErrorHandlingFactory.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/ErrorSeverity.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/StandardErrorHandler.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/TextEditErrorHandler.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/lifecycle/Destroyable.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/lifecycle/Initializeable.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/migr8/MigrationStep.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/migr8/ModelVersion000.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/model/ConfigurationParameter.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/AbstractModelBase.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/Field.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/FieldList.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/Identifiable.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/LazyCollection.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/LazyReference.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/ObjectReference.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/Reference.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/ReferenceLoader.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/Timestamped.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/ConfigurationChangeListener.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/DataChangeAwareComponent.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/DataSetChangeAwareComponent.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/DeleteAwareComponent.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/GenericEvent.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/GenericEventAwareComponent.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/ui/ConstrainedEditText.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/ui/ErrorView.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/util/DBBackup.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/util/DateUtil.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/util/Logger.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/util/StringUtil.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/AbstractValidator.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/ConstrainedView.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/ValidatableView.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/ValidationFactory.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/Validator.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/builtins/DateFromNow.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/builtins/NumberMustBeGreaterThanZero.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/builtins/StringIsNumericDouble.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/builtins/StringIsNumericInteger.java delete mode 100644 gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/builtins/StringNotEmpty.java create mode 100644 gen-external-apklibs/~apklib-net.mantucon.baracus_baracus-framework_0.6.iml create mode 100644 src/main/java/net/mantucon/baracus/service/ConfigurationService.java diff --git a/.idea/libraries/Maven__net_mantucon_baracus_baracus_framework_apklib_0_6_2_SNAPSHOT.xml b/.idea/libraries/Maven__net_mantucon_baracus_baracus_framework_apklib_0_6.xml similarity index 59% rename from .idea/libraries/Maven__net_mantucon_baracus_baracus_framework_apklib_0_6_2_SNAPSHOT.xml rename to .idea/libraries/Maven__net_mantucon_baracus_baracus_framework_apklib_0_6.xml index 9268027..323ab79 100644 --- a/.idea/libraries/Maven__net_mantucon_baracus_baracus_framework_apklib_0_6_2_SNAPSHOT.xml +++ b/.idea/libraries/Maven__net_mantucon_baracus_baracus_framework_apklib_0_6.xml @@ -1,13 +1,13 @@ - + - + - + - + \ No newline at end of file diff --git a/baracus-tutorial.iml b/baracus-tutorial.iml index 7d84ed9..180ead6 100644 --- a/baracus-tutorial.iml +++ b/baracus-tutorial.iml @@ -22,6 +22,7 @@ + @@ -34,7 +35,7 @@ - + diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/AndroidManifest.xml b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/AndroidManifest.xml deleted file mode 100644 index c2e380f..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/AndroidManifest.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/META-INF/MANIFEST.MF b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/META-INF/MANIFEST.MF deleted file mode 100644 index 48b2803..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/META-INF/MANIFEST.MF +++ /dev/null @@ -1,4 +0,0 @@ -Manifest-Version: 1.0 -Archiver-Version: Plexus Archiver -Created-By: 22.0-b10 (Oracle Corporation) - diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/gen/net/mantucon/baracus/BuildConfig.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/gen/net/mantucon/baracus/BuildConfig.java deleted file mode 100644 index 2e4a184..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/gen/net/mantucon/baracus/BuildConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -/*___Generated_by_IDEA___*/ - -/** Automatically generated file. DO NOT MODIFY */ -package net.mantucon.baracus; - -public final class BuildConfig { - public final static boolean DEBUG = true; -} \ No newline at end of file diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/gen/net/mantucon/baracus/Manifest.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/gen/net/mantucon/baracus/Manifest.java deleted file mode 100644 index 1a69e1d..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/gen/net/mantucon/baracus/Manifest.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package net.mantucon.baracus; - -/* This stub is for using by IDE only. It is NOT the Manifest class actually packed into APK */ -public final class Manifest { -} \ No newline at end of file diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/gen/net/mantucon/baracus/R.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/gen/net/mantucon/baracus/R.java deleted file mode 100644 index d403991..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/gen/net/mantucon/baracus/R.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package net.mantucon.baracus; - -/* This stub is for using by IDE only. It is NOT the R class actually packed into APK */ -public final class R { -} \ No newline at end of file diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/res/values/attrs.xml b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/res/values/attrs.xml deleted file mode 100644 index 7eb4f32..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/res/values/attrs.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/res/values/strings.xml b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/res/values/strings.xml deleted file mode 100644 index 63f815e..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/res/values/strings.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - This field must not be empty - $1 is not an integer - $1 is not a decimal number - Number must be greater than zero - The date must not be before today - - \ No newline at end of file diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/annotations/Bean.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/annotations/Bean.java deleted file mode 100644 index f075599..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/annotations/Bean.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.mantucon.baracus.annotations; - -/** - * - * Bean annotation denoting a bean as a component or a variable as an injection target.

- * - * - * Because baracus relies on type based injection - * this annotation has only a documentary character - * in order to enable you to mark variables a bean injection - * targets. If you leave it out, it has no effect on the injection - * process which is relying on types.
- * - * Use this bean to document components and injection targets as well. - * - */ -public @interface Bean { -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/AnnotationScanner.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/AnnotationScanner.java deleted file mode 100644 index 3d9c938..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/AnnotationScanner.java +++ /dev/null @@ -1,85 +0,0 @@ -package net.mantucon.baracus.context; - -import android.content.Context; -import android.content.ContextWrapper; -import dalvik.system.DexClassLoader; -import dalvik.system.DexFile; -import dalvik.system.PathClassLoader; -import net.mantucon.baracus.util.Logger; - -import java.io.IOException; -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.List; - -/** - * Annotation scanner - * - * Disfunctional on some android versions. do not use yet! - * - */ - -@Deprecated -public class AnnotationScanner { - - private AnnotationScanner() { } - - private static final Logger logger = new Logger(AnnotationScanner.class); - - public static List> getClassesAnnotatedWith(Class theAnnotation, Context context){ - - // In theory, the class loader is not required to be a PathClassLoader - Field field = null; - List> candidates = new ArrayList>(); - String sourceDir = context.getApplicationInfo().sourceDir; - try { - DexFile dex = new DexFile(sourceDir); - PathClassLoader classLoader2 = new PathClassLoader(sourceDir, Thread.currentThread().getContextClassLoader()); - DexClassLoader classLoader = new DexClassLoader(sourceDir, new ContextWrapper(context).getCacheDir().getAbsolutePath(), null, classLoader2); - - Enumeration entries = dex.entries(); - while (entries.hasMoreElements()) { - // Each entry is a class name, like "foo.bar.MyClass" - String entry = entries.nextElement(); - if (!entry.contains("$")) { - - try { - // Load the class -// Class entryClass = dex.loadClass(entry, classLoader); - Class entryClass = classLoader.loadClass(entry);//dexFile.loadClass(entry, classLoader); - - logger.debug("FOUND CLASS $1", entry); - if (entryClass == null) { - logger.error("WARNING! Class of $1 is NULL!",entry); - } - if (entryClass != null && entryClass.getAnnotation(theAnnotation) != null) { - logger.error("ADDED CLASS " + entryClass.getName()); - candidates.add(entryClass); - } - }catch (IllegalAccessError e) { - logger.error("Exception during scan on $1",entry); - } - } - } - - }catch (IOException e ) { - throw new RuntimeException(e); - }catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - return candidates; - } - - public static boolean carriesAnnotation(Class clazz, Class annotation) { - for (Annotation a : clazz.getAnnotations()) { - logger.error("$1 carries $2",clazz.getSimpleName(),a.getClass().getName()); - if (a.getClass().getName().equals(annotation.getName())) { - return true; - } - } - return false; - } - -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/BaracusApplicationContext.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/BaracusApplicationContext.java deleted file mode 100644 index d3325a1..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/BaracusApplicationContext.java +++ /dev/null @@ -1,709 +0,0 @@ -package net.mantucon.baracus.context; - -import android.R; -import android.app.Activity; -import android.app.Application; -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.os.Bundle; -import android.view.View; -import android.widget.TextView; -import net.mantucon.baracus.dao.BaracusOpenHelper; -import net.mantucon.baracus.dao.ConfigurationDao; -import net.mantucon.baracus.errorhandling.CustomErrorHandler; -import net.mantucon.baracus.errorhandling.ErrorHandlingFactory; -import net.mantucon.baracus.errorhandling.ErrorSeverity; -import net.mantucon.baracus.errorhandling.StandardErrorHandler; -import net.mantucon.baracus.orm.AbstractModelBase; -import net.mantucon.baracus.signalling.*; -import net.mantucon.baracus.util.Logger; -import net.mantucon.baracus.validation.ValidationFactory; -import net.mantucon.baracus.validation.Validator; -import sun.misc.MessageUtils; - -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.util.*; - -import static net.mantucon.baracus.util.StringUtil.join; - -/** - * Created with IntelliJ IDEA.
- * User: marcus
- * Date: 10.07.12
- * Time: 06:05
- *
- * - * Base Application Context class. In order to use BARACUS you must inherit this class. - * use the registerBeanClass() function to add all Your bean classes. Implement Initializable and - * Destroyable interface in order to have creation / destruction lifecycle management support. - * - *
- * Example Context Implementation : -
- {@code
-
- public class ApplicationContext extends BaracusApplicationContext{
-
- static {
-    registerBeanClass(BankDao.class);
-    ...
- }
-
-
- private static final Logger logger = new Logger(ApplicationContext.class);
-
- private ApplicationContext() {
- // protection constructor
- }
-
-
- }
-
- To make use of Your class as an app container, You must register it in the
- AndroidManifest.xml's application tag :
-
- {@code
-
- 
-
-
- }
-
- 
- - * - */ -public abstract class BaracusApplicationContext extends Application { - - // infrastructure beans - - // DB Access - private static SQLiteDatabase db; - private static BaracusOpenHelper baracusOpenHelper; - - - private static boolean semaphore = false; - private static int refCount = 0; - - // Awareness Refs, event handlers - protected final static Map, DeleteAwareComponent> deleteListeners = new HashMap, DeleteAwareComponent>(); - protected final static Map, DataSetChangeAwareComponent> changeListener = new HashMap, DataSetChangeAwareComponent>(); - protected final static Map, Set> dataListener = new HashMap, Set>(); - protected final static Map, Set>> eventConsumers = new HashMap, Set>>(); - - private static final Logger logger = new Logger(BaracusApplicationContext.class); - - private static volatile BaracusApplicationContext __instance = null; - - private static ActivityLifecycleCallbacks callbacks; - - private static final BeanContainer beanContainer = new BeanContainer(); - - private static ValidationFactory validationFactory; - private static ErrorHandlingFactory errorHandlingFactory; - - - static{ - registerBeanClass(ConfigurationDao.class); - registerBeanClass(ValidationFactory.class); - registerBeanClass(ErrorHandlingFactory.class); - } - - private static String databasePath; - - public BaracusApplicationContext() { - if (__instance != null) { - throw new ContainerAlreadyStartedException(); - } - __instance = this; - make(); - } - - /** - * Context is not built up yet - */ - public static class ContextNotYetCreatedException extends RuntimeException { - ContextNotYetCreatedException (String reason) { - super(reason); - } - } - - public static class ContainerAlreadyStartedException extends RuntimeException { - } - - /** - * thrown, if a unlocateable resource is requested - */ - private static final class BadResourceAccessException extends RuntimeException { - public BadResourceAccessException(Throwable throwable) { - super(throwable); - } - } - - private static boolean init=false; - public static synchronized void initApplicationContext() { - if (!init) { - beanContainer.createInstances(); -// beanContainer.holdBean(Context.class, __instance); // Inject a context simply - beanContainer.performInjections(); - beanContainer.performPostConstuct(); - beanContainer.treatKnownUiComponents(); - - validationFactory = getBean(ValidationFactory.class); - errorHandlingFactory = getBean(ErrorHandlingFactory.class); - - init = true; - } - } - - public static synchronized void make() { - if (!semaphore) { - semaphore = true; - callbacks = new ActivityLifecycleCallbacks() { - @Override - public void onActivityCreated(Activity activity, Bundle savedInstanceState) { - logger.debug("onActivityCreated called for $1",activity.getClass().getName()); - BeanContainer.addExistingActivity(activity); -// beanContainer.holdBean(activity.getClass(), activity); - if (!init) { - logger.debug("build application context"); - initApplicationContext(); - } - beanContainer.performInjection(activity); - - } - - @Override - public void onActivityStarted(Activity activity) { - logger.debug("onActivityStarted called for $1",activity.getClass().getName()); - BeanContainer.addActiveActivity(activity); - } - - @Override - public void onActivityResumed(Activity activity) { - logger.debug("onActivityResumed called for $1",activity.getClass().getName()); - BeanContainer.removePausedActivity(activity); - } - - @Override - public void onActivityPaused(Activity activity) { - logger.debug("onActivityPaused called for $1",activity.getClass().getName()); - BeanContainer.addPausedActivity(activity); - } - - @Override - public void onActivityStopped(Activity activity) { - logger.debug("onActivityStopped called for $1",activity.getClass().getName()); - BeanContainer.removeActiveActivity(activity); - beanContainer.performOutjection(activity); - } - - @Override - public void onActivitySaveInstanceState(Activity activity, Bundle outState) { - logger.debug("onActivitySaveInstanceState called for $1",activity.getClass().getName()); - -// beanContainer.performOutjection(activity.getClass()); - } - - @Override - public void onActivityDestroyed(Activity activity) { - logger.debug("onActivityDestroyed called for $1",activity.getClass().getName()); - BeanContainer.removeExistingActivity(activity); - } - }; - - __instance.registerActivityLifecycleCallbacks(callbacks); - - - - } - - semaphore = false; - - refCount++; - } - - /** - * register a bean class managed by the container A managed bean - * can implement the lifecycle interfaces Initializable (for post- - * construction management) and Destroyable (for pre-destroy management). - * - * @param theClazz - */ - public final static void registerBeanClass(Class theClazz) { - beanContainer.registerBeanClass(theClazz); - } - - /** - * resolve a string and replace parameters by passed strings - * e.g. resolveString(R.string.foo,4711) - * @param msgId - the android string resource id - * @param vars - the variables replacing $1,$2...$n in the string - * @return the substituted string - */ - public static String resolveString(Integer msgId, String... vars) { - String rawMsg = __instance.getApplicationContext().getString(msgId); - - if (vars != null && vars.length > 0) { - - int i = 1; - for (String parm : vars) { - rawMsg = rawMsg.replace("$" + i, parm); - ++i; - } - } - - return rawMsg; - } - - /** - * resolve a string and replace parameters by passed strings - * e.g. resolveString(R.string.foo,4711) - * single parameter function to avoid array wrapping in case of single parameters - * - * @param msgId - the android string resource id - * @param var - the variables replacing $1,$2...$n in the string - * @return the substituted string - */ - public static String resolveString(Integer msgId, String var) { - String rawMsg = __instance.getApplicationContext().getString(msgId); - rawMsg = rawMsg.replace("$1", var); - return rawMsg; - } - - /** - * destroys the application context and shreds all beans. this function allows you - * to shut down the entire bean context in your application without restarting it - * - * @param force - set to true, and all references are ignored - */ - public static synchronized void destroy(boolean force) { - refCount--; - if (refCount == 0 || force) { - - beanContainer.shutdownContext(); - - __instance.unregisterActivityLifecycleCallbacks(callbacks); - - connectDbHandle().close(); - deleteListeners.clear(); - changeListener.clear(); - - db = null; - validationFactory = null; - errorHandlingFactory = null; - - semaphore = false; - init = false; - System.gc(); - } - } - - - /** - * register a deletion listener implementing the DeleteAwareComponent interface. This listener - * is called automatically on the deletion of the associated class. notice, if a delete listener - * causes in exception in the callback processing, it will be automatically removed from the listener table - * @param clazz - the class - * @param dac - the delete listener - */ - public static synchronized void registerDeleteListener(Class clazz, DeleteAwareComponent dac) { - logger.debug("Registered DeleteListener $1 for class $2", clazz.getSimpleName(), dac.getClass().getSimpleName()); - deleteListeners.put(clazz, dac); - } - - /** - * emit a delete event on the passed model class - * @param clazz - the class to raise the event for - */ - public static synchronized void emitDeleteEvent(Class clazz) { - if (deleteListeners.containsKey(clazz)) { - DeleteAwareComponent dac = deleteListeners.get(clazz); - try { - dac.onDelete(); - } catch (Exception e) { - logger.error("Caught exception while emitting delete event", e); - deleteListeners.remove(clazz); - } - } - } - - /** - * register a change listener on the entity. @see registerDeleteListener. same restrictions, same behaviour - * but this time for change events - * @param clazz - * @param dac - */ - public static synchronized void registerSetChangeListener(Class clazz, DataSetChangeAwareComponent dac) { - logger.debug("Registered SetChangeListener $1 for class $2", clazz.getSimpleName(), dac.getClass().getSimpleName()); - changeListener.put(clazz, dac); - } - - /** - * emits a change event - * @param clazz - */ - public static synchronized void emitSetChangeEvent(Class clazz) { - if (changeListener.containsKey(clazz)) { - DataSetChangeAwareComponent dac = changeListener.get(clazz); - try { - dac.onChange(); - } catch (Exception e) { - logger.error("Caught exception while emitting change set event", e); - changeListener.remove(clazz); - } - } - } - - - /** - * register a change listener on the entity. @see registerDeleteListener. same restrictions, same behaviour - * but this time for change events - * - * @param clazz - * @param dac - */ - public static synchronized void registerDataChangeListener(Class clazz, DataChangeAwareComponent dac) { - logger.debug("Registered SetChangeListener $1 for class $2", clazz.getSimpleName(), dac.getClass().getSimpleName()); - Set set = dataListener.get(clazz); - if (set == null) { - set = new HashSet(); - dataListener.put(clazz, set); - } - set.add(dac); - } - - /** - * emits a change event on a single data object to all registered event recipients - * - * @param changedItem - the changed item - */ - public static synchronized void emitDataChangeEvent(AbstractModelBase changedItem) { - - if (changedItem != null) { - if (dataListener.containsKey(changedItem.getClass())) { - Set dac = dataListener.get(changedItem.getClass()); - if (dac != null && dac.size() > 0) { - for (DataChangeAwareComponent component : dac) { - try { - component.onChange(changedItem); - } catch (Exception e) { - logger.error("Caught exception while emitting change set event", e); - dac.remove(component); - } - } - } - } - } - } - - /** - * register a generic listener for a generic event. - * - * @param eventClass - the event class - * @param handler - the handler - */ - public static synchronized void registerGenericListener(Class eventClass, GenericEventAwareComponent handler) { - logger.debug("Registered Generic Listener $1 for class $2", eventClass.getSimpleName(), handler.getClass().getSimpleName()); - Set> set = eventConsumers.get(eventClass); - if (set == null) { - set = new HashSet>(); - eventConsumers.put(eventClass, set); - } - set.add(handler); - } - - /** - * Free all consumers of an generic event - * @param eventClass - */ - public static synchronized void freeGenericListeners(Class eventClass){ - Set> set = eventConsumers.get(eventClass); - if (set != null) { - set.clear(); - } - } - - /** - * Free all consumers of data change event - * @param forClazz - the model class whose event listeners should be removed - */ - public static synchronized void freeDataChangeListeners(Class forClazz){ - Set set = dataListener.get(forClazz); - if (set != null) { - set.clear(); - } - } - - - - /** - * emit a generic event to all registered listeners - * @param event - */ - public static synchronized void emitGenericEvent(GenericEvent event) { - Set> receivers = eventConsumers.get(event.getClass()); - if (receivers != null) { - for (GenericEventAwareComponent receiver : receivers) { - try { - receiver.handleEvent(event); - } catch (Exception e) { - logger.error("Caught exception while emitting generic event", e); - receivers.remove(receiver); - } - } - } - } - - - - - /** - * @return the android context - */ - public static synchronized Context getContext() { - return __instance.getApplicationContext(); - } - - /** - * @return the absolute path to the database - */ - public static String getDatabasePath() { - return databasePath; - } - - /** - * @return a db handle. notice, if you implement DAOs you do not need this functions, the db context is injected automatically! - */ - public static synchronized SQLiteDatabase connectDbHandle() { - if (db == null) { - db = connectOpenHelper().getWritableDatabase(); - databasePath = db.getPath(); - } - - return db; - } - - /** - * @return the open helper. currently needed by the dao. - */ - public static synchronized BaracusOpenHelper connectOpenHelper() { - if (baracusOpenHelper == null) { - for (Object o : beanContainer.beanMap.values()) { - if (BaracusOpenHelper.class.isAssignableFrom(o.getClass())) { - baracusOpenHelper = (BaracusOpenHelper) o; - } - } - if (baracusOpenHelper == null) { - throw new ContextNotYetCreatedException("You must implement an OpenHelper deriving BaracusOpenHelper and register it to Your context!"); - } - } - return baracusOpenHelper; - } - - /** - * register a named validator for performing field validation in forms. - * - * @param name - the name of the validator - * @param validator - the validator instance - */ - public static synchronized void registerValidator(String name, Validator validator) { - validationFactory.registerValidator(name, validator); - } - - /** - * register a named validator using the simple class name (FooBarValidator -> fooBarValidator) - * @param validator - the validator instance - */ - public static void registerValidator(Validator validator) { - validationFactory.registerValidator(validator); - } - - /** - * make sure, that all named validators put into the comma seperated list are available - * inside the context - * - * @param validatorList - */ - public static synchronized void verifyValidators(String validatorList) { - validationFactory.verifyValidators(validatorList); - } - - /** - * removes all errors from the view set before and then performs - * validations on the passed view and applies all errors to the - * view. use viewHasErrors() to ask, if there are any issues bound to the - * view - * - * @param view - the view to process - */ - public static synchronized void validateView(View view) { - resetErrors(view); - validationFactory.validateView(view); - errorHandlingFactory.applyErrorsOnView(view); - } - - /** - * registers an onFocusChangeListener to all view elements implementing - * the @see ConstrainedView interface to perform on-the-fly-validation. - * If you want Your View to be able to receive a validation callback - * - e.g. in order to manage the visibility of an OK-Button or sth. - - * Your View must implement the @see ValidatableView interface in - * order to receive a validation notification callbacks. - * - * If you implement a @see ManagedFragment, simply call - * the enableFocusChangeBasedValidation() function in the onCreate-method - * - * @param view - the view to register - */ - public static void registerValidationListener(View view) { - validationFactory.registerValidationListener(view); - } - - /** - * register a custom error handler. Use this stuff only, if You want to use specific view components - * to handle Your errors, if you want to use standard android handling for any component, - * use the registerStandardErrorHandler() function instead! - * @param handler - the handler instance - */ - public static synchronized void registerCustomErrorHandler(CustomErrorHandler handler) { - errorHandlingFactory.registerCustomErrorHandler(handler); - } - - /** - * register a standard error handler. Using a standard error handler will make use - * of the android standard error handling. - * - * @param handler - the handler instance - */ - public static synchronized void registerStandardErrorHandler(StandardErrorHandler handler) { - errorHandlingFactory.registerStandardErrorHandler(handler); - } - - - /** - * return true, if the passed view instance contains errors. Error handling should be always - * done on the root view of a form! - * - * @param container - the form view containing malicious components - * @return true, if any error is bound to the form instance - */ - public static boolean viewHasErrors(View container) { - return errorHandlingFactory.viewHasErrors(container); - } - - /** - * map all bound errors to all findeable receivers on the container. - * @param container - the container to map errors for - */ - public static void applyErrorsOnView(View container) { - errorHandlingFactory.applyErrorsOnView(container); - } - - /** - * adds an error to the passed view. use this function only, if want to perform manual form - * validation! if you rely on automatic validation and error routing, simply call validateView - * - * @param container - the container view - * @param affectedResource - the resource id of the component, where the error occured - * @param messageId - the message id to display - * @param severity - the severity of the problem (currently unused) - * @param params - the parameters to be mapped to the resource resolution - */ - public static void addErrorToView(View container, int affectedResource, int messageId, ErrorSeverity severity, String... params) { - errorHandlingFactory.addErrorToView(container, affectedResource, messageId, severity, params); - } - - /** - * clear all errors of the view container - * - * @param container - the container - */ - public static void resetErrors(View container) { - errorHandlingFactory.resetErrors(container); - } - - /** - * unregister all error handlers for a view. this should be called implicitly by the - * @see ManagedFragment and the - * @see ManagedActivity class - * - * If you are using own extension, make sure that you call this function before destroying - * the view in order to avoid memory leaks - * - * @param v - */ - public static void unregisterErrorhandlersForView(View v) { - errorHandlingFactory.unregisterCustomErrorHandlersForView(v); - } - - - /** - * returns the baracus application context instance. notice, - * normally you should not need this instance and fully rely - * on the automated injection mechanisms - * - * @return the baracus application context instance - */ - public static BaracusApplicationContext getInstance() { - return __instance; - } - - /** - * @param clazz - the class of the bean to be returned - * @param - class parametrizer - * @return the instance of the bean or null - */ - public static T getBean(Class clazz) { - return (T) BeanContainer.clazzMap.get(clazz); - } - - /** - * run a type based dependency injection on the passed object - * @param o - the object where injection shall be performed on - */ - public synchronized static void performInjectionsOn(Object o) { - if (!semaphore) { - beanContainer.performInjection(o); - } - } - - /** - * creates a bean instance not cached by the container - no singleton! - - * for your personal transient use. does not support custom constructors! - * @param clazz - the class to be instantiaten - * @param the type - * @return an instance of T with all refs to components injected - */ - public static T createPrototypeBean(Class clazz) { - try { - T instance = beanContainer.instantiatePojo(clazz); - performInjectionsOn(instance); - return instance; - } catch (Exception e) { - throw new Exceptions.IntantiationException(e); - } - } - - /** - * resolve the passed name into a android resource ID, this means - * the number representation in R.id. - * - * @param name - the name of a view component (e.g. btnOk) - * @return the ID (eg -47236333) - */ - public static final int getResource(String name) { - try { - Field f = R.layout.class.getField(name); - return f.getInt(null); - } catch (Exception e) { - logger.error("ERROR!", e); - throw new BadResourceAccessException(e); - } - } -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/BeanContainer.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/BeanContainer.java deleted file mode 100644 index 00ffdcb..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/BeanContainer.java +++ /dev/null @@ -1,388 +0,0 @@ -package net.mantucon.baracus.context; - -import android.app.Activity; -import android.app.Fragment; -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import net.mantucon.baracus.dao.BaracusOpenHelper; -import net.mantucon.baracus.lifecycle.Destroyable; -import net.mantucon.baracus.lifecycle.Initializeable; -import net.mantucon.baracus.util.Logger; - -import net.mantucon.baracus.context.Exceptions.*; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.util.*; - -/** - * - * Bean container carrying all bean instances order to keep the - * Application somewhat tight. - * - */ -public class BeanContainer { - - private static final Logger logger = new Logger(BeanContainer.class); - - // We are carrying a className to Object map and a Class to Object map - // this is simply done to avoid too many type based questions - protected final static Map beanMap = new HashMap(); - protected final static Map, Object> clazzMap= new HashMap, Object>(); - - // fragment holder. registering all fragments as bean will cause them - // to be held here. Registering fragments as bean makes them become - // injection capable and being used as a injection target - protected final static Set knownFragments = new HashSet(); - - // stats maps for handling context events - protected final static Map, Object> activeActivitiesMap= new HashMap, Object>(); - protected final static Map, Object> pausedActivitiesMap= new HashMap, Object>(); - protected final static Map, Object> existingActivitiesMap= new HashMap, Object>(); - - - /** - * Exception while destroying a bean. thrown if a shutdown caused - * an error - */ - public static class BeanDestructionException extends RuntimeException { - BeanDestructionException(Throwable reason) { - super(reason); - } - } - - - /** - * instanciate all registered beans - */ - void createInstances() { - for (Class clazz : clazzMap.keySet()) { - if (clazzMap.get(clazz) == null) { - try { - instantiateSingletonBean(clazz); - logger.debug("Instantiation of $1 succeded.", clazz.getName()); - } catch (Exception e) { - logger.debug("Instantiation of $1 failed. Reason : $2", clazz.getName(), e.getMessage()); - throw new Exceptions.IntantiationException(e); - } - } - } - } - - /** - * perform postconstruct method on all bean instances implementing Initializeable - */ - void performPostConstuct() { - for (Object o : beanMap.values()) { - if (o instanceof Initializeable) { - logger.debug("Running Post Construction method on $1",o.getClass().getName()); - ((Initializeable) o).postConstruct(); - } - } - } - - /** - * perform all bean injections on all beans - */ - void performInjections() { - for (Class clazz : clazzMap.keySet()) { - performInjection(clazz); - } - - //To change body of created methods use File | Settings | File Templates. - } - - /** - * locate the passed class instance and call injection - * @param clazz - the class whose cached singleton instance shall be injected with components - */ - void performInjection(Class clazz) { - Object o = clazzMap.get(clazz); - performInjection(o); - } - - /** - * perform injection on the passed object instance - * @param o - */ - void performInjection(Object o) { - Class clazz = o.getClass(); - for (Field field : getAllDeclaredFields(clazz)) { - String type = field.getType().getName(); - for (Class clazz2 : clazzMap.keySet()) { - if (type.equals(clazz2.getName())) { - field.setAccessible(true); - logger.debug("$1.$2 candidate is $3",clazz.getName(),field.getName(),clazz2.getName()); - try { - field.set(o, clazzMap.get(clazz2)); - } catch (IllegalAccessException e) { - throw new InjectionException("Failed to set "+clazz.getName()+"."+field.getName()+" with bean "+clazz2.getName(),e); - } - } else if (type.equals(SQLiteDatabase.class.getName())) { - field.setAccessible(true); - logger.debug("$1.$2 candidate is $3",clazz.getName(),field.getName(),clazz2.getName()); - try { - field.set(o, BaracusApplicationContext.getInstance().connectDbHandle()); - } catch (IllegalAccessException e) { - throw new InjectionException("OMG SQLite injection issued a major clusterfuck",e); - } - } else if (type.equals(BaracusOpenHelper.class.getName())) { - field.setAccessible(true); - logger.debug("$1.$2 candidate is $3",clazz.getName(),field.getName(),clazz2.getName()); - try { - field.set(o, BaracusApplicationContext.getInstance().connectOpenHelper()); - } catch (IllegalAccessException e) { - throw new InjectionException("OMG OpenHelper injection issued a major clusterfuck",e); - } - } else if (type.equals(Context.class.getName())) { - field.setAccessible(true); - logger.debug("$1.$2 candidate is $3",clazz.getName(),field.getName(),clazz2.getName()); - try { - field.set(o, BaracusApplicationContext.getInstance()); - } catch (IllegalAccessException e) { - throw new InjectionException("OMG Context injection issued a major clusterfuck",e); - } - } - } - } - } - - /** - * @param clazz - the class to scan - * @return all fields of all types - */ - Field[] getAllDeclaredFields(Class clazz) { - ArrayList fields = new ArrayList(); - - fields.addAll(Arrays.asList(clazz.getDeclaredFields())); - - Class superclass = clazz; - - while ((superclass = superclass.getSuperclass()) != null) { - fields.addAll(Arrays.asList(superclass.getDeclaredFields())); - } - - return fields.toArray(new Field[fields.size()]); - } - - /** - * nullify component refs in all beans - */ - void performDestruction() { - for (Class clazz : clazzMap.keySet()) { - performOutjection(clazz); - } - - for (Class clazz : clazzMap.keySet()) { - removeBean(clazz); - } - } - - /** - * tidy upp all managed references of clazz in order to avoid loitering objects - * @param clazz - */ - void performOutjection(Class clazz) { - Object o = clazzMap.get(clazz); - if (o == null) { - logger.warn("Warning! Object of type $1 was already nulled!",clazz.getName()); - } else { - performOutjection(o); - } - } - - void performOutjection(Object o) { - Class clazz = o.getClass(); - for (Field field : getAllDeclaredFields(clazz)) { - String type = field.getType().getName(); - for (Class clazz2 : clazzMap.keySet()) { - if (type.equals(clazz2.getName())) { - field.setAccessible(true); - logger.debug("$1.$2 nullified",clazz.getName(),field.getName(),clazz2.getName()); - try { - field.set(o, null); - } catch (IllegalAccessException e) { - throw new BeanDestructionException(e); - } - } - } - } - } - - - /** - * instanciate a bean class. if the bean class has got a constructor carrying the android Context, - * this constructor is used to pass the context. Otherwise, your bean has to implement a default - * constructor! - * - * @param theClazz - the clazz to instanciate - * @throws InstantiationException - * @throws IllegalAccessException - * @throws java.lang.reflect.InvocationTargetException - */ - void instantiateSingletonBean(Class theClazz) throws InstantiationException, IllegalAccessException, InvocationTargetException { - Object result = instantiatePojo(theClazz); - holdBean(theClazz, result); - } - - /** - * create an instance of the passed class regarding the application context contructor - * - * @param theClazz - * @return - * @throws InstantiationException - * @throws IllegalAccessException - * @throws InvocationTargetException - */ - T instantiatePojo(Class theClazz) throws InstantiationException, IllegalAccessException, InvocationTargetException { - T result = null; - for (Constructor c : theClazz.getConstructors()) { - Class[] parameterTypes = c.getParameterTypes(); - if (parameterTypes == null || parameterTypes.length == 0) { - // default Constructor - result = theClazz.newInstance(); - break; - } else if (parameterTypes.length == 1 && parameterTypes[0].equals(Context.class)) { - result = (T) c.newInstance(BaracusApplicationContext.getContext()); - break; - } - } - - if (result == null) { - throw new InstantiationException(theClazz.getName()+" could not be instantiated. Please provide a) a public default constructor or b) a public constructor takinng the Android Context as it's only parameter!"); - } - return result; - } - - /** - * put the bean into the holders - * @param theClazz - * @param o - */ - void holdBean(Class theClazz, Object o) { - beanMap.put(theClazz.getName(), o); - clazzMap.put(theClazz ,o); - if (o instanceof Fragment) { - knownFragments.add((Fragment)o); - } - } - - /** - * remove the bean class from the holders - * @param theClazz - */ - void removeBean(Class theClazz) { - beanMap.put(theClazz.getName(), null); - clazzMap.put(theClazz, null); - } - - /** - * register a bean class managed by the container A managed bean - * can implement the lifecycle interfaces Initializable (for post- - * construction management) and Destroyable (for pre-destroy management). - * - * @param theClazz - */ - final void registerBeanClass(Class theClazz) { - final String clazzName = theClazz.getName(); - if (!beanMap.containsKey(clazzName)) { - try { - holdBean(theClazz,null); - - } catch (Exception e) { - throw new RegistrationException(e); - } - } - } - - /** - * Shred the beans. - */ - synchronized void shutdownContext() { - for (Object o : beanMap.values()) { - if (o instanceof Destroyable) { - ((Destroyable) o).onDestroy(); - } - } - performDestruction(); - System.gc(); - } - - private void unregisterClasses() { - for (Class c : clazzMap.keySet()) { - removeBean(c); - } - } - - static void addActiveActivity(Activity activity){ - addActivity(activity,activeActivitiesMap); - } - static void addExistingActivity(Activity activity){ - addActivity(activity,existingActivitiesMap); - } - static void addPausedActivity(Activity activity){ - addActivity(activity,pausedActivitiesMap); - } - - static void removeActiveActivity(Activity activity){ - removeActivity(activity,activeActivitiesMap); - } - static void removeExistingActivity(Activity activity){ - removeActivity(activity,existingActivitiesMap); - } - static void removePausedActivity(Activity activity){ - removeActivity(activity,pausedActivitiesMap); - } - - static void printStats() { - logger.info("EXSTING $1", existingActivitiesMap.size()); - logger.info("ACTIVE $1", activeActivitiesMap.size()); - logger.info("RESUMED $1", pausedActivitiesMap.size()); - } - - - private static void addActivity(final Activity activity, final Map, Object> map ) { - - if (map.containsKey(activity.getClass())) { - logger.debug("Activity class $1 already in keyset", activity.getClass().getName()); - } - - if (map.containsValue(activity)) { - logger.debug("Activity $1 already in values",activity); - } - - map.put(activity.getClass(),activity); - printStats(); - } - - private static void removeActivity(final Activity activity, final Map, Object> map ) { - - if (!map.containsKey(activity.getClass())) { - logger.debug("Activity class $1 not in keyset", activity.getClass().getName()); - } - - if (!map.containsValue(activity)) { - logger.debug("Activity $1 not in values",activity); - } - - map.remove(activity.getClass()); - printStats(); - } - - - public void treatKnownUiComponents() { - for (Object o : activeActivitiesMap.values()) { - performInjection(o); - } - - for (Fragment f : knownFragments) { - try { - performInjection(f); - } catch (Exception e) { - logger.debug("$1 has caused an injection problem and is going to be removed from list."); - knownFragments.remove(f); - } - } - } - -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/Exceptions.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/Exceptions.java deleted file mode 100644 index 1df2e74..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/Exceptions.java +++ /dev/null @@ -1,35 +0,0 @@ -package net.mantucon.baracus.context; - -public class Exceptions { - /** - * Bean instanciation fucked up. Thrown when the instantiation of - * a bean caised an errer - */ - final static class IntantiationException extends RuntimeException { - IntantiationException(Throwable reason) { - super(reason); - } - } - - - /** - * Registration of a bean failed. - */ - final static class RegistrationException extends RuntimeException { - RegistrationException(Throwable reason) { - super(reason); - } - } - - /** - * Injection of a bean caused an error - */ - final static class InjectionException extends RuntimeException { - InjectionException(Throwable reason) { - super(reason); - } - InjectionException(String msg, Throwable reason) { - super(msg, reason); - } - } -} \ No newline at end of file diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/ManagedActivity.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/ManagedActivity.java deleted file mode 100644 index ae97dcd..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/ManagedActivity.java +++ /dev/null @@ -1,30 +0,0 @@ -package net.mantucon.baracus.context; - -import android.app.Activity; -import android.os.Bundle; -import android.view.View; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 23.09.13 - * Time: 08:34 - * To change this template use File | Settings | File Templates. - */ -public class ManagedActivity extends Activity{ - - protected View underlyingView; - - @Override - protected void onPostCreate(Bundle savedInstanceState) { - super.onPostCreate(savedInstanceState); - this.underlyingView = getWindow().getDecorView().findViewById(android.R.id.content); - } - - @Override - protected void onDestroy() { - BaracusApplicationContext.unregisterErrorhandlersForView(underlyingView); - super.onDestroy(); - } - -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/ManagedFragment.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/ManagedFragment.java deleted file mode 100644 index c347037..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/ManagedFragment.java +++ /dev/null @@ -1,57 +0,0 @@ -package net.mantucon.baracus.context; - -import android.app.Fragment; -import android.view.View; -import android.widget.EditText; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 17.05.13 - * - * This class is needed in order to juxtaposition the reinstantiaon of Fragment beans - * by android e.g. when a device rotate happens - unless I have found something - * more appropriate for it (Hooking into the lifecycle in android handling the fragments - * must be possible) - * - * Simple inherit this class and register it as usual as a Fragment bean and all accesses - * to injected beans will work fine :) - * - */ -public abstract class ManagedFragment extends Fragment { - - // set this View from derived classes if You want to use automatic error handling - protected View view; - - public ManagedFragment() { - BaracusApplicationContext.performInjectionsOn(this); - } - - @Override - public void onDestroyView() { - if (view != null) { // if you use the automatic error routing extension, you MUST set the view - // when inflating the form. Notice, this is normally done in the - // onCreateView function. If You do not set the view field when inflating - // a new view, you will create memory leaks, because all bound errorHandlers - // cannot be marked for removal by the garbage collector because they are - // held in the application context bound to the containing view instance! - BaracusApplicationContext.unregisterErrorhandlersForView(this.view); - } - super.onDestroyView(); - } - - /** - * enables the validation of the view onFocusChanged - * If you want Your View to - * be able to receive a validation callback - e.g. in order to manage the - * visibility of an OK-Button or sth. - Your View must implement - * the @see ValidatableView interface in order to receive a validation - * notification. - * - * Notice, You must set the underlying view instance to enable this feature! - * - */ - public void enableFocusChangeBasedValidation() { - BaracusApplicationContext.registerValidationListener(this.view); - } -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/BaracusOpenHelper.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/BaracusOpenHelper.java deleted file mode 100644 index 5c4914b..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/BaracusOpenHelper.java +++ /dev/null @@ -1,186 +0,0 @@ -package net.mantucon.baracus.dao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteOpenHelper; -import net.mantucon.baracus.lifecycle.Destroyable; -import net.mantucon.baracus.migr8.MigrationStep; -import net.mantucon.baracus.migr8.ModelVersion000; -import net.mantucon.baracus.util.Logger; - -import java.util.HashMap; -import java.util.Map; - -/** - *
- * OpenHelper base class used to manage Your database within baracus.   
- * Automatic database management includes context & connection management plus - * database creation and automatic migration support.
- * - * You must implement this class providing a target version, a database name and the - * android context. Also, You must add it to the beans using Your ApplicationContext! - * - * - *
- * - *
- * Example: - * -
- {@code
- public class OpenHelper extends BaracusOpenHelper {
-
- public static final String DATABASE_NAME = "my_application.db";      // database name
- public static final int TARGET_DATABASE_VERSION = 110;             // target versiion
-
- static  {
-    upgradeSteps.put(100, new ModelVersion100()); // one upgrade since initial version
-    // here you can add all migration steps. please
-    // be sure to apply increasing numbers.
- }
-
-
- public OpenHelper(Context mContext) {
-    super(mContext, DATABASE_NAME, TARGET_DATABASE_VERSION);
- }
-
- public MigrationStep getInitialModel() {
-    return new ModelVersion100();
- }
-}
-
- - Example Registration : -
- {@code
-
- public class ApplicationContext extends BaracusApplicationContext{
-     ...
-     static {
-        ...
-        registerBeanClass(OpenHelper.class);
-        ...
-     }
-
-}
-}
-
- * - * - */ -public abstract class BaracusOpenHelper extends SQLiteOpenHelper implements Destroyable { - - /** - * Exception preventing us from reusing a version number. This can to severe damage on Your - * database. Do not rebind Migration objects - */ - public static class VersionNumberAlreadyBoundException extends IllegalArgumentException { - public VersionNumberAlreadyBoundException(String s) { - super(s); - } - } - - private final Logger logger = new Logger(getClass()); // Logger - - protected static Map upgradeSteps = new HashMap(); // Here are the upgrade steps - - private final String databaseName; // set this value via constructor in order to define the db name - - /* set this value via constructor in order to set the target version - we are going to iterate all bound version migrators from initialVersion - until target version - */ - private final int targetDatabaseVersion; - - static { - upgradeSteps.put(110, new ModelVersion000()); - } - - /** - * Open Helper for the android database - * - * @param mContext - the android context - * @param databaseName - the database name of your app - * @param targetDatabaseVersion the target version. automatic migration will be done until this version - */ - protected BaracusOpenHelper(Context mContext, String databaseName, int targetDatabaseVersion) { - super(mContext, databaseName, null, targetDatabaseVersion); - this.databaseName = databaseName; - this.targetDatabaseVersion = targetDatabaseVersion; - } - - /** - * Creation function . do not edit. do not override. it takes care of the creation of your - * database - * - * @param db - */ - @Override - public final void onCreate(SQLiteDatabase db) { - - MigrationStep initialModel = getInitialModel(); - initialModel.applyVersion(db); - - onUpgrade(db, initialModel.getModelVersionNumber(), targetDatabaseVersion); - - } - - - public MigrationStep getInitialModel(){ - return new ModelVersion000(); - } - - /** - * use this method in order to add further migration steps to your db. - * each release with database changes should bring a migration step - * - * you should not change the prior defined steps any more. this will - * make your database safe for creation and migration on - * a brand new target system. - * - * @param step - the migration step - */ - protected static final void addMigrationStep(MigrationStep step) { - if (upgradeSteps.containsKey(step.getModelVersionNumber())) { - throw new VersionNumberAlreadyBoundException("The version number "+step.getModelVersionNumber()+" is already present in migration object list!"); - } - upgradeSteps.put(step.getModelVersionNumber(), step); - } - - /** - * Do not modify this function. Do not override. It takes care of your database - * migration. - * - * @param db - database ref - * @param oldVersion - the current version - * @param newVersion - the version to migrate to - */ - @Override - public final void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - for (int i = oldVersion+1 ; i <= newVersion; ++i) { - MigrationStep step = upgradeSteps.get(i); - if (step != null) { - logger.info("Applying Version $1",i); - step.applyVersion(db); - } else { - logger.debug("No Version for $1",i); - } - } - } - - public void onDestroy() { - - try { - this.close(); - } catch (Exception e) { - logger.error("On destroy failed", e); - } - - } - - public String getDatabaseName() { - return databaseName; - } - - -} \ No newline at end of file diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/BaseDao.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/BaseDao.java deleted file mode 100644 index 5b973b7..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/BaseDao.java +++ /dev/null @@ -1,390 +0,0 @@ -package net.mantucon.baracus.dao; - -import android.content.ContentValues; -import android.database.Cursor; -import android.database.sqlite.SQLiteDatabase; -import net.mantucon.baracus.annotations.Bean; -import net.mantucon.baracus.context.BaracusApplicationContext; -import net.mantucon.baracus.orm.AbstractModelBase; -import net.mantucon.baracus.orm.Field; -import net.mantucon.baracus.orm.FieldList; -import net.mantucon.baracus.orm.Timestamped; -import net.mantucon.baracus.util.Logger; - -import java.util.Date; -import java.util.LinkedList; -import java.util.List; - -/** - * DAO Base Class. If You want to make use of DAOs, You must derive this class to manage a - * POJO deriving AbstractModelBase - * - * @param - * @see ConfigurationDao for an example DAO. - */ -public abstract class BaseDao{ - - @Bean - private SQLiteDatabase db; - - private final Logger logger = new Logger(this.getClass()); - - protected final Class managedClass; - - /** - * Rowmapper component providing the object mapping functions - * example : - - RowMapper rowMapper = new RowMapper() { - - @Override - public ConfigurationParameter from(Cursor c) { - ConfigurationParameter result = new ConfigurationParameter(); - result.setId(c.getLong(idCol.fieldIndex)); - result.setConfigParameter(c.getString(configParamCol.fieldIndex)); - result.setConfigParameterValue(c.getString(configParamValueCol.fieldIndex)); - result.setTransient(false); - return result; - } - - @Override - public String getAffectedTable() { return TABLE_CONFIGURATION; } - - @Override - public FieldList getFieldList() { return ConfigurationParameter.fieldList; } - - @Override - public Field getNameField() { - return ConfigurationParameter.configParamCol; - } - - public ContentValues getContentValues(ConfigurationParameter parm) { - ContentValues result = new ContentValues(); - if (parm.getId() != null) { result.put(idCol.fieldName, parm.getId()); } - if (parm.getConfigParameter() != null) { result.put(configParamCol.fieldName, parm.getConfigParameter()); } - if (parm.getConfigParameterValue()!= null) { result.put(configParamValueCol.fieldName, parm.getConfigParameterValue()); } - return result; - } - }; - - * @param - */ - public static interface RowMapper { - /** - * maps the cursor content to a model bean (aka entity bean) - * @param c - the cursor - * @return the model bean - * @see ConfigurationDao.RowMapper - */ - T from(Cursor c); - - /** - * @return the affected table name - * @see ConfigurationDao.RowMapper - */ - String getAffectedTable(); - - /** - * @return the field list of your model bean - * @see ConfigurationDao.RowMapper - * @see net.mantucon.baracus.model.ConfigurationParameter - */ - FieldList getFieldList(); - - /** - * just for convinience, if your model has an unique name identifier (e.g. bankName( - * you can return this field. a matching dao then automatically has got a getByName function - * @return the name field - * @see ConfigurationDao.RowMapper - * - */ - Field getNameField(); - - /** - * makes a SQLite content values object out of your model bean in order to - * perform an update or an insert on the entity. - * - * @param item - the model bean - * @return the content values object - * @see ConfigurationDao.RowMapper - */ - ContentValues getContentValues(T item); - } - - /** - * Lock-in Constructor. Replaces the deprecated getManagedClass() function in order to save - * performance - * @param managedClass - the model class Your Dao manages - */ - protected BaseDao(Class managedClass) { - this.managedClass = managedClass; - } - - /** - * performs a delete operation on the db - * @param model - * @return - */ - public int delete(final AbstractModelBase model){ - int result=0; - if (!model.isTransient()) { - result = db.delete(model.getTableName(), AbstractModelBase.idCol.fieldName + " = ?", new String[]{model.getId().toString()}); - BaracusApplicationContext.emitDeleteEvent(managedClass); - model.setTransient(true); - } else { - logger.warn("Warning. You tried to delete a transient entity of type $1. No operation performed!.",model.getClass().getName()); - result = -1; - } - return result; - } - - /** - * fetches an model bean out the db using the Long id. - * @param id - the id - * @return the model bean; - */ - public T getById(Long id) { - - RowMapper rowMapper = getRowMapper(); - Cursor c = null; - T result = null; - try { - c = db.query(true, rowMapper.getAffectedTable(), rowMapper.getFieldList().getFieldNames(), AbstractModelBase.idCol.fieldName + "= ?", new String[]{id.toString()}, null, null, null, null); - if (!c.isAfterLast() && c.moveToNext() ) { - result = rowMapper.from(c); - } else { - result = null; - } - } finally { - if (c != null && !c.isClosed()) { - c.close(); - } - } - return result; - } - - /** - * return a unique item identified by it's name (e.g. Bank.bankName). To make use of this feature, - * Your rowmapper must return a proper name column in the getNameCol function (@see ConfigurationDao.RowMapper) - * - * @param name - the name String - * @return the object identified by this name - */ - public T getByName(String name) { - logger.trace("get object by name $1",name); - - RowMapper rowMapper = getRowMapper(); - Field nameField = rowMapper.getNameField(); - - if (nameField == null) { - throw new UnsupportedOperationException("NAME FIELD IS NOT DEFINED FOR THIS TYPE : "+rowMapper.getAffectedTable()+". You have to implement Your RowMapper's getNameField function properly to make use of this feature."); - } - Cursor c = null; - T result = null; - try { - - c = db.query(true, rowMapper.getAffectedTable(), rowMapper.getFieldList().getFieldNames(), nameField + "= ?", new String[]{name}, null, null, null, null); - if (!c.isAfterLast() && c.moveToNext() ) { - result = rowMapper.from(c); - } else { - result = null; - } - } finally { - if (c != null && !c.isClosed()) { - c.close(); - } - } - return result; - } - - /** - * @return all entities of Your type in database. - */ - public List loadAll() { - RowMapper rowMapper = getRowMapper(); - Cursor c = null; - List result = new LinkedList(); - try { - c = db.query(true, rowMapper.getAffectedTable(), rowMapper.getFieldList().getFieldNames(), null, null, null, null, null, null); - result = iterateCursor(c); - - } catch (Exception e) { - logger.error("An Error has occured",e); - } finally{ - if (c != null && !c.isClosed()) { - c.close(); - } - } - return result; - } - - /** - * Transaction handle. Enables You to have transactions with sqlite in a jdbc-alike way. - * You can get it by calling the beginTransaction function - */ - public final class TxHandle { - private final SQLiteDatabase db; - - private TxHandle(SQLiteDatabase db){ - this.db = db; - } - - public final void commit() { - this.db.setTransactionSuccessful(); - this.db.endTransaction(); - } - - public final void rollback() { - this.db.endTransaction(); - } - - } - - /** - * starts a new sqlite transaction - * @return the transaction handle - */ - public TxHandle getTransaction() { - db.beginTransaction(); - return new TxHandle(db); - } - - /** - * save an item without reusing an existing transaction (autocommit) - * - * @param item - the model bean to save - */ - public void save(T item) { - save(item,null); - } - - /** - * save an item in a running transaction. requires you later to call txHandle.commit() in - * order to commit the transaction. - * - * @param item - the model bean - * @param handle - the transaction handle - */ - public void save(T item, TxHandle handle) { - logger.trace("save object $1",item); - - boolean requiresSetChange = false; - boolean requiresInstanceChange = false; - - RowMapper rowMapper = getRowMapper(); - ContentValues cv = rowMapper.getContentValues(item); - - boolean localTransaction = handle == null; - if (localTransaction) { - db.beginTransaction(); - } - - try { - if (item.getId() == null || item.isTransient()) { - if (item instanceof Timestamped) { - Timestamped t = (Timestamped) item; - t.setCreationDate(new Date()); - t.setLastModificationDate(new Date()); - } - long key = db.insert(rowMapper.getAffectedTable(), null, cv); - item.setId(key); - item.setTransient(false); - requiresSetChange = true; - } else { - if (item instanceof Timestamped) { - Timestamped t = (Timestamped) item; - if (t.getCreationDate() == null) { t.setCreationDate(new Date()); } - t.setLastModificationDate(new Date()); - } - db.update(rowMapper.getAffectedTable(), cv, AbstractModelBase.idCol.fieldName + "= ?", new String[]{item.getId().toString()}); - requiresInstanceChange = true; - } - if (localTransaction) { - db.setTransactionSuccessful(); - } - } finally { - if (localTransaction) { - db.endTransaction(); - } - } - - if (requiresSetChange) { - BaracusApplicationContext.emitSetChangeEvent(managedClass); - } - - if (requiresInstanceChange) { - BaracusApplicationContext.emitDataChangeEvent(item); - } - } - - /** - * clears the entire table - */ - public void deleteAll() { - RowMapper rowMapper = getRowMapper(); - db.delete(rowMapper.getAffectedTable(), null, null); - - } - - /** - * iterate the cursor in order to have a list of entity afterwards - * - * @param c - the cursor - * @return - all mapped entities - */ - protected List iterateCursor(Cursor c) { - RowMapper rowMapper = getRowMapper(); - List result = new LinkedList(); - while (!c.isAfterLast() && c.moveToNext() ) { - result.add(rowMapper.from(c)); - } - return result; - } - - /** - * @return the rowmapper implemented by you. @see ConfigurationDao.RowMapper - */ - public abstract RowMapper getRowMapper(); - - - /** - * save the entire list of entity beans without transaction (autocommit) - * - * @param list - the list of beans - */ - public void saveAll(List list) { - saveAll(list,null); - } - - /** - * save the entire list of entity beans in a transaction. requires you to - * call the txHandle.commit() later - * - * @param list - the list of beans - * @param handle - the tx handle - */ - public void saveAll(final List list, final TxHandle handle) { - final boolean localTransaction = handle == null; - final TxHandle txHandle = localTransaction ? getTransaction() : handle; - try { - for (T item : list) { - save(item,handle); - } - - if (localTransaction) { - txHandle.commit(); - } - }catch (RuntimeException e){ - if (localTransaction) { - txHandle.rollback(); - } - } - } - - /** - * @return the db reference - */ - protected SQLiteDatabase getDb() { - return db; - } -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/ConfigurationDao.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/ConfigurationDao.java deleted file mode 100644 index f0d4f1a..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/ConfigurationDao.java +++ /dev/null @@ -1,75 +0,0 @@ -package net.mantucon.baracus.dao; - -import android.content.ContentValues; -import android.database.Cursor; -import net.mantucon.baracus.annotations.Bean; -import net.mantucon.baracus.model.ConfigurationParameter; -import net.mantucon.baracus.orm.AbstractModelBase; -import net.mantucon.baracus.orm.Field; -import net.mantucon.baracus.orm.FieldList; - -import static net.mantucon.baracus.model.ConfigurationParameter.*; -import static net.mantucon.baracus.orm.AbstractModelBase.idCol; -/** - *
- * Configuration DAO component 
- *
- * - * This component is a fully functional configuration dao ready to use in order - * to store in-application key-value-pairs. It is recommended to wrap - * access to the key-value-pairs into a service bean which is used - * to return type-safe variables (e.g. "myCount" in configuration is held as string "99") - * but in your app your service should take care of the type and return myCount as an integer - * value - * - *
- */ -@Bean -public class ConfigurationDao extends BaseDao { - - public ConfigurationDao() { - super(ConfigurationParameter.class); - } - - /** - *
Row Mapper implementation for configuration parameter
- */ - private RowMapper rowMapper = new RowMapper() { - - @Override - public ConfigurationParameter from(Cursor c) { - ConfigurationParameter result = new ConfigurationParameter(); - result.setId(c.getLong(idCol.fieldIndex)); - result.setConfigParameter(c.getString(configParamCol.fieldIndex)); - result.setConfigParameterValue(c.getString(configParamValueCol.fieldIndex)); - result.setTransient(false); - return result; - } - - @Override - public String getAffectedTable() { return TABLE_CONFIGURATION; } - - @Override - public FieldList getFieldList() { return ConfigurationParameter.fieldList; } - - @Override - public Field getNameField() { - return ConfigurationParameter.configParamCol; - } - - public ContentValues getContentValues(ConfigurationParameter parm) { - ContentValues result = new ContentValues(); - if (parm.getId() != null) { result.put(idCol.fieldName, parm.getId()); } - if (parm.getConfigParameter() != null) { result.put(configParamCol.fieldName, parm.getConfigParameter()); } - if (parm.getConfigParameterValue()!= null) { result.put(configParamValueCol.fieldName, parm.getConfigParameterValue()); } - return result; - } - }; - - - @Override - public RowMapper getRowMapper() { - return rowMapper; - } - -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/PersistenceModel.uml b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/PersistenceModel.uml deleted file mode 100644 index faeb4a0..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/PersistenceModel.uml +++ /dev/null @@ -1,13 +0,0 @@ - - - JAVA - - - - - - - - All - - diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/CustomErrorHandler.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/CustomErrorHandler.java deleted file mode 100644 index 523cb75..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/CustomErrorHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -package net.mantucon.baracus.errorhandling; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 25.09.13 - * Time: 17:38 - * - * Component interface for making a custom error handling. - * - * There is a vast difference to the StandardErrorHandlers : A custom error handler - * always is bound to a view component instance and therefore it needs to be hashed - * by its component id, whilst the StandardErrorHandlers simply rely on the type of - * the passed component (So you only will find a set containing all StandardHandlers) - * - */ -public interface CustomErrorHandler extends ErrorHandler { - /** - * @return the component Id of the error handler widget - */ - public int getId(); - - /** - * @return true if the component id, of the referenced Id; - */ - public int getIdToDisplayFor(); - -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/ErrorHandler.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/ErrorHandler.java deleted file mode 100644 index 997321c..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/ErrorHandler.java +++ /dev/null @@ -1,39 +0,0 @@ -package net.mantucon.baracus.errorhandling; - -import android.view.View; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 20.09.13 - * Time: 08:35 - * - * Error Handler interface. An error handler must be able to process an error and to reset - * - * If the error handler is bound to a view-component, it can influence the visual representation - * or style. Also, it must be capable to reset the error - both on itself and (in case of) the bound - * view component. - * - * @see net.mantucon.baracus.ui.ErrorView - * - */ -public interface ErrorHandler { - - /** - * process an error - * - * @param view - the view, where the error shall be applied - * @param errorMessageId - the message Id, which shall be used to display - * @param severity - the severity of an error - * @param params - varargs substituted for $1...$n in the message text - */ - public void handleError(View view, int errorMessageId, ErrorSeverity severity, String... params); - - /** - * take the error view off the passed view. - * @param view - the view, where any bound components shall be reset using findById - */ - public void reset(View view) ; - - -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/ErrorHandlingFactory.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/ErrorHandlingFactory.java deleted file mode 100644 index c7ba1ac..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/ErrorHandlingFactory.java +++ /dev/null @@ -1,228 +0,0 @@ -package net.mantucon.baracus.errorhandling; - -import android.view.View; -import android.widget.TextView; -import net.mantucon.baracus.annotations.Bean; -import net.mantucon.baracus.lifecycle.Destroyable; -import net.mantucon.baracus.lifecycle.Initializeable; - -import java.util.*; - -import static net.mantucon.baracus.context.BaracusApplicationContext.resolveString; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 25.09.13 - * Time: 17:41 - * To change this template use File | Settings | File Templates. - */ -@Bean -public class ErrorHandlingFactory implements Initializeable, Destroyable{ - - // Error handlers - private Map> errorMap = new HashMap>(); - private final Map registeredHandlers = new HashMap(); - private final Set standardHandlers = new HashSet(); - - - - /** - * adds an error with a specific error level to the passed view. - * If an implementation of CustomErrorHandler is registered for the affectedResource, the error - * will be automatically routed to that field - * - * Notice : only to be used when you disregard automatic form validation - * - * @param container - the containing view of the resource - * @param affectedResource - the resource - * @param messageId - a message ID - * @param severity - the severity. can be used by the CustomErrorHandler. - * @param params - the parameters varags used to replace $1..$n tags in the message text - */ - public void addErrorToView(View container, int affectedResource, int messageId, ErrorSeverity severity, String... params) { - if (!errorMap.containsKey(container)) { - errorMap.put(container, new HashMap()); - } - - Map assignment = errorMap.get(container); - Object[] values = new Object[params != null ? params.length + 2 : 2]; - - int id = -1; - if (registeredHandlers.containsKey(affectedResource)) { - id = registeredHandlers.get(affectedResource).getId(); - } else { - id = affectedResource; - } - - values[0] = Integer.valueOf(messageId); - values[1] = severity; - - if (params != null && params.length > 0) { - int i = 2; - for (String param : params) { - values[i] = param; - i++; - } - } - - assignment.put(id, values); - } - - /** - * let all errors impact on the passed view. All bound fields and error handlers - * associated with the passed will highlight any error mappeable to the view. - * - * @param container - the containing view - */ - public void applyErrorsOnView(View container) { - if (!errorMap.containsKey(container)) { - return; - } - - Map assignments = errorMap.get(container); - - for (Map.Entry set: assignments.entrySet()) { - View v = container.findViewById(set.getKey()); - // First, handle specific custom handler for using own error handling - // technique - if (v != null && CustomErrorHandler.class.isAssignableFrom(v.getClass())) { - ErrorHandler customErrorHandler= (ErrorHandler) v; - if (customErrorHandler != null) { - Object[] params = set.getValue(); - if (params.length > 2) { - String[] strings =new String[params.length - 2]; - for (int i = 0; i < params.length-2; ++i){ - strings[i] = (String) params[i]; - } - Integer msgId = (Integer) params[0]; - ErrorSeverity severity = (ErrorSeverity) params[1]; - customErrorHandler.handleError(container, msgId, severity, strings); - } else { - Integer msgId = (Integer) params[0]; - ErrorSeverity severity = (ErrorSeverity) params[1]; - customErrorHandler.handleError(container, msgId, severity); - } - } - } else { - // Now try all standard handlers - for (StandardErrorHandler handler : standardHandlers) { - if (v != null && handler.canHandleView(v)) { - Object[] params = set.getValue(); - TextView t = (TextView) v; - Integer msgId = (Integer) params[0]; - ErrorSeverity severity = (ErrorSeverity) params[1]; - if (params.length > 2) { - String[] strings =new String[params.length - 2]; - for (int i = 0; i < params.length-2; ++i){ - strings[i] = String.valueOf(params[i]); - } - handler.handleError(v,msgId, severity, strings); - } else { - handler.handleError(v, msgId, severity); - } - } - } - } - } - } - - /** - * Determines, whether a view is sticked with errors - * @param v - the view to check - * @return true, if any bound errors to the view are found in the errorMap - */ - public boolean viewHasErrors(View v){ - if (errorMap.containsKey(v)){ - return errorMap.get(v).size() > 0; - } - return false; - } - - /** - * remove all errors from the passed view - * @param container - the view to clear - */ - public void resetErrors(View container) { - if (errorMap.containsKey(container)) { - Map assignments = errorMap.get(container); - - for (Integer key: assignments.keySet()) { - View v = container.findViewById(key); - - if (CustomErrorHandler.class.isAssignableFrom(v.getClass())) { - CustomErrorHandler customErrorHandler= (CustomErrorHandler) v; - // Object[] params =assignments.get(key); - customErrorHandler.reset(container); - } - - if (TextView.class.isAssignableFrom(v.getClass())) { - TextView t = (TextView) v; - t.setError(null); - } - } - - errorMap.put(container, new HashMap()); - } - } - - /** - * register an error handler. an error handler normally is bound to another field in - * the view. The error is raised by attaching an error to the field (view) component - * bound to the CustomErrorHandler's idToDisplayFor-property - * @param CustomErrorHandler - */ - public void registerCustomErrorHandler(CustomErrorHandler CustomErrorHandler) { - if (CustomErrorHandler.getIdToDisplayFor() != -1) { - registeredHandlers.put(CustomErrorHandler.getIdToDisplayFor(), CustomErrorHandler); - } - } - - /** - * unregister all error handlers for the passed field. If you use the - * net.mantucon.baracus.context.ManagedFragment component and set the View - * - * @param container - */ - public void unregisterCustomErrorHandlersForView(View container) { - errorMap.remove(container); - } - - /** - * register an error handling for the use of the general android error - * handling stuff - * - * @param handler - the handler - * @see TextEditErrorHandler - */ - public void registerStandardErrorHandler(StandardErrorHandler handler) { - standardHandlers.add(handler); - } - - - @Override - public void onDestroy() { - registeredHandlers.clear(); - standardHandlers.clear(); - errorMap.clear(); - } - - @Override - public void postConstruct() { - registerStandardErrorHandler(new TextEditErrorHandler()); - } - - /** - * @return the map with all custom error handlers - */ - public Map getRegisteredHandlers() { - return registeredHandlers; - } - - /** - * @return all standard handlers - */ - public Set getStandardHandlers() { - return standardHandlers; - } -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/ErrorSeverity.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/ErrorSeverity.java deleted file mode 100644 index 3651192..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/ErrorSeverity.java +++ /dev/null @@ -1,14 +0,0 @@ -package net.mantucon.baracus.errorhandling; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 20.09.13 - * Time: 07:55 - * - * Severity indicator for an error. currently (mostly) unused - * - */ -public enum ErrorSeverity { - HINT, WARNING, ERROR, FATAL -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/StandardErrorHandler.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/StandardErrorHandler.java deleted file mode 100644 index 8b3a281..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/StandardErrorHandler.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.mantucon.baracus.errorhandling; - -import android.view.View; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 25.09.13 - * Time: 17:47 - * - * Interface for bridging baracus error handling onto normal android - * error messaging. This technique mostly relies on the type (@see TextEditErrorHandler) - * - */ -public interface StandardErrorHandler extends ErrorHandler{ - - /** - * returns true, if the implementation class is able to make standard error - * handling on the passed view - * - * @param v - the view ask for - * @return true, if the handler is able to handle the passed component - */ - public boolean canHandleView(View v); - -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/TextEditErrorHandler.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/TextEditErrorHandler.java deleted file mode 100644 index f4a1749..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/errorhandling/TextEditErrorHandler.java +++ /dev/null @@ -1,40 +0,0 @@ -package net.mantucon.baracus.errorhandling; - -import android.view.View; -import android.widget.TextView; -import net.mantucon.baracus.context.BaracusApplicationContext; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 25.09.13 - * Time: 17:48 - * - * Generic Error handling component to be applied on all TextViews passed for validation (if there - * is any error to route to the view component) - * - * - */ -public class TextEditErrorHandler implements StandardErrorHandler { - - @Override - public boolean canHandleView(View v) { - return (v != null && TextView.class.isAssignableFrom(v.getClass())); // Bind this handler to be applied to all - // Text views - } - - @Override - public void handleError(View view, int errorMessageId, ErrorSeverity severity, String... params) { - // This function applies the error message to the passed text view - String message = BaracusApplicationContext.resolveString(errorMessageId, params); - TextView v = (TextView) view; - v.setError(message); - } - - @Override - public void reset(View view) { - // This function removes the error message from the passed view - TextView v = (TextView) view; - v.setError(null); - } -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/lifecycle/Destroyable.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/lifecycle/Destroyable.java deleted file mode 100644 index afe26c4..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/lifecycle/Destroyable.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.mantucon.baracus.lifecycle; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 03.04.13 - * - * Implement this interface, if You want to add a pre-destroy behaviour - * to Your bean - * - */ -public interface Destroyable { - - /** - * Lifecycle callback called on bean destruction - */ - public void onDestroy(); -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/lifecycle/Initializeable.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/lifecycle/Initializeable.java deleted file mode 100644 index 191397b..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/lifecycle/Initializeable.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.mantucon.baracus.lifecycle; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 10.07.12 - * - * Implement this bean, if You want to add some initialization behaviour to - * Your bean - * - */ -public interface Initializeable { - - /** - * lifecycle function used for lifecycle management after creation and variable injection of a bean - * - * use this function in order to perform pre-use-but-after-creation-done-steps - */ - void postConstruct(); -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/migr8/MigrationStep.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/migr8/MigrationStep.java deleted file mode 100644 index e4e5219..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/migr8/MigrationStep.java +++ /dev/null @@ -1,30 +0,0 @@ -package net.mantucon.baracus.migr8; - -import android.database.sqlite.SQLiteDatabase; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 03.08.12 - * Time: 10:03 - * - * Automatic sequential database migration. A migration step consists of several DDL commands - * (CREATE TABLE, DROP TABLE, ALTER TABLE). For every release of your software with database - * modification you should have one Migrationstep. - * - * You should have an initial implementation creating your database and register it - * in your openHelper. This initial implementation must not use version 0, which is - * used by baracus in order to create a configuration table. - * - * Further versions should be added with increasing version numbers. - * - * @see net.mantucon.baracus.dao.BaracusOpenHelper for an example OpenHelper - * @see ModelVersion000 for an example MigrationStep - * - */ -public interface MigrationStep { - - void applyVersion(SQLiteDatabase db); - - int getModelVersionNumber(); -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/migr8/ModelVersion000.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/migr8/ModelVersion000.java deleted file mode 100644 index 466b2d5..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/migr8/ModelVersion000.java +++ /dev/null @@ -1,30 +0,0 @@ -package net.mantucon.baracus.migr8; - -import android.database.sqlite.SQLiteDatabase; -import net.mantucon.baracus.model.ConfigurationParameter; -import net.mantucon.baracus.util.Logger; - -/** - * Initial Model creating the configuration table to be used by the configuration DAO. - * - * This table enables you to store key-value-pairs into your database. - */ -public class ModelVersion000 implements MigrationStep { - - private static final Logger logger = new Logger(ModelVersion000.class); - - @Override - public void applyVersion(SQLiteDatabase db) { - - String stmt = "CREATE TABLE " + ConfigurationParameter.TABLE_CONFIGURATION - + "( "+ ConfigurationParameter.idCol.fieldName+" INTEGER PRIMARY KEY" - + ", "+ ConfigurationParameter.configParamCol.fieldName+ " TEXT" - + ", "+ ConfigurationParameter.configParamValueCol.fieldName+ " TEXT)"; - logger.info(stmt); - db.execSQL(stmt); } - - @Override - public int getModelVersionNumber() { - return 0; - } -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/model/ConfigurationParameter.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/model/ConfigurationParameter.java deleted file mode 100644 index d143b60..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/model/ConfigurationParameter.java +++ /dev/null @@ -1,85 +0,0 @@ -package net.mantucon.baracus.model; - -import net.mantucon.baracus.orm.AbstractModelBase; -import net.mantucon.baracus.orm.Field; -import net.mantucon.baracus.orm.FieldList; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 24.09.12 - * Time: 15:49 - * To change this template use File | Settings | File Templates. - */ -public class ConfigurationParameter extends AbstractModelBase { - - public static final String TABLE_CONFIGURATION = "configuration"; - - private static int prefix=0; - - private String configParameter; - private String configParameterValue; - - public static final FieldList fieldList = new FieldList(ConfigurationParameter.class.getSimpleName()); - public static final Field configParamCol = new Field("config_parameter", AbstractModelBase.fieldList.size() + prefix++); - public static final Field configParamValueCol = new Field("config_parameter_value", AbstractModelBase.fieldList.size() + prefix++); - - static { - fieldList.add(AbstractModelBase.fieldList); - fieldList.add(configParamCol); - fieldList.add(configParamValueCol); - } - - public ConfigurationParameter() { - super(TABLE_CONFIGURATION); - } - - public String getConfigParameter() { - return configParameter; - } - - public void setConfigParameter(String configParameter) { - this.configParameter = configParameter; - } - - public String getConfigParameterValue() { - return configParameterValue; - } - - public void setConfigParameterValue(String configParameterValue) { - this.configParameterValue = configParameterValue; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof ConfigurationParameter)) { - return false; - } - if (!super.equals(o)) { - return false; - } - - ConfigurationParameter that = (ConfigurationParameter) o; - - if (!configParameter.equals(that.configParameter)) { - return false; - } - if (configParameterValue != null ? !configParameterValue.equals(that.configParameterValue) : that.configParameterValue != null) { - return false; - } - - - return true; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + configParameter.hashCode(); - result = 31 * result + (configParameterValue != null ? configParameterValue.hashCode() : 0); - return result; - } -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/AbstractModelBase.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/AbstractModelBase.java deleted file mode 100644 index ffefa66..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/AbstractModelBase.java +++ /dev/null @@ -1,160 +0,0 @@ -package net.mantucon.baracus.orm; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 24.09.12 - * Time: 08:10 - * - * Base class to all persistence objects. You want a table based persistence bean? - * Simply inherit this class and add your fields to the field list. - * - * this very static way of wiring the table is a very fast one. - * - * After defining the model bean, be sure that you have a @see MigrationStep creating the table and - * defining a DAO bean managing the persistence access. - * - * Example : - - public class ConfigurationParameter extends AbstractModelBase { - - public static final String TABLE_CONFIGURATION = "configuration"; - - private static int prefix=0; - - private String configParameter; - private String configParameterValue; - - public static final FieldList fieldList = new FieldList(ConfigurationParameter.class.getSimpleName()); - public static final Field configParamCol = new Field("config_parameter",AbstractModelBase.fieldList.size() + prefix++); - public static final Field configParamValueCol = new Field("config_parameter_value",AbstractModelBase.fieldList.size() + prefix++); - - static { - fieldList.add(AbstractModelBase.fieldList); - fieldList.add(configParamCol); - fieldList.add(configParamValueCol); - } - - public ConfigurationParameter() { - super(TABLE_CONFIGURATION); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof ConfigurationParameter)) { - return false; - } - if (!super.equals(o)) { - return false; - } - - ConfigurationParameter that = (ConfigurationParameter) o; - - if (!configParameter.equals(that.configParameter)) { - return false; - } - - if (configParameterValue != null ? ! - configParameterValue.equals(that.configParameterValue) : that.configParameterValue != null) - { return false; } - - return true; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + configParameter.hashCode(); - result = 31 * result + (configParameterValue != null ? configParameterValue.hashCode() : 0); - return result; - } - } - - - * - * - * - */ -public abstract class AbstractModelBase implements Identifiable { - - /** - * the field list of the entity. - */ - - public static final Field idCol = new Field("id",0, true); - - public static final FieldList fieldList = new FieldList(AbstractModelBase.class.getSimpleName(), idCol); - -/* static { - fieldList.add(idCol); - }*/ - - protected Long id; - private boolean isTransient = true; - private final String tableName; - - - protected AbstractModelBase(String tableName) { - this.tableName = tableName; - } - - public boolean isTransient() { - return isTransient; - } - - public void setTransient(boolean aTransient) { - isTransient = aTransient; - } - - public String getTableName() { - return tableName; - } - - @Override - public Long getId() { - return id; - } - - @Override - public void setId(Long id) { - this.id = id; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof AbstractModelBase)) { - return false; - } - - AbstractModelBase that = (AbstractModelBase) o; - - if (id != null ? !id.equals(that.id) : that.id != null) { - return false; - } - if (!tableName.equals(that.tableName)) { - return false; - } - - return true; - } - - @Override - public int hashCode() { - int result = id != null ? id.hashCode() : 0; - result = 31 * result + tableName.hashCode(); - return result; - } - - @Override - public String toString() { - return "AbstractModelBase{" + - "id=" + id + - ", isTransient=" + isTransient + - ", tableName='" + tableName + '\'' + - '}'; - } -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/Field.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/Field.java deleted file mode 100644 index e7648c5..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/Field.java +++ /dev/null @@ -1,84 +0,0 @@ -package net.mantucon.baracus.orm; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 24.09.12 - * Time: 11:18 - * - * indicate a field. notice, no type information is needed here, because of the - * use of rowmappers in the dao layer. - * - */ -public class Field implements Comparable { - /** - * field index, increment by one per field, set default to AbstractModelBase.fieldList.size() , see AbstractModelBase example for details - */ - public final int fieldIndex; - /** - * the name of the field in the db - */ - public final String fieldName; - - /** - * indicates a key attribute. normally - when deriving AbstractModelBase - you can use the constructor - * using fieldName and fieldIndex or just set it to false - */ - public final boolean isKeyAttribute; - - /** - * Constructor for regular fields. Assumes, that your field is not part of the key. - * - * @param fieldName - db name of the field - * @param fieldIndex - the index of the field in the list - */ - public Field(String fieldName, int fieldIndex) { - this.fieldName = fieldName; - this.fieldIndex = fieldIndex; - isKeyAttribute = false; - } - - - /** - * Constructor carrying a key information. normally the other constructor should fit your purpose. - * - * @param fieldName - db name of the field - * @param fieldIndex - the index of the field in the list - * @param isKeyAttribute - key attribute indicator - */ - public Field(String fieldName, int fieldIndex, boolean isKeyAttribute) { - this.fieldName = fieldName; - this.fieldIndex = fieldIndex; - this.isKeyAttribute = isKeyAttribute; - } - - @Override - public final String toString() { - return fieldName; - } - - @Override - public boolean equals(Object o) { - if (this == o) { return true; } - if (!(o instanceof Field)) { return false; } - - Field field = (Field) o; - - if (fieldIndex != field.fieldIndex) { return false; } - if (fieldName != null ? !fieldName.equals(field.fieldName) : field.fieldName != null) { return false; } - - return true; - } - - @Override - public int hashCode() { - int result = fieldIndex; - result = 31 * result + (fieldName != null ? fieldName.hashCode() : 0); - return result; - } - - @Override - public int compareTo(Field field) { - return (Integer.valueOf(this.fieldIndex)).compareTo(Integer.valueOf(field.fieldIndex)); - } -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/FieldList.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/FieldList.java deleted file mode 100644 index 5b71f40..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/FieldList.java +++ /dev/null @@ -1,163 +0,0 @@ -package net.mantucon.baracus.orm; - -import net.mantucon.baracus.util.Logger; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 24.09.12 - * Time: 11:20 - * - * The field list of an entity. - * - */ -public class FieldList { - - public static class FieldListLockedException extends RuntimeException { - - } - - private final List fields = new ArrayList(); - - private String binder; - - boolean locked = false; - - public FieldList(String binder) { - this.binder = binder; - } - - /** - * Locing constructor. Add all fields here. After that, this instance is locked - * for modifications. - * - * @param binder - the binding entity - * @param fieldList - the fields to add - */ - public FieldList(String binder, Field... fieldList) { - - if (locked) { - throw new FieldListLockedException(); - } - - this.binder = binder; - for (Field field : fieldList) { - add(field); - } - locked = true; - } - - private static final Logger logger = new Logger(FieldList.class); - - private boolean dirty=true; - - public void add(Field field) { - checkField(field); - fields.add(field); - dirty=true; - } - - private void checkField(Field field) { - if (fields.contains(field)) { - logger.fatal("Field $1 already present in list", field); - } - } - - public void add(List fields) { - for (Field f : fields) { - checkField(f); - } - - this.fields.addAll(fields); - dirty=true; - } - - public void add(FieldList fieldList) { - add(fieldList.fields); - dirty=true; - } - - public String[] getFieldNames() { - String[] result = new String[getFields().size()]; - int i = 0; - for (Field f : getFields()) { - result[i++] = f.fieldName; - } - return result; - } - - public String getFieldNamesAsString() { - StringBuilder sb = new StringBuilder(); - for (Field f : getFields()) { - sb.append(f.fieldName).append(","); - } - String result = sb.toString(); - return result.substring(0,result.length() -1); - } - - public String getFieldNamesAsStringWithoutKeyColumn() { - StringBuilder sb = new StringBuilder(); - for (Field f : getFields()) { - if (!f.isKeyAttribute) { - sb.append(f.fieldName).append(","); - } - } - String result = sb.toString(); - return result.substring(0,result.length() -1); - } - - public int size() { - return fields.size(); - } - - /** - * @return a string containing all field parameters as JDBC variables - */ - public String getParamsAsString() { - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < fields.size(); i++) { - sb.append("?,"); - } - - String result = sb.toString(); - return result.substring(0,result.length() -1); - } - - /** - * @return a string containing all field parameters as JDBC variables except the key column - */ - public String getParamsAsStringWithoutKeyColumn() { - StringBuilder sb = new StringBuilder(); - for (Field f : fields) { - if (!f.isKeyAttribute) { - sb.append("?,"); - } - } - String result = sb.toString(); - return result.substring(0,result.length() -1); - } - - public List getFields() { - if (dirty) { - Collections.sort(fields); -// validate(); - dirty = false; - } - return fields; - } - - public void validate() { - int i = 0; - for (Field f : fields) { - if (i != f.fieldIndex) { - logger.warn("WARNING! $1's field $2 is placed at $3, but should be on $4",binder , f.fieldName, f.fieldIndex, i); -// f.fieldIndex = i; - } - ++i; - } - } -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/Identifiable.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/Identifiable.java deleted file mode 100644 index 28a84fb..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/Identifiable.java +++ /dev/null @@ -1,19 +0,0 @@ -package net.mantucon.baracus.orm; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 24.09.12 - * Time: 07:31 - * - * Interface indicating that your entity bean is identifiable by a standard long id. - * All deriving classes of AbstractModelBase will be identifiable, having a surrogate long id. - * - * - */ -public interface Identifiable { - - public Long getId(); - public void setId(Long id); - -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/LazyCollection.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/LazyCollection.java deleted file mode 100644 index 979ae6c..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/LazyCollection.java +++ /dev/null @@ -1,190 +0,0 @@ -package net.mantucon.baracus.orm; - -import java.util.*; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 24.09.12 - * Time: 15:18 - * - * Lazy collection implementation. This collection is fitted with and LazyLoader implementation - * taking care of the load of the data on the first access to this collection. - * - */ -public class LazyCollection implements List { - - /** - * Lazy Loader interface. Use this lazy loader in order to load the collection lazily after - * the first access. - * - * @param - */ - public static interface LazyLoader { - public List loadReference(); - } - - - private static enum CollectionState { - Armed, - Loaded - } - - private CollectionState collectionState = CollectionState.Armed; - - private final LazyLoader lazyLoader; - - /** - * Constructor. A LazyCollection must be fitted with a lazy loading helper - * - * @param lazyLoader - the component managing the load of the collection on first access. - */ - public LazyCollection(LazyLoader lazyLoader) { - this.lazyLoader = lazyLoader; - } - - - private ArrayList referencedData = new ArrayList(); - - /** - * Helper function checking if a lazy load has to be performed. - * - * If a lazy loader is armed, it will call the loadReference function on the - * lazy loader on first access. - * - */ - private void checkReferencedData() { - synchronized (collectionState) { - if (collectionState == CollectionState.Armed) { - collectionState = CollectionState.Loaded; - referencedData.addAll(lazyLoader.loadReference()); - } - } - } - - - public boolean add(T object) { - checkReferencedData(); - return referencedData.add(object); - } - - public boolean addAll(int index, Collection collection) { - checkReferencedData(); - return referencedData.addAll(index, collection); - } - - public List subList(int start, int end) { - checkReferencedData(); - return referencedData.subList(start, end); - } - - public T remove(int index) { - checkReferencedData(); - return referencedData.remove(index); - } - - public int lastIndexOf(Object object) { - checkReferencedData(); - return referencedData.lastIndexOf(object); - } - - public int size() { - checkReferencedData(); - return referencedData.size(); - } - - public boolean contains(Object object) { - checkReferencedData(); - return referencedData.contains(object); - } - - public T get(int index) { - checkReferencedData(); - return referencedData.get(index); - } - - public void ensureCapacity(int minimumCapacity) { - checkReferencedData(); - referencedData.ensureCapacity(minimumCapacity); - } - - public void add(int index, T object) { - checkReferencedData(); - referencedData.add(index, object); - } - - public Iterator iterator() { - checkReferencedData(); - return referencedData.iterator(); - } - - public ListIterator listIterator(int location) { - checkReferencedData(); - return referencedData.listIterator(location); - } - - public boolean containsAll(Collection collection) { - checkReferencedData(); - return referencedData.containsAll(collection); - } - - public T[] toArray(T[] contents) { - checkReferencedData(); - return referencedData.toArray(contents); - } - - public void clear() { - checkReferencedData(); - referencedData.clear(); - } - - public boolean addAll(Collection collection) { - checkReferencedData(); - return referencedData.addAll(collection); - } - - public ListIterator listIterator() { - checkReferencedData(); - return referencedData.listIterator(); - } - - public boolean removeAll(Collection collection) { - checkReferencedData(); - return referencedData.removeAll(collection); - } - - public void trimToSize() { - checkReferencedData(); - referencedData.trimToSize(); - } - - public int indexOf(Object object) { - checkReferencedData(); - return referencedData.indexOf(object); - } - - public Object[] toArray() { - checkReferencedData(); - return referencedData.toArray(); - } - - public T set(int index, T object) { - checkReferencedData(); - return referencedData.set(index, object); - } - - public boolean retainAll(Collection collection) { - checkReferencedData(); - return referencedData.retainAll(collection); - } - - public boolean isEmpty() { - checkReferencedData(); - return referencedData.isEmpty(); - } - - public boolean remove(Object object) { - checkReferencedData(); - return referencedData.remove(object); - } -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/LazyReference.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/LazyReference.java deleted file mode 100644 index 759f3d0..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/LazyReference.java +++ /dev/null @@ -1,51 +0,0 @@ -package net.mantucon.baracus.orm; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 24.09.12 - * Time: 15:34 - * Lazy reference implementation. Allows You to reference a collection lazily. - * - * Use this function in DAO-RowMappers in order to enable lazy on-access loading on - * referenced entities, which are not bound to a container (e.g. 1:1 ref Customer to BankAccount) - * or use this to describe a n:1 relation in the n partner (e.g. BankAccount to Bank) - */ -public class LazyReference implements Reference { - - private enum CollectionState { - Armed, - Loaded - } - - private CollectionState collectionState = CollectionState.Armed; - - private T instance = null; - - /* - The reference loader responsible to perform the lazy object access - */ - private final ReferenceLoader referenceLoader; - - public LazyReference(ReferenceLoader referenceLoader) { - this.referenceLoader = referenceLoader; - } - - @Override - public T getObject() { - if (collectionState == CollectionState.Armed){ - synchronized (this) { - collectionState = CollectionState.Loaded; - instance = referenceLoader.loadObject(); - } - } - return instance; - } - - @Override - public Long getObjectRefId() { - return referenceLoader.getId(); - } - - -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/ObjectReference.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/ObjectReference.java deleted file mode 100644 index 5c406e7..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/ObjectReference.java +++ /dev/null @@ -1,36 +0,0 @@ -package net.mantucon.baracus.orm; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 26.09.12 - * Time: 10:10 - * Object Reference. Use this item in order to set a discrete - non-lazy - object referenc - * to an object. Use this item esp. when setting a reference to another entity in order - * to persist the reference. - */ -public class ObjectReference implements Reference{ - - private T object; - - public ObjectReference(T object) { - this.object = object; - } - - public ObjectReference() { - } - - @Override - public T getObject() { - return object; - } - - @Override - public Long getObjectRefId() { - return object.getId(); - } - - public void setObject(T object) { - this.object = object; - } -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/Reference.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/Reference.java deleted file mode 100644 index 6a8358b..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/Reference.java +++ /dev/null @@ -1,22 +0,0 @@ -package net.mantucon.baracus.orm; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 26.09.12 - * Time: 10:10 - * Object reference. This is a type-to-type reference helper. It helps you - * to have lazy references without any dynamic proxying. The price you pay - * is accessing the Reference via an additional accessor (e.g. customer.getBankAccount().getObject()); - * - * When setting an instane of a reference in your code in order to save - * it, use the ObjectReference implementation. - * - * When writing a dao mapping function, use the lazy reference carrying the lazy loading information to - * post-load the reference object on first access. - * - */ -public interface Reference { - T getObject(); - Long getObjectRefId(); -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/ReferenceLoader.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/ReferenceLoader.java deleted file mode 100644 index 0301459..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/ReferenceLoader.java +++ /dev/null @@ -1,42 +0,0 @@ -package net.mantucon.baracus.orm; - -import net.mantucon.baracus.dao.BaseDao; - -/** - * Reference loader. Lazy Loading for Objects. Use this in rowMapper functions. This item - * needs to have the DAO passed using the getById() function of the DAO in order to load - * the item via it's id - *

- * example : - *

- * public CalculationSpreadSheet from(Cursor c) { - * CalculationSpreadSheet result = new CalculationSpreadSheet(); - * ... - * final Long bankAccountId = c.getLong(bankAccountCol.fieldIndex); - * result.setBankAccountReference(new LazyReference(new ReferenceLoader(bankAccountDao, bankAccountId))); - * ... - * - * @param - */ -public class ReferenceLoader { - private final BaseDao dao; - private final Long id; - - public ReferenceLoader(BaseDao dao, Long id) { - this.dao = dao; - this.id = id; - } - - /** - * load the referenced entity NOW and return it. This function will be triggered by - * the lazy reference. - * @return - */ - public T loadObject() { - return dao.getById(id); - } - - public Long getId() { - return id; - } -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/Timestamped.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/Timestamped.java deleted file mode 100644 index 6d069c3..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/orm/Timestamped.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.mantucon.baracus.orm; - -import java.util.Date; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 24.09.12 - * Time: 07:32 - * - * Indicates an entity bean carrying a modification timestamp - * - */ -public interface Timestamped { - - public Date getCreationDate(); - public Date getLastModificationDate(); - public void setCreationDate(Date date); - public void setLastModificationDate(Date date); -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/ConfigurationChangeListener.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/ConfigurationChangeListener.java deleted file mode 100644 index 649a938..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/ConfigurationChangeListener.java +++ /dev/null @@ -1,27 +0,0 @@ -package net.mantucon.baracus.signalling; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 27.03.13 - * Time: 11:22 - * - * Use this class to - * - */ -@Deprecated -public abstract class ConfigurationChangeListener{ - - private final String configurationElementName; - - public ConfigurationChangeListener(String configurationElement) { - this.configurationElementName = configurationElement; - } - - public String getConfigurationElementName() { - return configurationElementName; - } - - public abstract void onChange(); - -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/DataChangeAwareComponent.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/DataChangeAwareComponent.java deleted file mode 100644 index 8fd9faf..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/DataChangeAwareComponent.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.mantucon.baracus.signalling; - - -import net.mantucon.baracus.orm.AbstractModelBase; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 27.01.13 - * Time: 12:18 - * Implement this function to be aware of recordset changes on an certain entity type - * Then, you can register it to the context and the function will be fired on each change - * on the recordset you are listening to. - */ -public interface DataChangeAwareComponent { - public void onChange(T changedInstance); -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/DataSetChangeAwareComponent.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/DataSetChangeAwareComponent.java deleted file mode 100644 index 36a65e5..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/DataSetChangeAwareComponent.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.mantucon.baracus.signalling; - - -import net.mantucon.baracus.orm.AbstractModelBase; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 27.01.13 - * Time: 12:18 - * Implement this function to be aware of recordset changes on an certain entity type - * Then, you can register it to the context and the function will be fired on each change - * on the recordset you are listening to. - */ -public interface DataSetChangeAwareComponent { - public void onChange(); -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/DeleteAwareComponent.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/DeleteAwareComponent.java deleted file mode 100644 index 067936e..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/DeleteAwareComponent.java +++ /dev/null @@ -1,14 +0,0 @@ -package net.mantucon.baracus.signalling; - -import net.mantucon.baracus.orm.AbstractModelBase; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 27.01.13 - * Time: 12:18 - * be aware of deletions on a certain entity type's recordset. @see DataSetChangeAwareComponent - */ -public interface DeleteAwareComponent { - public void onDelete(); -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/GenericEvent.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/GenericEvent.java deleted file mode 100644 index 2f297c7..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/GenericEvent.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.mantucon.baracus.signalling; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 27.06.13 - * Time: 19:13 - * To change this template use File | Settings | File Templates. - */ -public interface GenericEvent { -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/GenericEventAwareComponent.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/GenericEventAwareComponent.java deleted file mode 100644 index 771fa4d..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/signalling/GenericEventAwareComponent.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.mantucon.baracus.signalling; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 27.06.13 - * Time: 19:13 - * To change this template use File | Settings | File Templates. - */ -public interface GenericEventAwareComponent { - void handleEvent(T event); -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/ui/ConstrainedEditText.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/ui/ConstrainedEditText.java deleted file mode 100644 index ca77714..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/ui/ConstrainedEditText.java +++ /dev/null @@ -1,66 +0,0 @@ -package net.mantucon.baracus.ui; - -import android.content.Context; -import android.util.AttributeSet; -import android.widget.EditText; -import android.widget.TextView; -import net.mantucon.baracus.context.BaracusApplicationContext; -import net.mantucon.baracus.util.Logger; -import net.mantucon.baracus.validation.ConstrainedView; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 20.09.13 - * Time: 07:54 - * To change this template use File | Settings | File Templates. - */ -public class ConstrainedEditText extends EditText implements ConstrainedView { - - private String validators; - - public ConstrainedEditText(Context context) { - super(context); - } - - public ConstrainedEditText(Context context, AttributeSet attrs) { - super(context, attrs); - parseAttribs(attrs); - } - - public ConstrainedEditText(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - parseAttribs(attrs); - } - - private void parseAttribs(AttributeSet attributeSet) { - - Logger log = new Logger(this.getClass()); - log.info("---------------------------------"); - int i = 0; - boolean cont = true; - while (i < attributeSet.getAttributeCount() && cont) { - log.info("$1 -> $2 -> $3", attributeSet.getAttributeName(i), attributeSet.getAttributeValue(i), attributeSet.getPositionDescription()); - if ("validatedBy".equals(attributeSet.getAttributeName(i))) { - this.validators = attributeSet.getAttributeValue(i); - log.info("VALIDATORS HAS BEEN SET TO $1", validators); - cont = false; - } - ++i; - } - - BaracusApplicationContext.verifyValidators(validators); - - log.info("---------------------------------"); - } - - - @Override - public String getCurrentValue() { - return this.getText() != null ? getText().toString() : null; - } - - public String getValidators() { - return validators; - } -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/ui/ErrorView.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/ui/ErrorView.java deleted file mode 100644 index 10ba158..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/ui/ErrorView.java +++ /dev/null @@ -1,107 +0,0 @@ -package net.mantucon.baracus.ui; - -import android.content.Context; -import android.graphics.Color; -import android.util.AttributeSet; -import android.view.View; -import android.widget.TextView; -import net.mantucon.baracus.R; -import net.mantucon.baracus.context.BaracusApplicationContext; -import net.mantucon.baracus.errorhandling.CustomErrorHandler; -import net.mantucon.baracus.errorhandling.ErrorHandler; -import net.mantucon.baracus.errorhandling.ErrorSeverity; -import net.mantucon.baracus.util.Logger; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 20.09.13 - * Time: 07:54 - * To change this template use File | Settings | File Templates. - */ -public class ErrorView extends TextView implements CustomErrorHandler { - - private int displayMessageFor; - private boolean highlightTarget; - private int originalColour; - - public ErrorView(Context context) { - super(context); - BaracusApplicationContext.registerCustomErrorHandler(this); - } - - public ErrorView(Context context, AttributeSet attrs) { - super(context, attrs); - parseAttribs(attrs); - BaracusApplicationContext.registerCustomErrorHandler(this); - } - - public ErrorView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - parseAttribs(attrs); - BaracusApplicationContext.registerCustomErrorHandler(this); - } - - private void parseAttribs(AttributeSet attributeSet) { - - Logger log = new Logger(this.getClass()); - log.info("---------------------------------"); - for (int i = 0; i < attributeSet.getAttributeCount(); ++i) { - log.info("$1 -> $2 -> $3", attributeSet.getAttributeName(i), attributeSet.getAttributeValue(i), attributeSet.getPositionDescription()); - if ("displayMessageFor".equals(attributeSet.getAttributeName(i))) { - this.displayMessageFor = attributeSet.getAttributeResourceValue(i,-1); - log.info("DISPLAY MESSAGE HAS BEEN SET TO $1", displayMessageFor); - } - - if ("highlightTarget".equals(attributeSet.getAttributeName(i))) { - this.highlightTarget = "true".equals(attributeSet.getAttributeValue(i)); - log.info("HIGHLIGHT TARGET HAS BEEN SET TO $1", highlightTarget); - } - - } - log.info("---------------------------------"); - } - - /** - * @return the ID of the component, whose errors affect this item - */ - public int getDisplayMessageFor() { - return displayMessageFor; - } - - /** - * @return true, if the referenced display shall be highlighted in case of an error - */ - public Boolean getHighlightTarget() { - return highlightTarget; - } - - @Override - public void handleError(View view, int errorMessageId, ErrorSeverity severity, String... params) { - String errorMessage = BaracusApplicationContext.resolveString(errorMessageId, params); - ErrorView visualRepresentation = (ErrorView ) view.findViewById(this.getId()); - visualRepresentation.setText(errorMessage); - - if (highlightTarget && displayMessageFor != -1) { - View target = view.findViewById(getIdToDisplayFor()); - originalColour = target.getDrawingCacheBackgroundColor(); - target.setBackgroundColor(Color.argb(100, 255, 100, 100)); - } - } - - @Override - public void reset(View view) { - this.setText(""); - - if (highlightTarget && displayMessageFor != -1) { - View target = view.findViewById(getIdToDisplayFor()); - target.setBackgroundColor(originalColour); - } - } - - @Override - public int getIdToDisplayFor() { - return displayMessageFor; - } - -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/util/DBBackup.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/util/DBBackup.java deleted file mode 100644 index cc888a6..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/util/DBBackup.java +++ /dev/null @@ -1,175 +0,0 @@ -package net.mantucon.baracus.util; - -import android.database.sqlite.SQLiteDatabase; -import android.os.Environment; -import net.mantucon.baracus.context.BaracusApplicationContext; -import net.mantucon.baracus.dao.BaracusOpenHelper; - -import java.io.*; -import java.nio.channels.FileChannel; -import java.util.Date; - -/** - * Make a database backup or restore a database in a running application. If you want to make - * use of this feature, you must fully rely on BaracusApplicationContext managed database handling - * or be VERY sure that you have all handles under control! - */ -public class DBBackup { - - - public static class BackupResult { - private final long size; - private final String backupDbName; - private final boolean successful; - private String reason; - - public BackupResult(long size, String backupDbName) { - this.size = size; - this.backupDbName = backupDbName; - this.successful = true; - } - - public BackupResult(long size, String backupDbName, String reason) { - this.size = size; - this.backupDbName = backupDbName; - this.successful = false; - this.reason = reason; - } - - public long getSize() { - return size; - } - - public String getBackupDbName() { - return backupDbName; - } - - public boolean isSuccessful() { - return successful; - } - - public String getReason() { - return reason; - } - } - - private DBBackup() { - // Utility class constructor - } - - public static BackupResult performDatabaseBackup() { - - final String currentDBPath = BaracusApplicationContext.getDatabasePath(); - BaracusOpenHelper openHelper = BaracusApplicationContext.connectOpenHelper(); - - // final String currentDBPath = "//data//net/mantucon/databases/"+OpenHelper.DATABASE_NAME; - final String backupDBPath = DateUtil.toReverseDate(new Date()) + "_" + openHelper.getDatabaseName() + ".tac"; - - try { - File sd = Environment.getExternalStorageDirectory(); - - if (sd.canWrite()) { - File currentDB = new File(currentDBPath); - File backupDB = new File(sd, backupDBPath); - - if (currentDB.exists()) { - FileChannel src = null; - FileChannel dst = null; - long size = 0; - try { - src = new FileInputStream(currentDB).getChannel(); - dst = new FileOutputStream(backupDB).getChannel(); - size = src.size(); - dst.transferFrom(src, 0, size); - } finally { - - if (src != null) { - src.close(); - } - if (dst != null) { - dst.close(); - } - } - return new BackupResult(size, backupDBPath); - - } else { - return new BackupResult(0, backupDBPath, "Database source file " + currentDBPath + " was not found!"); - } - } else { - return new BackupResult(0, backupDBPath, "SD path " + sd + " is write protected!"); - } - } catch (IOException e) { - return new BackupResult(0, backupDBPath, e.getMessage()); - } - } - - - public static BackupResult restore(String dbFileName) { - final String currentDBPath = BaracusApplicationContext.getDatabasePath(); - - try { - File sd = Environment.getExternalStorageDirectory(); - File currentDB = new File(currentDBPath); - File backupDB = new File(sd, dbFileName); - - if (!currentDB.canWrite()) { - new Logger(DBBackup.class).error("DB NOT WRITEABLE"); - } else { - currentDB.delete(); - // This is necessary to avoid any loitering DB Refs in GC! - System.gc(); - } - - if (backupDB.exists()) { - if (isValidDb(backupDB.getAbsolutePath())) { - BaracusApplicationContext.destroy(true); - FileChannel src = new FileInputStream(backupDB).getChannel(); - FileChannel dst = new FileOutputStream(currentDB).getChannel(); - Long size = src.size(); - dst.transferFrom(src, 0, size); - src.close(); - dst.close(); - return new BackupResult(size, dbFileName); - } else { - return new BackupResult(0, dbFileName, " is not a valid database!"); - } - } else { - return new BackupResult(0, dbFileName, "File does not exist"); - } - } catch (IOException e) { - return new BackupResult(0, dbFileName, e.getMessage()); - } finally { - BaracusApplicationContext.initApplicationContext(); - BaracusApplicationContext.make(); - } - } - - public static boolean isValidDb(String dbFile) { - SQLiteDatabase db = null; - boolean valid = true; - try { - db = SQLiteDatabase.openDatabase(dbFile, null, SQLiteDatabase.OPEN_READONLY); - valid = true; - } catch (Exception e) { - valid = false; - } finally { - if (db != null && db.isOpen()) { - db.close(); - } - } - return valid; - } - - - public static String[] getAvailableFiles() { - File sd = Environment.getExternalStorageDirectory(); - return sd.list(new FilenameFilter() { - @java.lang.Override - public boolean accept(File dir, String filename) { - final String path = dir.getAbsolutePath() + File.separator + filename; - return (filename.endsWith(".tac")) && !new File(path).isDirectory() && isValidDb(path); - } - }); - } - -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/util/DateUtil.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/util/DateUtil.java deleted file mode 100644 index c626efc..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/util/DateUtil.java +++ /dev/null @@ -1,95 +0,0 @@ -package net.mantucon.baracus.util; - -import android.text.format.DateFormat; -import net.mantucon.baracus.context.BaracusApplicationContext; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Comparator; -import java.util.Date; -import java.util.GregorianCalendar; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 17.10.12 - * Time: 06:02 - * To change this template use File | Settings | File Templates. - */ -public class DateUtil { - - protected DateUtil() { - // Protection Constructor - } - - public static class DateFormatException extends RuntimeException { - public DateFormatException(Throwable throwable) { - super(throwable); - } - } - - /** - * reverts a date string back into a date usign the system's date format - * @param date - the date string - * @return the parsed date - */ - public static Date toDate(String date) { - try { - return DateFormat.getDateFormat(BaracusApplicationContext.getContext()).parse(date); - } catch (ParseException e) { - throw new DateFormatException(e); - } - } - - public static class DateComparator implements Comparator { - @Override - public int compare(Date date, Date date1) { - if (date1 == null && date == null) { - return 0; - } - - if (date1 == null) { - return 1; - } - - if (date == null) { - return -1; - } - - return java.lang.Long.valueOf(date.getTime()).compareTo(Long.valueOf(date1.getTime())); - } - } - - public static String toEuropeanDate(Date date) { - return date != null ? new SimpleDateFormat("dd.MM.yyyy").format(date) : ""; - } - - public static Date fromEuropeanDate(String date) { - try { - return date != null ? new SimpleDateFormat("dd.MM.yyyy").parse(date) : null; - } catch (ParseException e) { - throw new DateFormatException(e); - } - } - - public static String toReverseDate(Date date) { - return date != null ? new SimpleDateFormat("yyyyMMdd_hhmmss").format(date) : ""; - } - - public static Date addOneYear(Date in) { - Calendar cal = new GregorianCalendar(); - cal.setTime(in); - cal.add(Calendar.YEAR, 1); - return cal.getTime(); - - } - - /** - * @return today's date - */ - public static Date today() { - return fromEuropeanDate(toEuropeanDate(new Date())); - } - -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/util/Logger.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/util/Logger.java deleted file mode 100644 index cc5d411..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/util/Logger.java +++ /dev/null @@ -1,324 +0,0 @@ -package net.mantucon.baracus.util; - -import android.util.Log; - -/** - * Created by IntelliJ IDEA. - * User: mnt - * Date: 07.02.12 - * Time: 19:21 - * very basic logger providin a log4j style combined with a slf4j vararg styled logging function - */ -public class Logger { - - private static String TAG = "PLEASE SET TAG"; - - private final String loggerId; - - enum Level { - ERROR, - WARN, - INFO, - DEBUG, - TRACE, - } - - private static Level level = Level.DEBUG; - - private static LogTarget logTarget = new AndroidLogger(); - - public static void enableTestLogger() { - logTarget = new SysOutLogger(); - } - - public static interface LogTarget { - public void debug(String tag, String msg, Throwable t); - public void debug(String tag, String msg); - public void info(String tag, String msg, Throwable t); - public void info(String tag, String msg); - public void warn(String tag, String msg, Throwable t); - public void warn(String tag, String msg); - public void error(String tag, String msg, Throwable t); - public void error(String tag, String msg); - public void trace(String tag, String msg, Throwable t); - public void trace(String tag, String msg); - } - - public static class AndroidLogger implements LogTarget { - public void trace(String tag, String msg) { - Log.v(tag, msg); - } - - public void trace(String tag, String msg, Throwable tr) { - Log.v(tag, msg, tr); - } - - public void warn(String tag, String msg, Throwable tr) { - Log.w(tag, msg, tr); - } - - public void warn(String tag, Throwable tr) { - Log.w(tag, tr); - } - - public void debug(String tag, String msg, Throwable tr) { - Log.d(tag, msg, tr); - } - - public void info(String tag, String msg, Throwable tr) { - Log.i(tag, msg, tr); - } - - public void info(String tag, String msg) { - Log.i(tag, msg); - } - - public void warn (String tag, String msg) { - Log.w(tag, msg); - } - - public void error(String tag, String msg) { - Log.e(tag, msg); - } - - public void error(String tag, String msg, Throwable tr) { - Log.e(tag, msg, tr); - } - - public void debug(String tag, String msg) { - Log.d(tag, msg); - } - } - - public static class SysOutLogger implements LogTarget { - - @SuppressWarnings("PMD") - public void dump(String tag, String msg, Throwable t) { - System.out.println(tag+" "+msg); - if (t != null) { t.printStackTrace(); } - } - @Override - public void debug(String tag, String msg, Throwable t) { - dump(tag,msg,t); - } - - @Override - public void debug(String tag, String msg) { - dump(tag,msg,null); - } - - @Override - public void info(String tag, String msg, Throwable t) { - dump(tag,msg,t); - } - - @Override - public void info(String tag, String msg) { - dump(tag,msg,null); - } - - @Override - public void warn(String tag, String msg, Throwable t) { - dump(tag,msg,t); - } - - @Override - public void warn(String tag, String msg) { - dump(tag,msg,null); - } - - @Override - public void error(String tag, String msg, Throwable t) { - dump(tag,msg,t); - } - - @Override - public void error(String tag, String msg) { - dump(tag,msg,null); - } - - @Override - public void trace(String tag, String msg, Throwable t) { - dump(tag,msg,t); - } - - @Override - public void trace(String tag, String msg) { - dump(tag,msg,null); - } - } - - - - private final String processMessageArgs(final String message, final Object... args) { - String result = message; - for (int i = 0; i < args.length; ++i){ - result= result.replace("$"+(i+1), String.valueOf(args[i])); - } - return result; - } - - public Logger(String loggerId) { - this.loggerId = loggerId; - log(Level.DEBUG, loggerId+" was registered"); - } - - public Logger(Class classToLog) { - this(classToLog.getSimpleName()); - } - - public void debug(final String message, final Object... args) { - if (!isLoggable(Level.DEBUG)) { return; } - log(Level.DEBUG, loggerId + " " + processMessageArgs(message, args)); - } - - public void error(final String message, final Object... args) { - if (!isLoggable(Level.ERROR)) { return; } - log(Level.ERROR, loggerId + " " + processMessageArgs(message, args)); - } - - public void fatal(final String message, final Object... args) { - if (!isLoggable(Level.ERROR)) { return; } - log(Level.ERROR, loggerId + " " + processMessageArgs(message, args)); - } - - public void info(final String message, final Object... args) { - if (!isLoggable(Level.INFO)) { return; } - log(Level.INFO, loggerId+" "+processMessageArgs(message,args)); - } - - public void trace(final String message, final Object... args) { - if (!isLoggable(Level.TRACE)) { return; } - log(Level.TRACE, loggerId+" "+processMessageArgs(message,args)); - } - - public void warn(final String message, final Object... args) { - if (!isLoggable(Level.WARN)) { return; } - log(Level.WARN, loggerId+" "+processMessageArgs(message,args)); - } - - public void debug(final String message) { - log(Level.DEBUG, loggerId + " " + message); - } - - public void error(final String message) { - log(Level.ERROR, loggerId + " " + message); - } - - public void fatal(final String message) { - log(Level.ERROR, loggerId + " " + message); - } - - public void info(final String message) { - log(Level.INFO, loggerId+" "+message); - } - - public void trace(final String message) { - log(Level.TRACE, loggerId + " " + message); - } - - public void warn(final String message) { - log(Level.WARN, loggerId + " " + message); - } - - - public void warn(final String message, Throwable e) { - log(Level.WARN, loggerId + " " + message, e); - } - - public void trace(final String message, Throwable e) { - log(Level.TRACE, loggerId + " " + message, e); - } - - public void info(final String message, Throwable e) { - log(Level.INFO, loggerId + " " + message, e); - } - - public void fatal(final String message, Throwable e) { - log(Level.ERROR, loggerId + " " + message, e); - } - - public void error(final String message, Throwable e) { - log(Level.ERROR, loggerId + " " + message, e); - } - - public void debug(final String message, Throwable e) { - log(Level.DEBUG, loggerId + " " + message, e); - } - - - private boolean isLoggable(Level l) { - switch (level) { - case TRACE: - return true; - case DEBUG: - return !l.equals(Level.TRACE); - case INFO: - return !l.equals(Level.TRACE) && !l.equals(Level.DEBUG); - case WARN: - return l.equals(Level.WARN) || l.equals(Level.ERROR); - case ERROR: - return l.equals(Level.ERROR); - } - return false; - } - - - private void logMessage(String message, Throwable t) { - if (message == null) { - message = "null"; - } - switch (level) { - case TRACE: - if (t != null) { - logTarget.trace(TAG,message,t); - } else { - logTarget.trace(TAG,message); - } - break; - case DEBUG: - if (t != null) { - logTarget.debug(TAG,message,t); - } else { - logTarget.debug(TAG,message); - } - break; - case INFO: - if (t != null) { - logTarget.info(TAG,message,t); - } else { - logTarget.info(TAG,message); - } - break; - case WARN: - if (t != null) { - logTarget.warn(TAG,message,t); - } else { - logTarget.warn(TAG,message); - } - break; - case ERROR: - if (t != null) { - logTarget.error(TAG,message,t); - } else { - logTarget.error(TAG,message); - } - break; - } - } - - private void log(Level level, String message, Throwable e) { - if (isLoggable(level)) { - logMessage(message, e); - } - } - private void log(Level level, String message) { - if (isLoggable(level)) { - logMessage(message, null); - } - } - - public static void setTag(String TAG) { - Logger.TAG = TAG; - } -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/util/StringUtil.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/util/StringUtil.java deleted file mode 100644 index af27fb4..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/util/StringUtil.java +++ /dev/null @@ -1,150 +0,0 @@ -package net.mantucon.baracus.util; - -import android.text.format.DateFormat; -import android.widget.TextView; -import net.mantucon.baracus.context.BaracusApplicationContext; - -import java.text.ParseException; -import java.util.Date; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 09.04.13 - * Time: 20:14 - * To change this template use File | Settings | File Templates. - */ -public class StringUtil { - private StringUtil() {} - - public static String firstByteToLower(String instring) { - return instring.substring(0,1).toLowerCase()+instring.substring(1,instring.length()); - } - - /** - * checks, if the passed TextView contains some text - * @param view - the TextView - * @return true, if a non-null, non-blank string is found inside of the text view - */ - public static boolean isEmpty(TextView view) { - if (view != null && view.getText() != null) { - return getString(view).length() == 0; - } - return false; - } - - /** - * extract the trimmed string value out of the passed TextView - * @param view - the view to read from - * @return the trimmed string value from the view - */ - public static String getString(TextView view) { - return view.getText().toString().trim(); - } - - /** - * extract an Integer out of a TextView - * @param view - the view to read from - * @return the Integer value or NULL in case of a non-parseable String - */ - public static Integer getNumber(TextView view) { - Integer result; - if (!isEmpty(view)) { - try { - result = Integer.parseInt(getString(view)); - } catch (Exception e) { - result = null; - } - } else { - result = null; - } - return result; - } - - /** - * extract an Double out of a TextView - * @param view - the view to read from - * @return the Double value or NULL in case of a non-parseable String - */ - public static Double getDouble(TextView view) { - Double result; - if (!isEmpty(view)) { - try { - result = Double.parseDouble(getString(view)); - } catch (Exception e) { - result = null; - } - } else { - result = null; - } - return result; - } - - /** - * make a one-sized array out of the passed string - * @param input - the string - * @return an array sized 1 containing the string - */ - public static String[] toArray(String input) { - if (input != null && input.length() > 0) { - String[] result = new String[1]; - result[0] = input; - return result; - } else { - return new String[0]; - } - } - - /** - * make a comma seperated string out a passed list/set of strings - * @param strings - the string collection - * @return the comma seperated string - */ - public static String join(Iterable strings) { - StringBuilder builder = new StringBuilder(); - for (String s : strings){ - builder.append(s).append(", "); - } - String result = builder.toString(); - return result.substring(1, result.length()-2); - } - - /** - * split a string into an array and trim the strings - * @param s - the string to split - * @param delim - the delimiter - * @return - the array containing all strings trimmed - */ - public static String[] splitPurified(String s, String delim) { - String[] result = null; - if (s != null && s.length() > 0) { - String[] input = s.split(delim); - result = new String[input.length]; - int i = 0; - for (String v : input) { - result[i] = v != null ? v.trim() : ""; - i++; - } - } - return result; - } - - /** - * formats a date to a string using the system's defined dateformat - * @param date - the date - * @return a String containing the formatted date - */ - public static String formatDate(Date date) { - return DateFormat.getDateFormat(BaracusApplicationContext.getContext()).format(date); - } - - /** - * reverts a date string back into a date usign the system's date format - * @param date - the date string - * @return the parsed date - */ - public static Date parseDate(String date) { - return DateUtil.toDate(date); - } - -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/AbstractValidator.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/AbstractValidator.java deleted file mode 100644 index 7a4867b..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/AbstractValidator.java +++ /dev/null @@ -1,27 +0,0 @@ -package net.mantucon.baracus.validation; - - -import android.view.View; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 24.09.13 - * Time: 10:21 - * To change this template use File | Settings | File Templates. - */ -public abstract class AbstractValidator implements Validator { - - /** - * Default Implementation to avoid every Validator implementing this function. - * In most cases - if you do not want the view content used in the message - implementing this - * abstract class instead of a view will save you some time - * - * @param v - the view - * @return null; -> default implementation - */ - @Override - public String[] viewToMessageParams(View v) { - return null; - } -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/ConstrainedView.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/ConstrainedView.java deleted file mode 100644 index 3659b2d..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/ConstrainedView.java +++ /dev/null @@ -1,15 +0,0 @@ -package net.mantucon.baracus.validation; - -import android.view.View; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 24.09.13 - * Time: 06:46 - * To change this template use File | Settings | File Templates. - */ -public interface ConstrainedView { - T getCurrentValue(); - String getValidators(); -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/ValidatableView.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/ValidatableView.java deleted file mode 100644 index a4986f9..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/ValidatableView.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.mantucon.baracus.validation; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 02.10.13 - * Time: 05:30 - * - * Interface indicating, that a view has got a validation callback. implement this - * in Your view in order to receive validation callbacks (e.g. to manage validation- - * dependent visibility like enabling an OK-Button etc). - * - */ -public interface ValidatableView { - - public void onValidation(); - -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/ValidationFactory.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/ValidationFactory.java deleted file mode 100644 index 4a9b7ac..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/ValidationFactory.java +++ /dev/null @@ -1,200 +0,0 @@ -package net.mantucon.baracus.validation; - -import android.view.View; -import android.view.ViewGroup; -import net.mantucon.baracus.annotations.Bean; -import net.mantucon.baracus.context.BaracusApplicationContext; -import net.mantucon.baracus.errorhandling.ErrorHandlingFactory; -import net.mantucon.baracus.errorhandling.ErrorSeverity; -import net.mantucon.baracus.lifecycle.Destroyable; -import net.mantucon.baracus.lifecycle.Initializeable; -import net.mantucon.baracus.util.Logger; -import net.mantucon.baracus.validation.builtins.*; - -import java.util.HashMap; -import java.util.Map; - -import static net.mantucon.baracus.util.StringUtil.firstByteToLower; -import static net.mantucon.baracus.util.StringUtil.join; -import static net.mantucon.baracus.util.StringUtil.splitPurified; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 24.09.13 - * Time: 06:57 - * To change this template use File | Settings | File Templates. - */ -@Bean -public class ValidationFactory implements Initializeable, Destroyable{ - - private static final Map> namedValidators = new HashMap>(); - private static final Logger logger = new Logger(ValidationFactory.class); - - @Bean - ErrorHandlingFactory errorHandlingFactory; - - /** - * Exception thrown, if an invalid validator name is used within the code - */ - public static final class InvalidValidatorNameException extends RuntimeException { - private final String validatorName; - public InvalidValidatorNameException(String validatorName) { - super(); - this.validatorName = validatorName; - } - - @Override - public String getMessage() { - return "A VALIDATOR NAMED "+validatorName+" COULD NOT BE FOUND! AVAILABLE VALIDATORS :"+join(namedValidators.keySet()); - } - } - - - /** - * register a named validator - * @param name - name of the validator to be used in XML - * @param validator - the validator instance - */ - public synchronized void registerValidator(String name, Validator validator) { - namedValidators.put(name, validator); - } - - /** - * register a named validator, the name will be derived from the class name - * @param validator - the validator instance - */ - public synchronized void registerValidator(Validator validator) { - String name = firstByteToLower(validator.getClass().getSimpleName()); - namedValidators.put(name, validator); - } - - /** - * verify that all validators in the list are bound to an existing validator - * - * @param validatorList - a comma seperated string containing all validators - */ - public void verifyValidators(String validatorList) { - if (validatorList != null && validatorList.trim().length() > 0) { - String[] validators = validatorList.split(","); - for (String v : validators){ - if (!namedValidators.containsKey(v)){ - logger.error("A named validator $1 could not be found. Available validators : $2", v, join(namedValidators.keySet())); - throw new InvalidValidatorNameException(v); - } - } - } - } - - /** - * Verify an entire View. This function will recurse all child views and look for - * View Components implementing the ConstrainedView interface. - * - * If a component is found, it will be validated by all validators denoted through the - * validatedBy attribute. If a violation occurs, it is matter - * - * @param v - the view to verify - */ - protected void validateView(View root, View v) { - if (ConstrainedView.class.isAssignableFrom(v.getClass())) { - ConstrainedView cv = (ConstrainedView) v; - String[] validators = splitPurified(cv.getValidators(), ","); - if (validators != null && validators.length > 0) { - boolean stop = false; - int i = 0; - while (!stop) { - String validatorName = validators[i++]; - Validator validator = namedValidators.get(validatorName); - if (validator != null && !validator.validate(cv)) { - errorHandlingFactory.addErrorToView(root, v.getId(), validator.getMessageId(), ErrorSeverity.ERROR, validator.viewToMessageParams(v)); - stop = true; - } - stop |= (i >= validators.length); - } - } - } - - if (ViewGroup.class.isAssignableFrom(v.getClass())) { - ViewGroup viewGroup = (ViewGroup) v; - for (int i = 0; i < viewGroup.getChildCount(); i++ ) { - View nextChild = viewGroup.getChildAt(i); - if (nextChild != null) { - validateView(root, nextChild); - } - } - } - } - - - /** - * Entry function for view validation - * - * @param v - */ - public void validateView(View v) { - validateView(v,v); - } - /** - * registers the built in validators - */ - @Override - public void postConstruct() { - registerValidator(new StringNotEmpty()); - registerValidator(new StringIsNumericDouble()); - registerValidator(new StringIsNumericInteger()); - registerValidator(new NumberMustBeGreaterThanZero()); - registerValidator(new DateFromNow()); - } - - @Override - public void onDestroy() { - namedValidators.clear(); - } - - - /** - * walkt the view tree in order to find components to register - * - * @param root - * @param v - */ - protected void registerValidationListener(final View root, final View v) { - if (ConstrainedView.class.isAssignableFrom(v.getClass())) { - v.setOnFocusChangeListener(new View.OnFocusChangeListener() { - @Override - public void onFocusChange(View v, boolean hasFocus) { - BaracusApplicationContext.validateView(root); - if (ValidatableView.class.isAssignableFrom(root.getClass())) { - ValidatableView validatableView = (ValidatableView) root; - validatableView.onValidation(); - } - } - }); - } - - if (ViewGroup.class.isAssignableFrom(v.getClass())) { - ViewGroup viewGroup = (ViewGroup) v; - for (int i = 0; i < viewGroup.getChildCount(); i++ ) { - View nextChild = viewGroup.getChildAt(i); - if (nextChild != null) { - registerValidationListener(root, nextChild); - } - } - } - } - - /** - * registers an onFocusChangeListener to all view elements implementing - * the @see ConstrainedView interface to perform on-the-fly-validation. - * If you want Your View to be able to receive a validation callback - * - e.g. in order to manage the visibility of an OK-Button or sth. - - * Your View must implement the @see ValidatableView interface in - * order to receive a validation notification callbacks - * - * @param root - the view to perform validation on - */ - public void registerValidationListener(final View root) { - registerValidationListener(root,root); - } - -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/Validator.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/Validator.java deleted file mode 100644 index fd3a8e9..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/Validator.java +++ /dev/null @@ -1,25 +0,0 @@ -package net.mantucon.baracus.validation; - -import android.view.View; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 24.09.13 - * Time: 06:45 - * - * Validator interface. Validators are held seperately from the beans. If You want to - * use a bean as a validator instead, make sure, you use the createPrototypeBean from - * the ApplicationContext to instantiate it and get injections done. It is disregarded - * to use Singleton Beans as Validators! - * - */ -public interface Validator { - - public boolean validate (ConstrainedView view); - - public int getMessageId(); - - public String[] viewToMessageParams(View v); - -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/builtins/DateFromNow.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/builtins/DateFromNow.java deleted file mode 100644 index 525b07b..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/builtins/DateFromNow.java +++ /dev/null @@ -1,60 +0,0 @@ -package net.mantucon.baracus.validation.builtins; - - -import android.text.format.DateFormat; -import android.view.View; -import android.widget.TextView; -import net.mantucon.baracus.R; -import net.mantucon.baracus.context.BaracusApplicationContext; -import net.mantucon.baracus.validation.AbstractValidator; -import net.mantucon.baracus.validation.ConstrainedView; - -import java.text.ParseException; -import java.util.Date; - -import static net.mantucon.baracus.util.DateUtil.today; -import static net.mantucon.baracus.util.StringUtil.getString; -import static net.mantucon.baracus.util.StringUtil.toArray; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 24.09.13 - * Time: 08:47 - * - * verifies that the passed String is a number greater than zero - * - */ -public class DateFromNow extends AbstractValidator{ - - @Override - public boolean validate(ConstrainedView view) { - String value = view.getCurrentValue(); - if (value != null || value.toString().trim().length() != 0) { - java.text.DateFormat df = DateFormat.getDateFormat(BaracusApplicationContext.getContext()); - try { - Date d = df.parse(value); - return today().getTime() <= d.getTime(); - } catch (ParseException e) { - return false; //unparseable - } - - - } else { - return true; // empty string is ok, if you dont want empty strings, then lock the field with a StringNotEmpy constraint - } - } - - - @Override - public int getMessageId() { - return R.string.dateFromNow; - } - - public String[] viewToMessageParams(View v) { - return toArray(getString((TextView) v)); - } - - - -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/builtins/NumberMustBeGreaterThanZero.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/builtins/NumberMustBeGreaterThanZero.java deleted file mode 100644 index 6902df0..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/builtins/NumberMustBeGreaterThanZero.java +++ /dev/null @@ -1,57 +0,0 @@ -package net.mantucon.baracus.validation.builtins; - - -import android.view.View; -import android.widget.TextView; -import net.mantucon.baracus.R; -import net.mantucon.baracus.validation.AbstractValidator; -import net.mantucon.baracus.validation.ConstrainedView; -import net.mantucon.baracus.validation.Validator; - -import static net.mantucon.baracus.util.StringUtil.getDouble; -import static net.mantucon.baracus.util.StringUtil.getString; -import static net.mantucon.baracus.util.StringUtil.toArray; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 24.09.13 - * Time: 08:47 - * - * verifies that the passed String is a number greater than zero - * - */ -public class NumberMustBeGreaterThanZero extends AbstractValidator{ - - @Override - public boolean validate(ConstrainedView view) { - String value = view.getCurrentValue(); - if (value != null || value.toString().trim().length() != 0) { - try { - Integer i = Integer.valueOf(value); - return i > 0; - } catch (NumberFormatException exception) { - // null activity , try to parse a double out of the string - } - try { - Double d = Double.valueOf(value); - return d > 0; - } catch (NumberFormatException e) { - return false; - } - } - return false; - } - - @Override - public int getMessageId() { - return R.string.numberIsSmallerThanZero; - } - - public String[] viewToMessageParams(View v) { - return toArray(getString((TextView) v)); - } - - - -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/builtins/StringIsNumericDouble.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/builtins/StringIsNumericDouble.java deleted file mode 100644 index 1ed6d23..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/builtins/StringIsNumericDouble.java +++ /dev/null @@ -1,51 +0,0 @@ -package net.mantucon.baracus.validation.builtins; - - -import android.view.View; -import android.widget.TextView; -import net.mantucon.baracus.R; -import net.mantucon.baracus.context.BaracusApplicationContext; -import net.mantucon.baracus.errorhandling.ErrorSeverity; -import net.mantucon.baracus.validation.ConstrainedView; -import net.mantucon.baracus.validation.Validator; - -import static net.mantucon.baracus.util.StringUtil.getString; -import static net.mantucon.baracus.util.StringUtil.toArray; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 24.09.13 - * Time: 08:47 - * return true, if a string as a numeric double. empty or null strings - * will also return true - */ -public class StringIsNumericDouble implements Validator { - - @Override - public boolean validate(ConstrainedView view) { - String value = view.getCurrentValue(); - if (value != null || value.toString().trim().length() != 0) { - View v = (View) view; - String s = value.toString().trim(); - try { - Double i = Double.parseDouble(s); - } catch (Exception e) { - return false; - } - } - return true; - } - - @Override - public int getMessageId() { - return R.string.notADecimalField; - } - - public String[] viewToMessageParams(View v) { - return toArray(getString((TextView) v)); - } - - - -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/builtins/StringIsNumericInteger.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/builtins/StringIsNumericInteger.java deleted file mode 100644 index 14ec72b..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/builtins/StringIsNumericInteger.java +++ /dev/null @@ -1,50 +0,0 @@ -package net.mantucon.baracus.validation.builtins; - - -import android.view.View; -import android.widget.TextView; -import net.mantucon.baracus.R; -import net.mantucon.baracus.context.BaracusApplicationContext; -import net.mantucon.baracus.errorhandling.ErrorSeverity; -import net.mantucon.baracus.util.StringUtil; -import net.mantucon.baracus.validation.ConstrainedView; -import net.mantucon.baracus.validation.Validator; - -import static net.mantucon.baracus.util.StringUtil.*; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 24.09.13 - * Time: 08:47 - * - * return true, if a string as a numeric integer. empty or null strings - * will also return true - * - */ -public class StringIsNumericInteger implements Validator { - - @Override - public boolean validate(ConstrainedView view) { - String value = view.getCurrentValue(); - if (value != null || value.toString().trim().length() != 0) { - View v = (View) view; - String s = value.toString().trim(); - try { - Integer i = Integer.parseInt(s); - } catch (Exception e) { - return false; - } - } - return true; - } - - @Override - public int getMessageId() { - return R.string.notAIntegerField; - } - - public String[] viewToMessageParams(View v) { - return toArray(getString((TextView) v)); - } -} diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/builtins/StringNotEmpty.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/builtins/StringNotEmpty.java deleted file mode 100644 index 7b4e60f..0000000 --- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/validation/builtins/StringNotEmpty.java +++ /dev/null @@ -1,37 +0,0 @@ -package net.mantucon.baracus.validation.builtins; - - -import android.view.View; -import net.mantucon.baracus.R; -import net.mantucon.baracus.context.BaracusApplicationContext; -import net.mantucon.baracus.errorhandling.ErrorSeverity; -import net.mantucon.baracus.validation.AbstractValidator; -import net.mantucon.baracus.validation.ConstrainedView; -import net.mantucon.baracus.validation.Validator; - -/** - * Created with IntelliJ IDEA. - * User: marcus - * Date: 24.09.13 - * Time: 08:47 - * To change this template use File | Settings | File Templates. - */ -public class StringNotEmpty extends AbstractValidator { - - @Override - public boolean validate(ConstrainedView view) { - String value = view.getCurrentValue(); - if (value == null || value.toString().trim().length() == 0) { - return false; - } - return true; - - } - - @Override - public int getMessageId() { - return R.string.notNullField; - } - - -} diff --git a/gen-external-apklibs/~apklib-net.mantucon.baracus_baracus-framework_0.6.iml b/gen-external-apklibs/~apklib-net.mantucon.baracus_baracus-framework_0.6.iml new file mode 100644 index 0000000..f10bc85 --- /dev/null +++ b/gen-external-apklibs/~apklib-net.mantucon.baracus_baracus-framework_0.6.iml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/net/mantucon/baracus/HelloAndroidActivity.java b/src/main/java/net/mantucon/baracus/HelloAndroidActivity.java index 91261bf..1d1fa41 100644 --- a/src/main/java/net/mantucon/baracus/HelloAndroidActivity.java +++ b/src/main/java/net/mantucon/baracus/HelloAndroidActivity.java @@ -6,6 +6,7 @@ import android.view.Menu; import android.view.View; import net.mantucon.baracus.annotations.Bean; +import net.mantucon.baracus.application.ApplicationContext; import net.mantucon.baracus.dao.BankAccountDao; import net.mantucon.baracus.service.BankAccountService; import net.mantucon.baracus.service.CustomerService; @@ -47,6 +48,8 @@ public boolean onCreateOptionsMenu(Menu menu) { public void onButtonTestClicked(View v) { customerService.testService(); bankAccountService.createAndOrDumpAccount(); + ApplicationContext.destroy(true); + ApplicationContext.initApplicationContext(); } } diff --git a/src/main/java/net/mantucon/baracus/application/ApplicationContext.java b/src/main/java/net/mantucon/baracus/application/ApplicationContext.java index 025b144..f8b27be 100644 --- a/src/main/java/net/mantucon/baracus/application/ApplicationContext.java +++ b/src/main/java/net/mantucon/baracus/application/ApplicationContext.java @@ -4,6 +4,7 @@ import net.mantucon.baracus.dao.BankAccountDao; import net.mantucon.baracus.dao.BaracusOpenHelper; import net.mantucon.baracus.service.BankAccountService; +import net.mantucon.baracus.service.ConfigurationService; import net.mantucon.baracus.service.CustomerService; /** @@ -19,6 +20,8 @@ public class ApplicationContext extends BaracusApplicationContext { registerBeanClass(CustomerService.class); registerBeanClass(BankAccountService.class); + + registerBeanClass(ConfigurationService.class); } } diff --git a/src/main/java/net/mantucon/baracus/service/ConfigurationService.java b/src/main/java/net/mantucon/baracus/service/ConfigurationService.java new file mode 100644 index 0000000..fb2c41b --- /dev/null +++ b/src/main/java/net/mantucon/baracus/service/ConfigurationService.java @@ -0,0 +1,76 @@ +package net.mantucon.baracus.service; + +import net.mantucon.baracus.annotations.Bean; +import net.mantucon.baracus.dao.ConfigurationDao; +import net.mantucon.baracus.lifecycle.Destroyable; +import net.mantucon.baracus.lifecycle.Initializeable; +import net.mantucon.baracus.model.ConfigurationParameter; + +import java.util.Date; + +/** + * Created with IntelliJ IDEA. + * User: marcus + */ + +@Bean +public class ConfigurationService implements Initializeable, Destroyable{ + + @Bean + ConfigurationDao configurationDao; + + Date lastStarted; + + private static final String KEY_APP_INIT_DONE="APPL_INIT_DONE"; + private static final String KEY_APP_LAST_START="APPL_LAST_START"; + + private static enum YesNo { + YES, + NO + } + + public boolean isApplicationInitializationDone() { + ConfigurationParameter parameter= configurationDao.getByName(KEY_APP_INIT_DONE); + if (parameter != null) { + return YesNo.YES.toString().equals(parameter.getConfigParameterValue()); + } + return false; + } + + public void setApplicationInitializationDone(boolean isEnabled) { + ConfigurationParameter parameter= configurationDao.getByName(KEY_APP_INIT_DONE); + + if (parameter == null) { + parameter = new ConfigurationParameter(); + parameter.setConfigParameter(KEY_APP_INIT_DONE); + } + + parameter.setConfigParameterValue(isEnabled ? YesNo.YES.toString() + : YesNo.NO.toString()); + + configurationDao.save(parameter); + + } + + + @Override + public void onDestroy() { + ConfigurationParameter parameter= configurationDao.getByName(KEY_APP_LAST_START); + + if (parameter == null) { + parameter = new ConfigurationParameter(); + parameter.setConfigParameter(KEY_APP_LAST_START); + } + + parameter.setConfigParameterValue(String.valueOf(lastStarted.getTime())); + + configurationDao.save(parameter); + + } + + @Override + public void postConstruct() { + lastStarted = new Date(); + } + +} From d4aff41499b0d9cc6d58eb861df270a5fb36546a Mon Sep 17 00:00:00 2001 From: gorefest Date: Sun, 27 Oct 2013 17:22:15 +0100 Subject: [PATCH 03/16] added tutorial 5 basics --- baracus-tutorial.iml | 7 +- .../baracus/HelloAndroidActivity.java | 43 ++++++++++ .../baracus/application/OpenHelper.java | 6 +- .../mantucon/baracus/dao/BankAccountDao.java | 40 ++++++++- .../net/mantucon/baracus/dao/CustomerDao.java | 85 +++++++++++++++++++ .../baracus/migr8/ModelVersion101.java | 34 ++++++++ .../baracus/migr8/ModelVersion102.java | 31 +++++++ .../mantucon/baracus/model/BankAccount.java | 23 ++++- .../net/mantucon/baracus/model/Customer.java | 61 +++++++++++++ 9 files changed, 317 insertions(+), 13 deletions(-) create mode 100644 src/main/java/net/mantucon/baracus/dao/CustomerDao.java create mode 100644 src/main/java/net/mantucon/baracus/migr8/ModelVersion101.java create mode 100644 src/main/java/net/mantucon/baracus/migr8/ModelVersion102.java create mode 100644 src/main/java/net/mantucon/baracus/model/Customer.java diff --git a/baracus-tutorial.iml b/baracus-tutorial.iml index 180ead6..b3ab7d0 100644 --- a/baracus-tutorial.iml +++ b/baracus-tutorial.iml @@ -16,13 +16,10 @@ + - - - - - + diff --git a/src/main/java/net/mantucon/baracus/HelloAndroidActivity.java b/src/main/java/net/mantucon/baracus/HelloAndroidActivity.java index 1d1fa41..f152868 100644 --- a/src/main/java/net/mantucon/baracus/HelloAndroidActivity.java +++ b/src/main/java/net/mantucon/baracus/HelloAndroidActivity.java @@ -8,7 +8,12 @@ import net.mantucon.baracus.annotations.Bean; import net.mantucon.baracus.application.ApplicationContext; import net.mantucon.baracus.dao.BankAccountDao; +import net.mantucon.baracus.dao.CustomerDao; +import net.mantucon.baracus.model.BankAccount; +import net.mantucon.baracus.model.Customer; +import net.mantucon.baracus.orm.ObjectReference; import net.mantucon.baracus.service.BankAccountService; +import net.mantucon.baracus.service.ConfigurationService; import net.mantucon.baracus.service.CustomerService; import net.mantucon.baracus.util.Logger; @@ -26,6 +31,18 @@ public class HelloAndroidActivity extends Activity { @Bean BankAccountService bankAccountService; + @Bean + ConfigurationService configurationService; + + @Bean + CustomerDao customerDao; + + @Bean + BankAccountDao bankAccountDao; + + + + /** * Called when the activity is first created. * @param savedInstanceState If the activity is being re-initialized after @@ -36,6 +53,32 @@ public class HelloAndroidActivity extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + + if (!configurationService.isApplicationInitializationDone()) { + initData(); + configurationService.setApplicationInitializationDone(true); + } + } + + private void initData() { + Customer johnDoe = new Customer(); + johnDoe.setFirstName("John"); + johnDoe.setLastName("Doe"); + customerDao.save(johnDoe); + + BankAccount b1 = new BankAccount(); + b1.setCustomer(johnDoe); + b1.setIban("1234DOE777"); + b1.setBankName("Foo Bank Inc."); + + BankAccount b2 = new BankAccount(); + b2.setCustomer(johnDoe); + b2.setIban("DOEDEEDOE"); + b2.setBankName("Bar Investments Inc."); + + bankAccountDao.save(b1); + bankAccountDao.save(b2); + } @Override diff --git a/src/main/java/net/mantucon/baracus/application/OpenHelper.java b/src/main/java/net/mantucon/baracus/application/OpenHelper.java index 80a854b..7595fc0 100644 --- a/src/main/java/net/mantucon/baracus/application/OpenHelper.java +++ b/src/main/java/net/mantucon/baracus/application/OpenHelper.java @@ -3,6 +3,8 @@ import android.content.Context; import net.mantucon.baracus.dao.BaracusOpenHelper; import net.mantucon.baracus.migr8.ModelVersion100; +import net.mantucon.baracus.migr8.ModelVersion101; +import net.mantucon.baracus.migr8.ModelVersion102; /** * Created with IntelliJ IDEA. @@ -11,10 +13,12 @@ public class OpenHelper extends BaracusOpenHelper { private static final String DATABASE_NAME="tutorial-app.db"; - private static final int TARGET_VERSION=100; + private static final int TARGET_VERSION=102; static { addMigrationStep(new ModelVersion100()); + addMigrationStep(new ModelVersion101()); + addMigrationStep(new ModelVersion102()); } /** diff --git a/src/main/java/net/mantucon/baracus/dao/BankAccountDao.java b/src/main/java/net/mantucon/baracus/dao/BankAccountDao.java index ec4b5b2..a67cfc1 100644 --- a/src/main/java/net/mantucon/baracus/dao/BankAccountDao.java +++ b/src/main/java/net/mantucon/baracus/dao/BankAccountDao.java @@ -2,14 +2,19 @@ import android.content.ContentValues; import android.database.Cursor; +import net.mantucon.baracus.annotations.Bean; +import net.mantucon.baracus.application.ApplicationContext; import net.mantucon.baracus.model.BankAccount; -import net.mantucon.baracus.orm.Field; -import net.mantucon.baracus.orm.FieldList; -import net.mantucon.baracus.orm.LazyCollection; +import net.mantucon.baracus.model.Customer; +import net.mantucon.baracus.orm.*; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedList; import java.util.List; import static net.mantucon.baracus.model.BankAccount.bankNameCol; +import static net.mantucon.baracus.model.BankAccount.customerIdCol; import static net.mantucon.baracus.model.BankAccount.ibanCol; import static net.mantucon.baracus.orm.AbstractModelBase.idCol; @@ -20,6 +25,9 @@ */ public class BankAccountDao extends BaseDao { + @Bean + CustomerDao customerDao; + /** * Lock the DAO of */ @@ -27,13 +35,34 @@ public BankAccountDao() { super(BankAccount.class); } - private static final RowMapper rowMapper = new RowMapper() { + public List getByCustomerId(Long id) { + Cursor c = null; + List result = new LinkedList(); + try { + c = this.getDb().query(true, rowMapper.getAffectedTable(), rowMapper.getFieldList().getFieldNames(), BankAccount.customerIdCol.fieldName + "=" + id.toString(), null, null, null, null, null); + result = iterateCursor(c); + } finally { + if (c != null && !c.isClosed()) { + c.close(); + } + } + + return result; + + } + + + private final RowMapper rowMapper = new RowMapper() { @Override public BankAccount from(Cursor c) { BankAccount result = new BankAccount(); result.setId(c.getLong(idCol.fieldIndex)); result.setIban(c.getString(ibanCol.fieldIndex)); result.setBankName(c.getString(bankNameCol.fieldIndex)); + + Long customerId = c.getLong(customerIdCol.fieldIndex); + result.setCustomerReference(new LazyReference(new ReferenceLoader(customerDao, customerId))); + result.setTransient(false); return result; } @@ -58,6 +87,9 @@ public ContentValues getContentValues(BankAccount account) { if (account.getId() != null) { result.put(idCol.fieldName, account.getId()); } if (account.getIban() != null) { result.put(BankAccount.ibanCol.fieldName, account.getIban()); } if (account.getBankName() != null) { result.put(bankNameCol.fieldName, account.getBankName()); } + if (account.getCustomerReference() != null && account.getCustomerReference().getObjectRefId() != null) { + result.put(customerIdCol.fieldName, account.getCustomerReference().getObjectRefId()); + } return result; } }; diff --git a/src/main/java/net/mantucon/baracus/dao/CustomerDao.java b/src/main/java/net/mantucon/baracus/dao/CustomerDao.java new file mode 100644 index 0000000..a7fea27 --- /dev/null +++ b/src/main/java/net/mantucon/baracus/dao/CustomerDao.java @@ -0,0 +1,85 @@ +package net.mantucon.baracus.dao; + +import android.content.ContentValues; +import android.database.Cursor; +import net.mantucon.baracus.annotations.Bean; +import net.mantucon.baracus.model.BankAccount; +import net.mantucon.baracus.model.Customer; +import net.mantucon.baracus.orm.Field; +import net.mantucon.baracus.orm.FieldList; +import net.mantucon.baracus.orm.LazyCollection; + +import java.util.Collection; +import java.util.List; + +import static net.mantucon.baracus.model.Customer.*; +import static net.mantucon.baracus.orm.AbstractModelBase.idCol; + +/** + * Created with IntelliJ IDEA. + * User: marcus + * To change this template use File | Settings | File Templates. + */ +public class CustomerDao extends BaseDao { + + @Bean + BankAccountDao bankAccountDao; + + /** + * Lock the DAO of + */ + public CustomerDao() { + super(Customer.class); + } + + private final RowMapper rowMapper = new RowMapper() { + @Override + public Customer from(Cursor c) { + Customer result = new Customer(); + final Long id = c.getLong(idCol.fieldIndex); + result.setId(id); + result.setLastName(c.getString(lastNameCol.fieldIndex)); + result.setFirstName(c.getString(firstNameCol.fieldIndex)); + result.setTransient(false); + + result.setAccounts(new LazyCollection(new LazyCollection.LazyLoader() { + @Override + public List loadReference() { + return bankAccountDao.getByCustomerId(id); + } + })); + + + return result; + } + + @Override + public String getAffectedTable() { + return Customer.TABLE_CUSTOMER; + } + + @Override + public FieldList getFieldList() { + return Customer.fieldList; + } + + @Override + public Field getNameField() { + return Customer.lastNameCol; + } + + @Override + public ContentValues getContentValues(Customer customer) { + ContentValues result = new ContentValues(); + if (customer.getId() != null) { result.put(idCol.fieldName, customer.getId()); } + if (customer.getLastName() != null) { result.put(lastNameCol.fieldName, customer.getLastName()); } + if (customer.getFirstName() != null) { result.put(firstNameCol.fieldName, customer.getFirstName()); } + return result; + } + }; + + @Override + public RowMapper getRowMapper() { + return rowMapper; + } +} diff --git a/src/main/java/net/mantucon/baracus/migr8/ModelVersion101.java b/src/main/java/net/mantucon/baracus/migr8/ModelVersion101.java new file mode 100644 index 0000000..7dda940 --- /dev/null +++ b/src/main/java/net/mantucon/baracus/migr8/ModelVersion101.java @@ -0,0 +1,34 @@ +package net.mantucon.baracus.migr8; + +import android.database.sqlite.SQLiteDatabase; +import net.mantucon.baracus.model.BankAccount; +import net.mantucon.baracus.model.Customer; +import net.mantucon.baracus.util.Logger; + +/** + * Created with IntelliJ IDEA. + * User: marcus + * To change this template use File | Settings | File Templates. + */ +public class ModelVersion101 implements MigrationStep { + + + private static final Logger logger = new Logger(ModelVersion101.class); + @Override + public void applyVersion(SQLiteDatabase db) { + + String stmt = "CREATE TABLE " + Customer.TABLE_CUSTOMER + + "( "+ Customer.idCol.fieldName+" INTEGER PRIMARY KEY" + + ", "+ Customer.lastNameCol.fieldName+ " TEXT" + + ", "+ Customer.firstNameCol.fieldName+ " TEXT"+ + ")"; + logger.info(stmt); + db.execSQL(stmt); + + } + + @Override + public int getModelVersionNumber() { + return 101; + } +} diff --git a/src/main/java/net/mantucon/baracus/migr8/ModelVersion102.java b/src/main/java/net/mantucon/baracus/migr8/ModelVersion102.java new file mode 100644 index 0000000..0f8cb50 --- /dev/null +++ b/src/main/java/net/mantucon/baracus/migr8/ModelVersion102.java @@ -0,0 +1,31 @@ +package net.mantucon.baracus.migr8; + +import android.database.sqlite.SQLiteDatabase; +import net.mantucon.baracus.model.BankAccount; +import net.mantucon.baracus.model.Customer; +import net.mantucon.baracus.util.Logger; + +/** + * Created with IntelliJ IDEA. + * User: marcus + * To change this template use File | Settings | File Templates. + */ +public class ModelVersion102 implements MigrationStep { + + + private static final Logger logger = new Logger(ModelVersion102.class); + @Override + public void applyVersion(SQLiteDatabase db) { + + String stmt = "ALTER TABLE " + BankAccount.TABLE_BANK_ACCOUNT + + " ADD COLUMN "+BankAccount.customerIdCol.fieldName + " INTEGER"; + logger.info(stmt); + db.execSQL(stmt); + + } + + @Override + public int getModelVersionNumber() { + return 102; + } +} diff --git a/src/main/java/net/mantucon/baracus/model/BankAccount.java b/src/main/java/net/mantucon/baracus/model/BankAccount.java index 05df1ee..0280ec2 100644 --- a/src/main/java/net/mantucon/baracus/model/BankAccount.java +++ b/src/main/java/net/mantucon/baracus/model/BankAccount.java @@ -1,8 +1,6 @@ package net.mantucon.baracus.model; -import net.mantucon.baracus.orm.AbstractModelBase; -import net.mantucon.baracus.orm.Field; -import net.mantucon.baracus.orm.FieldList; +import net.mantucon.baracus.orm.*; /** * Created with IntelliJ IDEA. @@ -16,16 +14,19 @@ public class BankAccount extends AbstractModelBase { private String bankName; private String iban; + private Reference customerReference; public static final FieldList fieldList = new FieldList(BankAccount.class.getSimpleName()); public static final Field bankNameCol = new Field("bank_name", columnIndex++); public static final Field ibanCol = new Field("iban", columnIndex++); + public static final Field customerIdCol = new Field("customerId", columnIndex++); static { fieldList.add(AbstractModelBase.fieldList); fieldList.add(bankNameCol); fieldList.add(ibanCol); + fieldList.add(customerIdCol); } public BankAccount() { @@ -48,4 +49,20 @@ public void setIban(String iban) { this.iban = iban; } + public Reference getCustomerReference() { + return customerReference; + } + + public void setCustomerReference(Reference customerReference) { + this.customerReference = customerReference; + } + + public Customer getCustomer() { + return customerReference.getObject(); + } + + public void setCustomer(Customer customer) { + this.customerReference = new ObjectReference(customer); + } + } diff --git a/src/main/java/net/mantucon/baracus/model/Customer.java b/src/main/java/net/mantucon/baracus/model/Customer.java new file mode 100644 index 0000000..ac7a780 --- /dev/null +++ b/src/main/java/net/mantucon/baracus/model/Customer.java @@ -0,0 +1,61 @@ +package net.mantucon.baracus.model; + +import net.mantucon.baracus.orm.AbstractModelBase; +import net.mantucon.baracus.orm.Field; +import net.mantucon.baracus.orm.FieldList; + +import java.util.Collection; + +/** + * Created with IntelliJ IDEA. + * User: marcus + */ +public class Customer extends AbstractModelBase { + + public static final String TABLE_CUSTOMER = "customer"; + + private static int columnIndex= AbstractModelBase.fieldList.size(); + + private String lastName; + private String firstName; + private Collection accounts; + + public static final FieldList fieldList = new FieldList(Customer.class.getSimpleName()); + public static final Field lastNameCol = new Field("last_name", columnIndex++); + public static final Field firstNameCol = new Field("first_name", columnIndex++); + + + static { + fieldList.add(AbstractModelBase.fieldList); + fieldList.add(lastNameCol); + fieldList.add(firstNameCol); + } + + public Customer() { + super(TABLE_CUSTOMER); + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public Collection getAccounts() { + return accounts; + } + + public void setAccounts(Collection accounts) { + this.accounts = accounts; + } +} From af2fc1810d554dc028985bbbafe24449e4fc8052 Mon Sep 17 00:00:00 2001 From: gorefest Date: Sun, 27 Oct 2013 17:54:21 +0100 Subject: [PATCH 04/16] added t5 POC --- .../mantucon/baracus/HelloAndroidActivity.java | 15 +++++++++++---- .../java/net/mantucon/baracus/model/Customer.java | 7 ++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/mantucon/baracus/HelloAndroidActivity.java b/src/main/java/net/mantucon/baracus/HelloAndroidActivity.java index f152868..318f4f6 100644 --- a/src/main/java/net/mantucon/baracus/HelloAndroidActivity.java +++ b/src/main/java/net/mantucon/baracus/HelloAndroidActivity.java @@ -17,6 +17,8 @@ import net.mantucon.baracus.service.CustomerService; import net.mantucon.baracus.util.Logger; +import java.util.List; + public class HelloAndroidActivity extends Activity { static final Logger logger = new Logger(HelloAndroidActivity.class); @@ -89,10 +91,15 @@ public boolean onCreateOptionsMenu(Menu menu) { } public void onButtonTestClicked(View v) { - customerService.testService(); - bankAccountService.createAndOrDumpAccount(); - ApplicationContext.destroy(true); - ApplicationContext.initApplicationContext(); + + List allCustomers = customerDao.loadAll(); + + for (Customer customer : allCustomers) { + List customerAccounts = customer.getAccounts(); + for (BankAccount account : customerAccounts) { + logger.info("Customer $1 $2 --- account --> $3/$4", customer.getFirstName(),customer.getLastName(), account.getBankName(), account.getIban()); + } + } } } diff --git a/src/main/java/net/mantucon/baracus/model/Customer.java b/src/main/java/net/mantucon/baracus/model/Customer.java index ac7a780..ea113a3 100644 --- a/src/main/java/net/mantucon/baracus/model/Customer.java +++ b/src/main/java/net/mantucon/baracus/model/Customer.java @@ -5,6 +5,7 @@ import net.mantucon.baracus.orm.FieldList; import java.util.Collection; +import java.util.List; /** * Created with IntelliJ IDEA. @@ -18,7 +19,7 @@ public class Customer extends AbstractModelBase { private String lastName; private String firstName; - private Collection accounts; + private List accounts; public static final FieldList fieldList = new FieldList(Customer.class.getSimpleName()); public static final Field lastNameCol = new Field("last_name", columnIndex++); @@ -51,11 +52,11 @@ public void setFirstName(String firstName) { this.firstName = firstName; } - public Collection getAccounts() { + public List getAccounts() { return accounts; } - public void setAccounts(Collection accounts) { + public void setAccounts(List accounts) { this.accounts = accounts; } } From 5314710a00daab7087fc4e76dc3a502314fad241 Mon Sep 17 00:00:00 2001 From: gorefest Date: Mon, 28 Oct 2013 14:59:19 +0100 Subject: [PATCH 05/16] tutorial 5 : Advanced Mapping POC --- baracus-tutorial.iml | 6 +++++- .../java/net/mantucon/baracus/HelloAndroidActivity.java | 7 +++++++ .../mantucon/baracus/application/ApplicationContext.java | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/baracus-tutorial.iml b/baracus-tutorial.iml index b3ab7d0..bccca11 100644 --- a/baracus-tutorial.iml +++ b/baracus-tutorial.iml @@ -18,8 +18,12 @@ - + + + + + diff --git a/src/main/java/net/mantucon/baracus/HelloAndroidActivity.java b/src/main/java/net/mantucon/baracus/HelloAndroidActivity.java index 318f4f6..97daa64 100644 --- a/src/main/java/net/mantucon/baracus/HelloAndroidActivity.java +++ b/src/main/java/net/mantucon/baracus/HelloAndroidActivity.java @@ -92,6 +92,7 @@ public boolean onCreateOptionsMenu(Menu menu) { public void onButtonTestClicked(View v) { + // Demonstrate Customer 1:N Lazy Loading List allCustomers = customerDao.loadAll(); for (Customer customer : allCustomers) { @@ -100,6 +101,12 @@ public void onButtonTestClicked(View v) { logger.info("Customer $1 $2 --- account --> $3/$4", customer.getFirstName(),customer.getLastName(), account.getBankName(), account.getIban()); } } + + // Demontrate BankAccount N:1 Lazy Loading + List allBankAccounts = bankAccountDao.loadAll(); + for (BankAccount account : allBankAccounts){ + logger.info("Bank Account $1 / $2 --- customer ---> $1 $2", account.getBankName(), account.getIban(), account.getCustomer().getFirstName(), account.getCustomer().getLastName()); + } } } diff --git a/src/main/java/net/mantucon/baracus/application/ApplicationContext.java b/src/main/java/net/mantucon/baracus/application/ApplicationContext.java index f8b27be..ed6c627 100644 --- a/src/main/java/net/mantucon/baracus/application/ApplicationContext.java +++ b/src/main/java/net/mantucon/baracus/application/ApplicationContext.java @@ -3,6 +3,7 @@ import net.mantucon.baracus.context.BaracusApplicationContext; import net.mantucon.baracus.dao.BankAccountDao; import net.mantucon.baracus.dao.BaracusOpenHelper; +import net.mantucon.baracus.dao.CustomerDao; import net.mantucon.baracus.service.BankAccountService; import net.mantucon.baracus.service.ConfigurationService; import net.mantucon.baracus.service.CustomerService; @@ -17,6 +18,7 @@ public class ApplicationContext extends BaracusApplicationContext { registerBeanClass(OpenHelper.class); registerBeanClass(BankAccountDao.class); + registerBeanClass(CustomerDao.class); registerBeanClass(CustomerService.class); registerBeanClass(BankAccountService.class); From 59d43700dc84cecfff28a07e6efebdab86b0fe85 Mon Sep 17 00:00:00 2001 From: gorefest Date: Mon, 10 Feb 2014 18:29:22 +0100 Subject: [PATCH 06/16] tutorial 6 : Simple form validation --- ...en__com_google_android_android_4_0_1_2.xml | 13 ++ ...Maven__commons_codec_commons_codec_1_3.xml | 13 ++ ..._commons_logging_commons_logging_1_1_1.xml | 13 ++ .idea/libraries/Maven__junit_junit_4_10.xml | 9 ++ ...n_baracus_baracus_framework_apklib_0_6.xml | 13 -- ...apache_httpcomponents_httpclient_4_0_1.xml | 13 ++ ...g_apache_httpcomponents_httpcore_4_0_1.xml | 13 ++ .../Maven__org_hamcrest_hamcrest_core_1_1.xml | 9 ++ .../Maven__org_json_json_20080701.xml | 13 ++ ...hronos_opengl_api_gl1_1_android_2_1_r1.xml | 13 ++ .../Maven__org_mockito_mockito_all_1_9_5.xml | 9 ++ .../Maven__xerces_xmlParserAPIs_2_6_2.xml | 13 ++ .idea/libraries/Maven__xpp3_xpp3_1_1_4c.xml | 13 ++ AndroidManifest.xml | 1 + baracus-tutorial.iml | 11 +- ...mantucon.baracus_baracus-framework_0.6.iml | 14 +- ...klib-org.baracus_baracus-framework_0.7.iml | 41 ++++++ pom.xml | 4 +- res/layout/activity_main.xml | 49 ++++--- res/layout/customer_editor.xml | 39 ++++++ res/layout/entries_list_child_item.xml | 20 +++ res/layout/entries_list_group_item.xml | 14 ++ res/values/strings.xml | 4 + .../baracus/AccountExpandListAdapter.java | 130 ++++++++++++++++++ .../baracus/CustomerEditorActivity.java | 62 +++++++++ .../baracus/HelloAndroidActivity.java | 51 +++++++ 26 files changed, 548 insertions(+), 49 deletions(-) create mode 100644 .idea/libraries/Maven__com_google_android_android_4_0_1_2.xml create mode 100644 .idea/libraries/Maven__commons_codec_commons_codec_1_3.xml create mode 100644 .idea/libraries/Maven__commons_logging_commons_logging_1_1_1.xml create mode 100644 .idea/libraries/Maven__junit_junit_4_10.xml delete mode 100644 .idea/libraries/Maven__net_mantucon_baracus_baracus_framework_apklib_0_6.xml create mode 100644 .idea/libraries/Maven__org_apache_httpcomponents_httpclient_4_0_1.xml create mode 100644 .idea/libraries/Maven__org_apache_httpcomponents_httpcore_4_0_1.xml create mode 100644 .idea/libraries/Maven__org_hamcrest_hamcrest_core_1_1.xml create mode 100644 .idea/libraries/Maven__org_json_json_20080701.xml create mode 100644 .idea/libraries/Maven__org_khronos_opengl_api_gl1_1_android_2_1_r1.xml create mode 100644 .idea/libraries/Maven__org_mockito_mockito_all_1_9_5.xml create mode 100644 .idea/libraries/Maven__xerces_xmlParserAPIs_2_6_2.xml create mode 100644 .idea/libraries/Maven__xpp3_xpp3_1_1_4c.xml create mode 100644 gen-external-apklibs/~apklib-org.baracus_baracus-framework_0.7.iml create mode 100644 res/layout/customer_editor.xml create mode 100644 res/layout/entries_list_child_item.xml create mode 100644 res/layout/entries_list_group_item.xml create mode 100644 src/main/java/net/mantucon/baracus/AccountExpandListAdapter.java create mode 100644 src/main/java/net/mantucon/baracus/CustomerEditorActivity.java diff --git a/.idea/libraries/Maven__com_google_android_android_4_0_1_2.xml b/.idea/libraries/Maven__com_google_android_android_4_0_1_2.xml new file mode 100644 index 0000000..f9160dd --- /dev/null +++ b/.idea/libraries/Maven__com_google_android_android_4_0_1_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__commons_codec_commons_codec_1_3.xml b/.idea/libraries/Maven__commons_codec_commons_codec_1_3.xml new file mode 100644 index 0000000..3688001 --- /dev/null +++ b/.idea/libraries/Maven__commons_codec_commons_codec_1_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__commons_logging_commons_logging_1_1_1.xml b/.idea/libraries/Maven__commons_logging_commons_logging_1_1_1.xml new file mode 100644 index 0000000..b770f56 --- /dev/null +++ b/.idea/libraries/Maven__commons_logging_commons_logging_1_1_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__junit_junit_4_10.xml b/.idea/libraries/Maven__junit_junit_4_10.xml new file mode 100644 index 0000000..720a7ef --- /dev/null +++ b/.idea/libraries/Maven__junit_junit_4_10.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__net_mantucon_baracus_baracus_framework_apklib_0_6.xml b/.idea/libraries/Maven__net_mantucon_baracus_baracus_framework_apklib_0_6.xml deleted file mode 100644 index 323ab79..0000000 --- a/.idea/libraries/Maven__net_mantucon_baracus_baracus_framework_apklib_0_6.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_apache_httpcomponents_httpclient_4_0_1.xml b/.idea/libraries/Maven__org_apache_httpcomponents_httpclient_4_0_1.xml new file mode 100644 index 0000000..a9ca4c6 --- /dev/null +++ b/.idea/libraries/Maven__org_apache_httpcomponents_httpclient_4_0_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_apache_httpcomponents_httpcore_4_0_1.xml b/.idea/libraries/Maven__org_apache_httpcomponents_httpcore_4_0_1.xml new file mode 100644 index 0000000..eee5c06 --- /dev/null +++ b/.idea/libraries/Maven__org_apache_httpcomponents_httpcore_4_0_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_1.xml b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_1.xml new file mode 100644 index 0000000..e5de34d --- /dev/null +++ b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_1.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_json_json_20080701.xml b/.idea/libraries/Maven__org_json_json_20080701.xml new file mode 100644 index 0000000..b86a8bf --- /dev/null +++ b/.idea/libraries/Maven__org_json_json_20080701.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_khronos_opengl_api_gl1_1_android_2_1_r1.xml b/.idea/libraries/Maven__org_khronos_opengl_api_gl1_1_android_2_1_r1.xml new file mode 100644 index 0000000..2fe6214 --- /dev/null +++ b/.idea/libraries/Maven__org_khronos_opengl_api_gl1_1_android_2_1_r1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_mockito_mockito_all_1_9_5.xml b/.idea/libraries/Maven__org_mockito_mockito_all_1_9_5.xml new file mode 100644 index 0000000..ca7afe0 --- /dev/null +++ b/.idea/libraries/Maven__org_mockito_mockito_all_1_9_5.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__xerces_xmlParserAPIs_2_6_2.xml b/.idea/libraries/Maven__xerces_xmlParserAPIs_2_6_2.xml new file mode 100644 index 0000000..96cae4c --- /dev/null +++ b/.idea/libraries/Maven__xerces_xmlParserAPIs_2_6_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__xpp3_xpp3_1_1_4c.xml b/.idea/libraries/Maven__xpp3_xpp3_1_1_4c.xml new file mode 100644 index 0000000..26694b3 --- /dev/null +++ b/.idea/libraries/Maven__xpp3_xpp3_1_1_4c.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/AndroidManifest.xml b/AndroidManifest.xml index b85f2f1..dcf6006 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -21,6 +21,7 @@ + \ No newline at end of file diff --git a/baracus-tutorial.iml b/baracus-tutorial.iml index bccca11..21fd5f6 100644 --- a/baracus-tutorial.iml +++ b/baracus-tutorial.iml @@ -8,22 +8,25 @@ - - + + + + + @@ -36,7 +39,7 @@ - + diff --git a/gen-external-apklibs/~apklib-net.mantucon.baracus_baracus-framework_0.6.iml b/gen-external-apklibs/~apklib-net.mantucon.baracus_baracus-framework_0.6.iml index f10bc85..ad978c8 100644 --- a/gen-external-apklibs/~apklib-net.mantucon.baracus_baracus-framework_0.6.iml +++ b/gen-external-apklibs/~apklib-net.mantucon.baracus_baracus-framework_0.6.iml @@ -22,20 +22,8 @@ - + - - - - - - - - - - - - diff --git a/gen-external-apklibs/~apklib-org.baracus_baracus-framework_0.7.iml b/gen-external-apklibs/~apklib-org.baracus_baracus-framework_0.7.iml new file mode 100644 index 0000000..4ec6673 --- /dev/null +++ b/gen-external-apklibs/~apklib-org.baracus_baracus-framework_0.7.iml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index 25fab82..18fcdd1 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ 4.0.1.2 3.6.0 UTF-8 - 0.6 + 0.7-SR1 @@ -23,7 +23,7 @@ provided - net.mantucon.baracus + org.baracus baracus-framework ${baracus.version} apklib diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml index 89d9b28..9d79862 100644 --- a/res/layout/activity_main.xml +++ b/res/layout/activity_main.xml @@ -1,22 +1,37 @@ + android:layout_width="match_parent" + android:layout_height="match_parent" + android:paddingBottom="@dimen/activity_vertical_margin" + android:paddingLeft="@dimen/activity_horizontal_margin" + android:paddingRight="@dimen/activity_horizontal_margin" + android:paddingTop="@dimen/activity_vertical_margin"> - + + -