-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Save, List, Load functionality of File Store is complete
- Loading branch information
Showing
29 changed files
with
1,035 additions
and
824 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
xwiki-android-client/src/demo_tutorials/_01_CreateDocument.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
||
|
||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
xwiki-android-client/src/demo_tutorials/_02_AdvancedObjectEditing.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
23
xwiki-android-client/src/demo_tutorials/_03_SaveDocument.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
35
xwiki-android-client/src/demo_tutorials/_04_SaveDocumentAdv.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
xwiki-android-client/src/demo_tutorials/_05_ListAndLoadDocuments.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.