Skip to content

Commit

Permalink
make "model Transformation" components: Document Builder ,
Browse files Browse the repository at this point in the history
XmodelTranslator

pom changed.Upgraded jayway android maven plugin.
  • Loading branch information
sasinda committed Jul 22, 2012
1 parent d1cd624 commit c14fc45
Show file tree
Hide file tree
Showing 99 changed files with 4,715 additions and 1,147 deletions.
87 changes: 42 additions & 45 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,72 +24,69 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- <parent>
<parent>
<groupId>org.xwiki.commons</groupId>
<artifactId>xwiki-commons</artifactId>
<version>4.2-SNAPSHOT</version>
</parent> -->
<version>4.1.2</version>
</parent>
<groupId>org.xwiki.android</groupId>
<artifactId>xwiki-android</artifactId>
<version>1.0-SNAPSHOT</version>
<name>XWiki Android - Parent POM</name>
<packaging>pom</packaging>
<description>XWiki Android - Parent POM</description>
<properties>
<properties>
<xwiki.clirr.skip>true</xwiki.clirr.skip>
Force accessing banned dependancy junit since android-test artifact
uses it
<!-- Force accessing banned dependency junit since android-test artifact
uses it -->
<xwiki.enforcer.skip>true</xwiki.enforcer.skip>
</properties>

<modules>
<module>xwiki-rest-model</module>
<module>xwiki-android-rest</module>
<module>xwiki-android-core</module>
<module>xwiki-android-components</module>
<module>xwiki-android-client</module>
<module>xwiki-android-test-rest</module>
<module>xwiki-android-tests-instrumentation</module>
</modules>
<dependencies>
<module>xwiki-android-components</module>
<module>xwiki-android-client</module>
<module>xwiki-android-test-rest</module>
<module>xwiki-android-tests-instrumentation</module>
</modules>

<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependency>
</dependencies>

<build>

<sourceDirectory>src</sourceDirectory>

<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>maven-android-plugin</artifactId>
<version>2.9.0-beta-5</version>
<configuration>
<sdk>
<platform>2.1</platform>
</sdk>
<emulator>
<avd>android-7</avd>
</emulator>
<deleteConflictingFiles>true</deleteConflictingFiles>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
<coreLibrary>true</coreLibrary>
</configuration>
<extensions>true</extensions>
</plugin>


<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
</plugins>

<sourceDirectory>src</sourceDirectory>

<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<sdk>
<platform>2.1</platform>
</sdk>

<deleteConflictingFiles>true</deleteConflictingFiles>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
<coreLibrary>true</coreLibrary>
</configuration>
<extensions>true</extensions>
</plugin>


<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
</plugins>

</build>
</project>
</project>
6 changes: 3 additions & 3 deletions xwiki-android-client/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
# Project target.
target=android-7

android.library.reference.1=../xwiki-android-rest
android.library.reference.2=../xwiki-android-components
android.library.reference.3=../xwiki-android-core
android.library.reference.3=../xwiki-android-core
android.library.reference.1=../xwiki-android-components
android.library.reference.2=../xwiki-android-rest
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.xwiki.android.ral.RESTfulManager;
import org.xwiki.android.ral.XmlRESTFulManager;
import org.xwiki.android.xmodel.entity.Document;

import com.j256.ormlite.dao.Dao;


Expand Down Expand Up @@ -40,16 +39,16 @@ public void onClick(DialogInterface arg0, int arg1){}
XWikiApplicationContext ctx=(XWikiApplicationContext)getApplicationContext();
EntityManager em=ctx.newEntityManager();
// try {
// Dao<F,Integer> docdao=em.getDao(DocumentReference.class);
// docdao.create(new DocumentReference("xwiki","blog","myBlogPage"));
//
//Dao<DocumentReference,Integer> docdao=em.getDao(DocumentReference.class);
//docdao.create(new DocumentReference("xwiki","blog","myBlogPage"));

// } catch (SQLException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }

// RESTfulManager mngr=new XmlRESTFulManager();
// mngr.getDocumentRao(new DocumentRaoCallback(){});
// } // mngr.getDocumentRao(new DocumentRaoCallback(){});
}

}
2 changes: 1 addition & 1 deletion xwiki-android-components/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
#proguard.config=${sdk.dir}\tools\proguard\proguard-android.txt:proguard-project.txt

android.library=true
android.library.reference.1=../xwiki-android-rest
# Project target.
target=android-7
android.library.reference.1=../xwiki-android-core
1 change: 1 addition & 0 deletions xwiki-android-core/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
# Project target.
target=android-7
android.library=true
android.library.reference.1=../xwiki-android-rest
1 change: 0 additions & 1 deletion xwiki-android-core/src/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
package org.xwiki.android.bgsvcs;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

import org.xwiki.android.context.XWikiApplicationContext;
import org.xwiki.android.dal.EntityManager;
import org.xwiki.android.entity.SyncOutEntity;
import org.xwiki.android.entity.SyncOutEntity.StatusType;
import org.xwiki.android.fileStore.DocumentFao;
import org.xwiki.android.fileStore.FSDocumentReference;
import org.xwiki.android.fileStore.FileStoreManager;
import org.xwiki.android.ral.DocumentRao;
import org.xwiki.android.ral.RESTfulManager;
import org.xwiki.android.ral.RaoException;
import org.xwiki.android.rest.RestConnectorException;
import org.xwiki.android.xmodel.entity.Document;
import org.xwiki.android.xmodel.svc.DocumentRemoteSvcCallbacks;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;

