com.vaadin.polymer.app.widget.AppPouchdbDocument Maven / Gradle / Ivy
/*
* This code was generated with Vaadin Web Component GWT API Generator,
* from app-pouchdb project by The Polymer Authors
* that is licensed with http://polymer.github.io/LICENSE.txt license.
*/
package com.vaadin.polymer.app.widget;
import com.vaadin.polymer.app.*;
import com.vaadin.polymer.*;
import com.vaadin.polymer.elemental.*;
import com.vaadin.polymer.PolymerWidget;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.core.client.JavaScriptObject;
/**
* app-pouchdb-document
is an implementation of Polymer.AppStorageBehavior
for reading and writing to individual PouchDB documents.
* In order to refer to a PouchDB document, provide the name of the database
(both local and remote databases are supported) and the ID of the document.
* For example:
* <app-pouchdb-document
* db-name="cats"
* doc-id="parsnip">
* </app-pouchdb-document>
*
* In the above example, a PouchDB instance will be created to connect to the
local database named “cats”. Then it will check to see if a document with the
ID “parsnip” exists. If it does, the data
property of the document will be
set to the value of the document. If it does not, then any subsequent
assignments to the data
property will cause a document with ID “parsnip” to
be created.
* Here is an example of a simple form that can be used to read and write to a
PouchDB document:
* <app-pouchdb-document
* db-name="cats"
* doc-id="parsnip"
* data="{{cat}}">
* </app-pouchdb-document>
* <input
* is="iron-input"
* bind-value="{{cat.name}}">
* </input>
*
*/
public class AppPouchdbDocument extends PolymerWidget {
/**
* Default Constructor.
*/
public AppPouchdbDocument() {
this("");
}
/**
* Constructor used by UIBinder to create widgets with content.
*/
public AppPouchdbDocument(String html) {
super(AppPouchdbDocumentElement.TAG, AppPouchdbDocumentElement.SRC, html);
}
/**
* Gets a handle to the Polymer object's underlying DOM element.
*/
public AppPouchdbDocumentElement getPolymerElement() {
return (AppPouchdbDocumentElement) getElement();
}
/**
* If true, all attempts to “put” or “post” values into the database
will be automatically structured as an “upsert”, where documents are
updated if already available, or created if not.
*
* JavaScript Info:
* @property upsert
* @type Boolean
*
*/
public boolean getUpsert() {
return getPolymerElement().getUpsert();
}
/**
* If true, all attempts to “put” or “post” values into the database
will be automatically structured as an “upsert”, where documents are
updated if already available, or created if not.
*
* JavaScript Info:
* @property upsert
* @type Boolean
*
*/
public void setUpsert(boolean value) {
getPolymerElement().setUpsert(value);
}
/**
* The number of document revisions to keep track of. The default value
(0) indicates no limit.
*
* JavaScript Info:
* @property revsLimit
* @type Number
* @behavior AppPouchdbQuery
*/
public double getRevsLimit() {
return getPolymerElement().getRevsLimit();
}
/**
* The number of document revisions to keep track of. The default value
(0) indicates no limit.
*
* JavaScript Info:
* @property revsLimit
* @type Number
* @behavior AppPouchdbQuery
*/
public void setRevsLimit(double value) {
getPolymerElement().setRevsLimit(value);
}
/**
* A reference to the PouchDB database instance that has been created.
*
* JavaScript Info:
* @property db
* @type Object
* @behavior AppPouchdbQuery
*/
public JavaScriptObject getDb() {
return getPolymerElement().getDb();
}
/**
* A reference to the PouchDB database instance that has been created.
*
* JavaScript Info:
* @property db
* @type Object
* @behavior AppPouchdbQuery
*/
public void setDb(JavaScriptObject value) {
getPolymerElement().setDb(value);
}
/**
* Override this getter to define the default value to use when
there’s no data stored.
*
* JavaScript Info:
* @property zeroValue
* @type *
* @behavior AppPouchdbDocument
*/
public JavaScriptObject getZeroValue() {
return getPolymerElement().getZeroValue();
}
/**
* Override this getter to define the default value to use when
there’s no data stored.
*
* JavaScript Info:
* @property zeroValue
* @type *
* @behavior AppPouchdbDocument
*/
public void setZeroValue(JavaScriptObject value) {
getPolymerElement().setZeroValue(value);
}
/**
* The data to synchronize.
*
* JavaScript Info:
* @property data
* @type Object
* @behavior AppPouchdbDocument
*/
public JavaScriptObject getData() {
return getPolymerElement().getData();
}
/**
* The data to synchronize.
*
* JavaScript Info:
* @property data
* @type Object
* @behavior AppPouchdbDocument
*/
public void setData(JavaScriptObject value) {
getPolymerElement().setData(value);
}
/**
* A changes event emitter. Notifies of changes to the PouchDB document
referred to by docId
, if a docId
has been provided.
*
* JavaScript Info:
* @property changes
* @type Object
*
*/
public JavaScriptObject getChanges() {
return getPolymerElement().getChanges();
}
/**
* A changes event emitter. Notifies of changes to the PouchDB document
referred to by docId
, if a docId
has been provided.
*
* JavaScript Info:
* @property changes
* @type Object
*
*/
public void setChanges(JavaScriptObject value) {
getPolymerElement().setChanges(value);
}
/**
* Override this getter to return true if the value has never been
persisted to storage.
*
* JavaScript Info:
* @property isNew
* @type boolean
* @behavior AppPouchdbDocument
*/
public boolean getIsNew() {
return getPolymerElement().getIsNew();
}
/**
* Override this getter to return true if the value has never been
persisted to storage.
*
* JavaScript Info:
* @property isNew
* @type boolean
* @behavior AppPouchdbDocument
*/
public void setIsNew(boolean value) {
getPolymerElement().setIsNew(value);
}
/**
* When true, will perform detailed logging.
*
* JavaScript Info:
* @property log
* @type Boolean
* @behavior AppPouchdbDocument
*/
public boolean getLog() {
return getPolymerElement().getLog();
}
/**
* When true, will perform detailed logging.
*
* JavaScript Info:
* @property log
* @type Boolean
* @behavior AppPouchdbDocument
*/
public void setLog(boolean value) {
getPolymerElement().setLog(value);
}
/**
* If this is true transactions will happen one after the other,
never in parallel.
* Specifically, no transaction will begin until every previously
enqueued transaction by this element has completed.
* If it is false, new transactions will be executed as they are
received.
*
* JavaScript Info:
* @property sequentialTransactions
* @type Boolean
* @behavior AppPouchdbDocument
*/
public boolean getSequentialTransactions() {
return getPolymerElement().getSequentialTransactions();
}
/**
* If this is true transactions will happen one after the other,
never in parallel.
* Specifically, no transaction will begin until every previously
enqueued transaction by this element has completed.
* If it is false, new transactions will be executed as they are
received.
*
* JavaScript Info:
* @property sequentialTransactions
* @type Boolean
* @behavior AppPouchdbDocument
*/
public void setSequentialTransactions(boolean value) {
getPolymerElement().setSequentialTransactions(value);
}
/**
* A promise that will resolve once all queued transactions
have completed.
* This field is updated as new transactions are enqueued, so it will
only wait for transactions which were enqueued when the field
was accessed.
* This promise never rejects.
*
* JavaScript Info:
* @property transactionsComplete
* @type Promise
* @behavior AppPouchdbDocument
*/
public JavaScriptObject getTransactionsComplete() {
return getPolymerElement().getTransactionsComplete();
}
/**
* A promise that will resolve once all queued transactions
have completed.
* This field is updated as new transactions are enqueued, so it will
only wait for transactions which were enqueued when the field
was accessed.
* This promise never rejects.
*
* JavaScript Info:
* @property transactionsComplete
* @type Promise
* @behavior AppPouchdbDocument
*/
public void setTransactionsComplete(JavaScriptObject value) {
getPolymerElement().setTransactionsComplete(value);
}
/**
* If desired, assign a function that implements a conflict resolution
strategy. This conflict resolution strategy will take precedence when
a conflict occurs, and will prevent conflict notification events from
being fired.
* Consider using an app-pouchdb-conflict-resolver
element instead for
a more declarative experience!
*
* JavaScript Info:
* @property resolveConflict
* @type Function
*
*/
public Function getResolveConflict() {
return getPolymerElement().getResolveConflict();
}
/**
* If desired, assign a function that implements a conflict resolution
strategy. This conflict resolution strategy will take precedence when
a conflict occurs, and will prevent conflict notification events from
being fired.
* Consider using an app-pouchdb-conflict-resolver
element instead for
a more declarative experience!
*
* JavaScript Info:
* @property resolveConflict
* @type Function
*
*/
public void setResolveConflict(Function value) {
getPolymerElement().setResolveConflict(value);
}
/**
* The current _rev (revision) of the PouchDB document that this
element’s data refers to, if the document is not new.
*
* JavaScript Info:
* @property rev
* @type String
*
*/
public String getRev() {
return getPolymerElement().getRev();
}
/**
* The current _rev (revision) of the PouchDB document that this
element’s data refers to, if the document is not new.
*
* JavaScript Info:
* @property rev
* @type String
*
*/
public void setRev(String value) {
getPolymerElement().setRev(value);
}
/**
* The PouchDB adapter to use. For more information on PouchDB adapters,
please refer to the PouchDB documentation
here.
*
* JavaScript Info:
* @property adapter
* @type String
* @behavior AppPouchdbQuery
*/
public String getAdapter() {
return getPolymerElement().getAdapter();
}
/**
* The PouchDB adapter to use. For more information on PouchDB adapters,
please refer to the PouchDB documentation
here.
*
* JavaScript Info:
* @property adapter
* @type String
* @behavior AppPouchdbQuery
*/
public void setAdapter(String value) {
getPolymerElement().setAdapter(value);
}
/**
* The name of the database. This can be either a local database (such
as “cats”), or a remote one (e.g., “https://example.com:5678/cats“).
*
* JavaScript Info:
* @property dbName
* @type String
* @behavior AppPouchdbQuery
*/
public String getDbName() {
return getPolymerElement().getDbName();
}
/**
* The name of the database. This can be either a local database (such
as “cats”), or a remote one (e.g., “https://example.com:5678/cats“).
*
* JavaScript Info:
* @property dbName
* @type String
* @behavior AppPouchdbQuery
*/
public void setDbName(String value) {
getPolymerElement().setDbName(value);
}
/**
* The value of the _id (Pouch/Couch unique identifier) of the PouchDB
document that this element’s data should refer to.
*
* JavaScript Info:
* @property docId
* @type String
*
*/
public String getDocId() {
return getPolymerElement().getDocId();
}
/**
* The value of the _id (Pouch/Couch unique identifier) of the PouchDB
document that this element’s data should refer to.
*
* JavaScript Info:
* @property docId
* @type String
*
*/
public void setDocId(String value) {
getPolymerElement().setDocId(value);
}
// Needed in UIBinder
/**
* Override this getter to define the default value to use when
there’s no data stored.
*
* JavaScript Info:
* @attribute zero-value
* @behavior AppPouchdbDocument
*/
public void setZeroValue(String value) {
Polymer.property(this.getPolymerElement(), "zeroValue", value);
}
// Needed in UIBinder
/**
* A reference to the PouchDB database instance that has been created.
*
* JavaScript Info:
* @attribute db
*
*/
public void setDb(String value) {
Polymer.property(this.getPolymerElement(), "db", value);
}
// Needed in UIBinder
/**
* The data to synchronize.
*
* JavaScript Info:
* @attribute data
* @behavior AppPouchdbDocument
*/
public void setData(String value) {
Polymer.property(this.getPolymerElement(), "data", value);
}
// Needed in UIBinder
/**
* A promise that will resolve once all queued transactions
have completed.
* This field is updated as new transactions are enqueued, so it will
only wait for transactions which were enqueued when the field
was accessed.
* This promise never rejects.
*
* JavaScript Info:
* @attribute transactions-complete
* @behavior AppPouchdbDocument
*/
public void setTransactionsComplete(String value) {
Polymer.property(this.getPolymerElement(), "transactionsComplete", value);
}
// Needed in UIBinder
/**
* The number of document revisions to keep track of. The default value
(0) indicates no limit.
*
* JavaScript Info:
* @attribute revs-limit
* @behavior AppPouchdbQuery
*/
public void setRevsLimit(String value) {
Polymer.property(this.getPolymerElement(), "revsLimit", value);
}
// Needed in UIBinder
/**
* A changes event emitter. Notifies of changes to the PouchDB document
referred to by docId
, if a docId
has been provided.
*
* JavaScript Info:
* @attribute changes
*
*/
public void setChanges(String value) {
Polymer.property(this.getPolymerElement(), "changes", value);
}
/**
*
*
* JavaScript Info:
* @method setStoredValue
* @param {} storagePath
* @param {} value
*
*
*/
public void setStoredValue(Object storagePath, Object value) {
getPolymerElement().setStoredValue(storagePath, value);
}
/**
*
*
* JavaScript Info:
* @method getStoredValue
* @param {} storagePath
*
*
*/
public void getStoredValue(Object storagePath) {
getPolymerElement().getStoredValue(storagePath);
}
/**
* A convenience method. Returns true iff value is null, undefined,
an empty array, or an object with no keys.
*
* JavaScript Info:
* @method valueIsEmpty
* @param {} value
* @behavior AppPouchdbDocument
*
*/
public void valueIsEmpty(Object value) {
getPolymerElement().valueIsEmpty(value);
}
/**
*
*
* JavaScript Info:
* @method reset
*
*
*/
public void reset() {
getPolymerElement().reset();
}
/**
* Perform the initial sync between storage and memory. This method
is called automatically while the element is being initialized.
Implementations may override it.
* If an implementation intends to call this method, it should instead
call _initializeStoredValue, which provides reentrancy protection.
*
* JavaScript Info:
* @method initializeStoredValue
* @behavior AppPouchdbDocument
* @return {JavaScriptObject}
*/
public JavaScriptObject initializeStoredValue() {
return getPolymerElement().initializeStoredValue();
}
/**
* Remove the data from storage.
*
* JavaScript Info:
* @method destroy
* @behavior AppPouchdbDocument
* @return {JavaScriptObject}
*/
public JavaScriptObject destroy() {
return getPolymerElement().destroy();
}
/**
*
*
* JavaScript Info:
* @method save
*
*
*/
public void save() {
getPolymerElement().save();
}
/**
* Override this method.
* If the data value represented by this storage instance is new, this
method generates an attempt to write the value to storage.
*
* JavaScript Info:
* @method saveValue
* @param {*} args
* @behavior AppPouchdbDocument
* @return {JavaScriptObject}
*/
public JavaScriptObject saveValue(JavaScriptObject args) {
return getPolymerElement().saveValue(args);
}
/**
* Override this method to implement creating and updating
stored values.
*
* JavaScript Info:
* @method setStoredValue
* @param {string} storagePath
* @param {*} value
* @behavior AppPouchdbDocument
* @return {JavaScriptObject}
*/
public JavaScriptObject setStoredValue(String storagePath, JavaScriptObject value) {
return getPolymerElement().setStoredValue(storagePath, value);
}
/**
* Maps a storage path to the corresponding Polymer databinding path.
Override to define a custom mapping.
* The inverse of memoryPathToStoragePath.
*
* JavaScript Info:
* @method storagePathToMemoryPath
* @param {string} path
* @behavior AppPouchdbDocument
* @return {String}
*/
public String storagePathToMemoryPath(String path) {
return getPolymerElement().storagePathToMemoryPath(path);
}
/**
* Maps a Polymer databinding path to the corresponding path in the
storage system. Override to define a custom mapping.
* The inverse of storagePathToMemoryPath.
*
* JavaScript Info:
* @method memoryPathToStoragePath
* @param {string} path
* @behavior AppPouchdbDocument
* @return {String}
*/
public String memoryPathToStoragePath(String path) {
return getPolymerElement().memoryPathToStoragePath(path);
}
/**
* Enables performing transformations on the in-memory representation of
storage without activating observers that will cause those
transformations to be re-applied to the storage backend. This is useful
for preventing redundant (or cyclical) application of transformations.
*
* JavaScript Info:
* @method syncToMemory
* @param {Function} operation
* @behavior AppPouchdbDocument
*
*/
public void syncToMemory(Function operation) {
getPolymerElement().syncToMemory(operation);
}
}