Freitag, 25. Juli 2014

BARACUS Release 0.8.1



Hello, today I am glad to announce that BARACUS version 0.8.1 has been released. It carries several bugfixes and improvements and introduces a small amount of useful helper functions


 It can be included using the coordinates

<dependency>
<groupid>org.baracus</groupid>
<artifactid>baracus-framework</artifactid>
<version>0.8.1</version>
<type>apklib</type>
</dependency>

You also can download the sourcecode from github



VERSION 0.8.1 Changelog

- added DataUtil for simple Collection -> Map transformations
- added list based delete/save functions withing one transaction
- added Popup macro
- added generic BaseDao.arrify function to  to make collections become an array on demand
- added function to create lazy object reference (BaseDao.createLazyReference) by dao and id to application context  (was useful to me for dto-to-model copy constructor)
- added function to create lazy collection references (BaseDao.createLazyCollection) by dao, id and remote field
 (same like above)
- added support for optimistic locking, useful when multiple android clients are writing
  to one android master database.
- created optmistic locking capable entity (via version field)
- created BaseDao.initialFromCursor factory function to make coping with ID and version
  a little bit more flexible.
- added NullReference in ORM to avoid NPE handling on nullified References

- added a locator function BaracusApplicationContext.getBeansOfType to find all instances
  implementing a certain class.

These bugs were fixed :


- bugfixed query-function (double iteration)
- bugfixed ModelBase field list naming
- bugfixed replaceBean method
- bugfixed loss of timestamp info in BaseDao.save()


Mittwoch, 2. Juli 2014

BARACUS Release 0.8


Today I am glad to announce that BARACUS framework version 0.8 has been released.
 It can be included using the coordinates

<dependency>
<groupid>org.baracus</groupid>
<artifactid>baracus-framework</artifactid>
<version>0.8</version>
<type>apklib</type>
</dependency>

You also can download the sourcecode from github

A couple of features have been added:


VERSION 0.8

- added the getIdField function in order to make overriding the id column naming possible
- added the getLoadAllCursor in order to make linking to a data DataBoundAdapter possible
- to be better able to work with persistence interfaces the LazyMorphicCollection has been
  introduced in order to be able to return a List<Type> from a Dao<SpecialType>

- interface registration now possible in order to extend code reuseability
  additional to applicationContainer.registerBeanClass(aClass) you now can
  call registerBeanClass(InterfaceType, BeanClass);

  This is a powerful feature since it makes in-app testing much more easy.

- also : replace bean implementations in the running application and context hot reinit

- bugfix for NullPointerException in Android preview in IntelliJ

- added support for automatic selection of modified entities (BaseDao.getAllItemsModifiedAfter)
  .. simply extend your rowmapper to implement TimestampSupportingRowmapper and return
     the timestamp fields

- added an after-context-init hook to enable application post-construct
- added a function deleteById carrying a Long parameter to the DAOs
- added an constructor based "transient" determination to ModelBase
- added some utils for basic date calculation

- added queryByExample function in order to do QBE :)
- modified DataSetChangeAware interface, now passes the emitted class in order to be able to
  create aggregator-alike DataSetChangeAware components handling multiple entity types



--- DEPRECATION NOTICE ---
- don't inherit AbstractModelBase any more! The "id" column clashes
  with the android convention of carrying an "_id" column, so I added
  a boolean parameter to force You making a review on Your model classes.
  You can either inherit LegacyModelBase (same behaviour like before) or
  - and this is recommended - rebuild Your tables by renaming the "id" column
  to an "_id" column. This restrict impacts when You try to fill view withs
  data using a cursor. So either You must consider using the LegacyBean
  or You should modify Your code.

Regards,
mnt

Android daily pain : class R does not contain the correct constants

Yesterday I started preparing  the release of BARACUS 0.8. Therefore, I started to update all tutorials. By the new Android versions I surely updated my SDK in the meantime. In mind, just to do a version upgrade and use a new plugin version, I started migration.

So what I did was using a newer pom, update plugin and sdk version :

public class ApplicationContext extends BaracusApplicationContext {
 <properties>
        <android.sdk.path>C:/adt-bundle-windows-x86-20130219/sdk</android.sdk.path>
        <android.plugin.version>3.8.2</android.plugin.version>
        <android.sdk.version>18</android.sdk.version>
  <platform.version>4.0.1.2</platform.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <baracus.version>0.8</baracus.version>
 </properties>
... and ..,
public class ApplicationContext extends BaracusApplicationContext {
 <build>
  <finalName>${project.artifactId}</finalName>
  <pluginManagement>
   <plugins>
    <plugin>
     <groupId>com.jayway.maven.plugins.android.generation2</groupId>
     <artifactId>android-maven-plugin</artifactId>
     <version>${android.plugin.version}</version>
     <extensions>true</extensions>
    </plugin>
   </plugins>
  </pluginManagement>
  <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>${android.plugin.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <sdk>
                        <platform>${android.sdk.version}</platform>
                    </sdk>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
            </plugin>


So, basically, I chose the setting mostly equals to the one in the framework. Also, I switched to use the new ModelBase class, since the AbstractModelBase becomes unavailable in this release.

Problem : The android project did not compile any more. But it did with the old plugin!?! WTF?!!

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/marcus/tutorial-fix/baracus-tutorial/src/main/java/net/mantucon/baracus/HelloAndroidActivity.java:[57,25] cannot find symbol
  symbol:   variable layout
  location: class net.mantucon.baracus.R
[ERROR] /home/marcus/tutorial-fix/baracus-tutorial/src/main/java/net/mantucon/baracus/HelloAndroidActivity.java:[89,57] cannot find symbol
  symbol:   variable menu
  location: class net.mantucon.baracus.R
[INFO] 2 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.913 s
[INFO] Finished at: 2014-07-02T15:28:54+01:00
[INFO] Final Memory: 27M/336M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project baracus-tutorial: Compilation failure: Compilation failure:
[ERROR] /home/marcus/tutorial-fix/baracus-tutorial/src/main/java/net/mantucon/baracus/HelloAndroidActivity.java:[57,25] cannot find symbol
[ERROR] symbol:   variable layout
[ERROR] location: class net.mantucon.baracus.R
[ERROR] /home/marcus/tutorial-fix/baracus-tutorial/src/main/java/net/mantucon/baracus/HelloAndroidActivity.java:[89,57] cannot find symbol
[ERROR] symbol:   variable menu
[ERROR] location: class net.mantucon.baracus.R
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Process finished with exit code 1

After searching a little bit, I found out that the class R exists twice. I imported the BARACUS framework and it shares the package namespace with the tutorial.

Reason: The latest Android SDK and plugin do not allow the Mixup of R's within the same namespace any more.

Solution : I did a refactoring, moving all tutorial classes to the baracustutorial namespace. This fixed the issue. Now the error disappeard. Thanks to IDEA Intellij, this was less than 10mins per project. Annoying was the fact, that every R-access had to be removed by Hand.