import com.j256.ormlite.dao.Dao;

/**
*
* @author xwiki gsoc 2012
* @version 1.0 Handles syncing of Documents with the server.
*/

// dev note:Other remote syncing functionalities should also be put here.
public class SyncBackgroundService extends Service
{
private static final String tag="SyncBackgroundService";
private static final int SYNC_PERIOD = 60000;// sync every min.
private Timer timer;
private TimerTask task;



@Override
public void onCreate()
{
Log.d(tag,"bg service created");
// HandlerThread thread = new HandlerThread("ServiceStartArguments",
// Process.THREAD_PRIORITY_BACKGROUND);
// thread.start();
timer = new Timer();
task = new TimerTask()
{
@Override
public void run()
{
XWikiApplicationContext ctx=XWikiApplicationContext.getInstance();
EntityManager em=ctx.newEntityManager();
try {
Dao<SyncOutEntity, Integer> dao = em.getDao(SyncOutEntity.class);
List<SyncOutEntity> list=dao.queryForAll();
if(!list.isEmpty()){
RESTfulManager rm=ctx.newRESTfulManager();
FileStoreManager fm=ctx.getFileStoreManager();
DocumentRemoteSvcCallbacks clbks=new DocumentRemoteSvcCallbacks()
{
public void onCreated(Document res, boolean success,RaoException ex) {

};
};

DocumentRao rao=rm.newDocumentRao();
DocumentFao fao=fm.getDocumentFao();
for(SyncOutEntity s:list){
FSDocumentReference ref=s.getDocref();
Document doc=fao.load(ref);
try {
rao.create(doc);
} catch (RestConnectorException e) {
e.printStackTrace();
break;//abort sync. retry after SYNC_PERIOD
} catch (RaoException e) {
//doc may be already created.
try {
rao.update(doc);
} catch (RestConnectorException e1) {
e1.printStackTrace();
break;
} catch (RaoException e1) {
// we cannot do an update also.
//donot delete and recreate. Just mark failed.
s.setStatus(StatusType.FAILED);
dao.update(s);
e1.printStackTrace();
}
e.printStackTrace();
}
}
}else{
Log.d(tag, "terminating SyncBackgroundService. No docs to sync out");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
stopSelf();//stop native service after all sync entries are synced.
}
};

}

@Override
public int onStartCommand(Intent intent, int flags, int startId)
{
Toast.makeText(this, "Sync Service Starting", Toast.LENGTH_SHORT).show();
timer.schedule(task, 3000, SYNC_PERIOD);
return START_NOT_STICKY;
}

@Override
public IBinder onBind(Intent intent)
{
return null;// not supported
}

@Override
public void onDestroy()
{
Toast.makeText(this, "service done", Toast.LENGTH_SHORT).show();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.xwiki.android.blog.xobj.XBlogPost;
import org.xwiki.android.fileStore.FSDocumentReference;
import org.xwiki.android.ral.RaoException;
import org.xwiki.android.rest.RestConnectorException;
import org.xwiki.android.xmodel.entity.Document;
import org.xwiki.android.xmodel.entity.Document;
import org.xwiki.android.xmodel.svc.DocumentLocalSvcCallbacks;
Expand Down Expand Up @@ -129,7 +130,7 @@ public void onCreated(Document res, boolean success, RaoException ex)
}

@Override
public void handleException(IOException e)
public void handleException(RestConnectorException e)
{
// SyncServic.syncLater(doc)
docsvc.save(doc, null, null);// !!! unending loop if file saving is not successful, and u pass 'this' as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class XBlogPost extends XSimpleObject

public XBlogPost()
{
className = "Blog.BlogPostClass";// set Type.
super("Blog.BlogPostClass");// set Type.
}

public String getCategory()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package org.xwiki.android.blog.xobj;

public class XCategory
import org.xwiki.android.xmodel.xobjects.XSimpleObject;

public class XCategory extends XSimpleObject
{
// todo: text area class desc
// stringclass name
public XCategory()
{
super("");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.xwiki.android.entity.LoginAttempt;
import org.xwiki.android.entity.User;
import org.xwiki.android.rest.HttpConnector;
import org.xwiki.android.rest.RestConnectorException;

import com.j256.ormlite.dao.Dao;

Expand All @@ -30,7 +31,13 @@ public class LoginFacade
public int login(String username, String password, String url, boolean remPwd)
{
HttpConnector httpConnector = new HttpConnector();
int code = httpConnector.checkLogin(username, password, url);
int code=0;
try {
code = httpConnector.checkLogin(username, password, url);
} catch (RestConnectorException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// start seperate thread to add login attempt to DB. (update LoginAttempt , update User if new user data
// combination )
Thread statusUpdater = new Thread(new statusUpdater(username, password, url, code, remPwd));
Expand Down
Loading

0 comments on commit c14fc45

Please sign in to comment.