Skip to content

Commit

Permalink
Save, List, Load functionality of File Store is complete
Browse files Browse the repository at this point in the history
  • Loading branch information
sasinda committed Jul 8, 2012
1 parent 45de346 commit 2d8672d
Show file tree
Hide file tree
Showing 29 changed files with 1,035 additions and 824 deletions.
92 changes: 74 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,82 @@
<version>2.2.1</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.j256.ormlite</groupId>
<artifactId>ormlite-core</artifactId>
<type>jar</type>
<version>4.40</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>com.j256.ormlite</groupId>
<artifactId>ormlite-android</artifactId>
<type>jar</type>
<version>4.40</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.simpleframework</groupId>
<artifactId>simple-xml</artifactId>
<version>2.6.4</version>
<type>jar</type>
<scope>compile</scope>
<exclusions>
<!-- StAX is not available on Android -->
<exclusion>
<artifactId>stax</artifactId>
<groupId>stax</groupId>
</exclusion>
<exclusion>
<artifactId>stax-api</artifactId>
<groupId>stax</groupId>
</exclusion>
<!-- Provided by Android -->
<exclusion>
<artifactId>xpp3</artifactId>
<groupId>xpp3</groupId>
</exclusion>
</exclusions>
</dependency>




</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<sdk>
<platform>7</platform>
</sdk>
<emulator>
<avd>android-7</avd>
</emulator>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
<coreLibrary>true</coreLibrary>
</configuration>
<extensions>true</extensions>
</plugin>
</plugins>

<plugins>

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>

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

</build>
</project>
12 changes: 0 additions & 12 deletions xwiki-android-client/default.properties

This file was deleted.

7 changes: 3 additions & 4 deletions xwiki-android-client/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}\tools\proguard\proguard-android.txt:proguard-project.txt

#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-7
android.library.reference.1=..\\xwiki-android-components
android.library.reference.2=..\\xwiki-android-rest
android.library.reference.3=../xwiki-android-core
android.library.reference.1=../xwiki-android-rest
android.library.reference.2=../xwiki-android-components
9 changes: 5 additions & 4 deletions xwiki-android-client/res/layout/blog_editor_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
android:layout_weight="2"
android:text="Title"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/et_blog_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName" >
android:inputType="textPersonName"
android:text="demoPage" >

<requestFocus />
</EditText>
Expand All @@ -40,13 +41,13 @@
android:layout_weight="2"
android:text="Category"
android:textAppearance="?android:attr/textAppearanceMedium" />
<AutoCompleteTextView
android:id="@+id/actv_blog_category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="AutoCompleteTextView" />
android:text="Blog.Personal" />

</TableRow>
Expand Down
50 changes: 50 additions & 0 deletions xwiki-android-client/src/demo_tutorials/_01_CreateDocument.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package demo_tutorials;

import org.xwiki.android.blog.xobj.XBlogPost;
import org.xwiki.android.ral.RaoException;
import org.xwiki.android.xmodel.entity.Document;
import org.xwiki.android.xmodel.entity.Document;
import org.xwiki.android.xmodel.svc.DocumentRemoteSvcCallbacks;
import org.xwiki.android.xmodel.svc.DocumentRemoteSvcs;
import org.xwiki.android.xmodel.svc.DocumentSvcImpl;


