public final class MesosferDataSchema
extends java.lang.Object
MesosferDataSchema
is a local representation of schema that can be saved and
retrieved from the Mesosfer cloud.
The basic workflow for creating new schema is to construct a new MesosferDataSchema
by accessing createSchema(String)
, use addColumn(String, MesosferObject.Type)
to fill it with data, and then use saveAsync(SaveCallback)
to persist to the cloud.
The basic workflow for accessing existing data is to use a MesosferQuery
to specify which
existing data to retrieve.Modifier and Type | Method and Description |
---|---|
MesosferDataSchema |
addColumn(java.lang.String name,
MesosferObject.Type type)
Add a column for
MesosferDataSchema |
static MesosferDataSchema |
createSchema(java.lang.String bucket)
Constructs a new
MesosferDataSchema with no data in it. |
static MesosferDataSchema |
createWithObjectId(java.lang.String objectId)
Creates a reference to an existing
MesosferDataSchema for use in creating
associations between MesosferDataSchema s. |
void |
deleteAsync(DeleteCallback callback)
Deletes this object on the server in a background thread.
|
MesosferDataSchema |
deleteColumn(java.lang.String name)
Delete a column from a
MesosferDataSchema |
void |
fetchAsync(GetCallback<MesosferDataSchema> callback)
Fetches this object with the data from the server in a background thread.
|
java.lang.String |
getBucket()
Gets the bucket name of this
MesosferDataSchema |
java.util.List<MesosferColumn> |
getColumn()
Gets the list of column for
MesosferDataSchema . |
java.util.Date |
getCreatedAt()
This reports time as the server sees it, so that if you create a
MesosferDataSchema ,
then wait a while, and then call saveAsync(SaveCallback) , the creation time will be
the time of the first saveAsync(SaveCallback) call rather than the time the object
was created locally. |
java.lang.String |
getObjectId()
Accessor to the object id.
|
static MesosferQuery<MesosferDataSchema> |
getQuery()
Constructs a query for
MesosferDataSchema . |
static MesosferQuery<MesosferDataSchema> |
getQuery(java.lang.String bucket)
Constructs a query for
MesosferData . |
java.util.Date |
getUpdatedAt()
This reports time as the server sees it, so that if you make changes to a
MesosferDataSchema ,
then wait a while, and then call saveAsync(SaveCallback) , the updated time will be
the time of the saveAsync(SaveCallback) call rather than the time the object
was changed locally. |
boolean |
isDataAvailable()
Gets whether the
MesosferDataSchema has been fetched. |
void |
saveAsync(SaveCallback callback)
Saves this object with the data from the server in a background thread.
|
org.json.JSONObject |
toJSON()
To put all keys and values of this
MesosferData into a JSONObject . |
java.lang.String |
toString() |
public static MesosferDataSchema createSchema(java.lang.String bucket)
MesosferDataSchema
with no data in it. A MesosferDataSchema
constructed in this way will not have an objectId and will not persist to the database until
saveAsync(SaveCallback)
is called.
Bucket names must be alphanumerical, and must start with a letter. It is recommended
to name classes in MesosferCaseLikeThis
.
bucket
- the bucket name for this MesosferDataSchema
MesosferDataSchema
public static MesosferDataSchema createWithObjectId(java.lang.String objectId)
MesosferDataSchema
for use in creating
associations between MesosferDataSchema
s. Calling isDataAvailable()
on
this object will return false
until fetchAsync(GetCallback)
has been called.objectId
- The object id for the referenced object.MesosferDataSchema
without data.public boolean isDataAvailable()
MesosferDataSchema
has been fetched.true
if the MesosferDataSchema
is new or has been fetched.
false
otherwise.public java.lang.String getBucket()
MesosferDataSchema
MesosferDataSchema
public java.util.List<MesosferColumn> getColumn()
MesosferDataSchema
.public java.lang.String getObjectId()
public java.util.Date getCreatedAt()
MesosferDataSchema
,
then wait a while, and then call saveAsync(SaveCallback)
, the creation time will be
the time of the first saveAsync(SaveCallback)
call rather than the time the object
was created locally.public java.util.Date getUpdatedAt()
MesosferDataSchema
,
then wait a while, and then call saveAsync(SaveCallback)
, the updated time will be
the time of the saveAsync(SaveCallback)
call rather than the time the object
was changed locally.public MesosferDataSchema deleteColumn(java.lang.String name)
MesosferDataSchema
name
- The name of columnMesosferDataSchema
for chaining taskpublic MesosferDataSchema addColumn(java.lang.String name, MesosferObject.Type type)
MesosferDataSchema
name
- The name of columntype
- The MesosferObject.Type
of columnMesosferDataSchema
for chaining taskpublic void fetchAsync(GetCallback<MesosferDataSchema> callback)
callback
- callback.done(object, e)
is called when the fetch completes.public void saveAsync(SaveCallback callback)
callback
- callback.done(e)
is called when the save completes.public void deleteAsync(DeleteCallback callback)
callback
- callback.done(e)
is called when the save completes.public static MesosferQuery<MesosferDataSchema> getQuery()
MesosferDataSchema
.public static MesosferQuery<MesosferDataSchema> getQuery(java.lang.String bucket)
MesosferData
.bucket
- The bucket name that used for MesosferData
public org.json.JSONObject toJSON()
MesosferData
into a JSONObject
.JSONObject
of all keys and valuespublic java.lang.String toString()
toString
in class java.lang.Object