public class _01_CreateDocument
{
public void demo(){

Document mydoc=new Document("wikiName", "spaceName", "pageName");//create empty document
//lets make a Blog.BlogPostClass object to put into mydoc.
// in XA all model objects,classes, properties are prefixed with X.
XBlogPost blgpstObj=new XBlogPost(); // Blog.BlogPostClass is know as ...blog.xobj.XBlogPost. Here we have removed
// the suffix Class and added a prefix X.

//lets edit some properties of the XBlogPost object
blgpstObj.setContent("This blog post is created with Xwiki Android");
mydoc.addObject(blgpstObj);

DocumentRemoteSvcs docsvc=new DocumentSvcImpl();// the current implementation for DocumentRemoteSvcs is this.

//docsvc can be used to creat the document on the server. The service uses a seperate thread to do all the work.
//The results are given through a callback.

DocumentRemoteSvcCallbacks clbk=new DocumentRemoteSvcCallbacks()
{
@Override
public void onCreated(Document res, boolean success, RaoException ex)
{
if(success){
// update ui here. You can notify the user that the doc was created in the server.
}else{
//you can check what the exception is and try to rectify.
//Most probably this same document is already existing in the server. So you should delete
//the already existing one and recreate. Or you can do a simple update by docsvc.update(mydoc, clbk);
}
}
};
docsvc.create(mydoc,clbk); //ok the docsvc does all the work of creating a page for the document and then adding
// all those objects,tags,comments and attachments in the document.


}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package demo_tutorials;

import org.xwiki.android.blog.xobj.XBlogPost;
import org.xwiki.android.xmodel.entity.Document;
import org.xwiki.android.xmodel.xobjects.XBooleanProperty;


public class _02_AdvancedObjectEditing
{
public void demo(){

Document mydoc=new Document("wikiName", "spaceName", "pageName");//create empty document
XBlogPost blgpstObj=new XBlogPost();
blgpstObj.setHidden(true);//simple way to edit the value of "hidden" property of XBlogPost.

//say, now we want to do some advanced stuff with that property.
XBooleanProperty hiddenP= blgpstObj.getpHidden();// use getp, setp methods to get the property.
//lets change hidden again.
hiddenP.setValue(false);
//change an attribute of the property.
hiddenP.setPrettyName("Hidden pretty name");

//Since a reference is passed, you do not have to blgpstObj.setpHidden(hiddenP) to commit the effects.

}
}
23 changes: 23 additions & 0 deletions xwiki-android-client/src/demo_tutorials/_03_SaveDocument.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package demo_tutorials;

import org.xwiki.android.xmodel.entity.Document;
import org.xwiki.android.xmodel.svc.DocumentLocalSvcs;
import org.xwiki.android.xmodel.svc.DocumentSvcImpl;

public class _03_SaveDocument
{
public void demo(){

Document mydoc=new Document("wikiName", "spaceName", "pageName");//create empty document
// ... edit mydoc

//lets save it!

DocumentLocalSvcs docsvcl=new DocumentSvcImpl();

docsvcl.save(mydoc, "My tag to identify this easily", null);//docsvcl.save(doc, tag, clbk). we pass null for clbk
// since we do not want to know wether the doc was sucessfully
// saved or not.

}
}
35 changes: 35 additions & 0 deletions xwiki-android-client/src/demo_tutorials/_04_SaveDocumentAdv.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package demo_tutorials;

import java.io.File;

import org.xwiki.android.xmodel.entity.Document;
import org.xwiki.android.xmodel.svc.DocumentLocalSvcCallbacks;
import org.xwiki.android.xmodel.svc.DocumentLocalSvcs;
import org.xwiki.android.xmodel.svc.DocumentSvcImpl;

public class _04_SaveDocumentAdv
{
public void demo(){

Document mydoc=new Document("wikiName", "spaceName", "pageName");//create empty document
// ... edit mydoc


DocumentLocalSvcs docsvcl=new DocumentSvcImpl();
DocumentLocalSvcCallbacks clbk=new DocumentLocalSvcCallbacks()
{
@Override
public void onSaveComplete(File savedto)
{
if(savedto!=null){
//success. Edit UI to notify user here.
}else{
//oops problem. May be the device storage is full.
}

}
};
docsvcl.save(mydoc, "My tag to identify this easily", null);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package demo_tutorials;

import java.util.List;
import java.util.Map;

import org.xwiki.android.fileStore.FSDocumentReference;
import org.xwiki.android.xmodel.entity.Document;
import org.xwiki.android.xmodel.svc.DocumentLocalSvcCallbacks;
import org.xwiki.android.xmodel.svc.DocumentLocalSvcs;
import org.xwiki.android.xmodel.svc.DocumentSvcImpl;

import android.app.Activity;

public class _05_ListAndLoadDocuments extends Activity
{

FSDocumentReference loadMe;
DocumentLocalSvcs ds;

protected void onCreate(android.os.Bundle savedInstanceState)
{

ds = new DocumentSvcImpl();

DocumentLocalSvcCallbacks clbk1 = new DocumentLocalSvcCallbacks()
{
@Override
public void onListingComplete(List<FSDocumentReference> rslts, Map<String, Object> matchedby)
{
// matched by will contain entry ("space", "MySpace")
loadMe = rslts.get(0);
loadThis(loadMe);
}
};

ds.listBySpace("MySpace", clbk1);
// after the listing is complete you will be notified in the onListingComplete.
}

private void loadThis(FSDocumentReference ref)
{
DocumentLocalSvcCallbacks clbk2 = new DocumentLocalSvcCallbacks()
{
@Override
public void onLoadComplete(Document entity)
{
//entity is the loaded document.
}
};
ds.load(ref, clbk2);
}

}
Empty file.
Loading

0 comments on commit 2d8672d

Please sign in to comment.