Giter VIP home page Giter VIP logo

vault's Issues

RxJava support

Since links are represented on different tables this currently limits the query abilities when applying a where() clause, as one cannot add conditions based on linked entries:

vault.fetch(Cat.class)
    .where("bestFriend.remote_id = ?", "foo") // won't work
    .all();

This forces the caller to filter the results manually. Among many other benefits, supporting queries with RxJava could make this a little bit less tedious, for example:

vault.observe(Cat.class)
    .filter((cat) -> "FOO".equals(cat.bestFriend().remoteId())
    .subscribe((cat) -> ...);

What is vault_file_name.db ? Where to get it from?

In seeding section I saw it being mentioned to put file "vault_file_name.db" in assets folder and then refer it while declaring space. But no where I found it mentioned what "vault_file_name.db" is and how to generate or download it ?

Support multiple locales on the one app

Is there a way to have multiple languages persisted on the device? This is quite a big feature of our app and if we cannot have multiple languages persisted we will need to roll our own implementation.

At the moment, there is only one language supported with a single .sqllite file. If it was possible, we would prefer to have the id of the database file linked to the locale as well. That way we can switch the locale and language easily.

There is also evidence that switching to another language will not overwrite the previous language. Do we have to remove the space and start over?

I'm getting a NoClassDefFoundError for the retrofit.RestAdapter in the CDA client only on android api 19(4.4.4) on a Huawei Y635-l01.

This issue in not happening in any other device

These are the related dependencies. As you can see i'm using retrofit in the app as well:
apt 'com.contentful.vault:compiler:2.0.0'
compile'com.contentful.vault:core:2.0.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.0'
compile('com.squareup.retrofit2:adapter-rxjava:2.0.0') {
exclude module: 'rxjava'
exclude module: 'rxandroid'
}

I'm building the CDAClient in the application class' onCreate().

Fatal Exception: java.lang.NoClassDefFoundError: retrofit.RestAdapter$Builder
at com.contentful.java.cda.CDAClient.createService(CDAClient.java:54)
at com.contentful.java.cda.CDAClient.(CDAClient.java:38)
at com.contentful.java.cda.CDAClient.(CDAClient.java:23)
at com.contentful.java.cda.CDAClient$Builder.build(CDAClient.java:265)
at uk.co.activityhunter.activityhunter.util.ProjectUtils.setCDAClient(ProjectUtils.java:105)
at uk.co.activityhunter.activityhunter.application.AHApp.onCreate(AHApp.java:26)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1009)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4632)
at android.app.ActivityThread.access$1800(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1298)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5336)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:873)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:689)
at dalvik.system.NativeStart.main(NativeStart.java)

SQLiteException on tables upgrade

I've got this exception while upgrading tables (new value in dbVersion). It seems the table name with "-" is not allowed.

Caused by: android.database.sqlite.SQLiteException: near "-": syntax error (code 1): , while compiling: DROP TABLE assets$en-US at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887) at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:498) at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588) at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58) at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31) at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1674) at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1605) at com.contentful.vault.SqliteHelper.deleteTables(SqliteHelper.java:128) at com.contentful.vault.SqliteHelper.onUpgrade(SqliteHelper.java:70)

Content types with non localised symbols are NULL when sync'ed

Hi.

I was trying to create a new content type to sync and I am currently having some trouble syncing the non localised fields.

I inspected the database output and the identifier and helpKey fields are currently set to NULL for all the entry_{id}${locale} tables

Only the content field is downloaded and it is because it is localisable.

I have tested it against vault 0.9.14 and 2.0.0 and it has the same problem

Here is the model definition

@ContentType("helpContent")
public class Helpcontent extends Resource {
	@Field String identifier;
	@Field String content;
	@Field String helpKey;

	public Helpcontent() {
	}

	public String identifier() {
		return identifier;
	}

	public String helpKey() {
		return helpKey;
	}

	public String content() {
		return content;
	}
}

And here is the JSON preview

{
  "name": "Help content",
  "description": "",
  "displayField": "identifier",
  "fields": [
    {
      "id": "identifier",
      "name": "Identifier",
      "type": "Symbol",
      "localized": false,
      "required": true,
      "validations": [
        {
          "unique": true
        }
      ],
      "disabled": false,
      "omitted": false
    },
    {
      "id": "content",
      "name": "Content",
      "type": "Text",
      "localized": true,
      "required": true,
      "validations": [],
      "disabled": false,
      "omitted": false
    },
    {
      "name": "helpKey",
      "id": "helpKey",
      "type": "Symbol"
    }
  ],
  "sys": {
    "id": "helpContent",
    "type": "ContentType",
    "createdAt": "2016-11-02T14:28:38.538Z",
    "createdBy": {
      "sys": {
        "type": "Link",
        "linkType": "User",
        "id": "5u4wmZIO25TuaI2AWA4pJq"
      }
    },
    "space": {
      "sys": {
        "type": "Link",
        "linkType": "Space",
        "id": "vo0tsnu0x6xh"
      }
    },
    "firstPublishedAt": "2016-11-02T14:28:53.932Z",
    "publishedCounter": 2,
    "publishedAt": "2016-11-03T15:27:58.070Z",
    "publishedBy": {
      "sys": {
        "type": "Link",
        "linkType": "User",
        "id": "5u4wmZIO25TuaI2AWA4pJq"
      }
    },
    "publishedVersion": 3,
    "version": 4,
    "updatedAt": "2016-11-03T15:27:58.077Z",
    "updatedBy": {
      "sys": {
        "type": "Link",
        "linkType": "User",
        "id": "5u4wmZIO25TuaI2AWA4pJq"
      }
    }
  }
}

Inject class with model's db column names

@ContentType("foo")
public class Foo extends Resource {
  @Field String bar;
  @Field String baz;
}

should generate:

public class Foo$Fields {
  public static final String BAR "bar-db-column-name";
  public static final String BAZ "baz-db-column-name";
}

Model with no fields

@ContentType("foo")
public class Foo extends Resource { }

Currently results in a compile-time error:

Error:(X, X) error: Failed writing injection for "com.package.Foo", message: cannot unindent 1 from 0

This exception is raised due to incorrect use of JavaPoet since ModelInjection.java assumes at least one field was defined. Defining a model with no fields is an error, and a more friendly error message should indicate that.

Entry title

Contentful defines title for each content type. Would be possible to access the content of this field using a single method, something like:
resource.title()

Documentation on how to represent Links to other Entry types in models

Would you be able to describe how we would represent Links to other resources in the model itself?
At the moment, we have a content type that references other entry types but do not know how to represent it in the data models.

Edit - to clarify, these links in the data model can refer to many different content types

Hint about contenttype

Hi there,

I was struggling for some days why my stuff wasn't synced. The Problem was I wrote the contenttypes with an capital letter in the beginning, because it's displayed in the web interface of contentful. I think it would be a good idea to examine users of vault to have a look into the json preview and search for the contenttype.

Best
Alex

Replace query pipeline with a type-safe one

Making queries right now forces the caller to hardcode strings or concatenate them:

vault.fetch(Foo.class).where("gross = ?", bar)
vault.fetch(Foo.class).where(Foo$Fields.GROSS + " = ?", bar);

An alternative approach should be considered, one that potentially could also infer that JOIN clauses are required to fulfill the query.

Using the Preview API

Hi,

I was wondering if it possible to use the Preview API + key with this Vault library?

How do we use the Vault library using the preview api token?

Is it supported?

I am getting an exception even though there is a function in the CDAClient to use the preview API.

java.lang.UnsupportedOperationException: Syncing using a preview token is not supported. Please use a production token.

ORM is not loading the correct localised Asset

Hi.

I have come across a bug where if I have a localised Asset field, it will not load the correct Asset file, it will load the asset for the default locale.

The localised text fields are being loaded correctly, just the wrong asset is being loaded.

NPE when an object has link references caused by predefined string values in model

I was able to load up my content object using vault until I started added some links to other content types. It started to crash with the following stacktrace.

java.lang.NullPointerException
            at com.contentful.vault.LinkResolver.getCachedResourceOrFetch(LinkResolver.java:103)
            at com.contentful.vault.LinkResolver.resolveLinksForField(LinkResolver.java:70)
            at com.contentful.vault.LinkResolver.resolveLinks(LinkResolver.java:58)
            at com.contentful.vault.QueryResolver.resolveLinks(QueryResolver.java:81)
            at com.contentful.vault.QueryResolver.all(QueryResolver.java:65)
            at com.contentful.vault.FetchQuery.all(FetchQuery.java:27)
            at com.contentful.vault.FetchQuery.first(FetchQuery.java:31)
            at com.contentful.vault.FetchQuery.first(FetchQuery.java:43)

What else do you need to know to debug this scenario?

Concurrent Modification Exception thrown

Hi.

I am getting a very strange error all of a sudden where the requestSync action fails to complete and we are getting a java.util.ConcurrentModificationException

It looks like it is caused by Retrofit.

OnErrorThrowable$OnNextValue "rx.exceptions.OnErrorThrowable$OnNextValue: OnError while emitting onNext value: retrofit.client.Response.class"

OnError while emitting onNext value: retrofit.client.Response.class"

Is there a way to trace the source of this problem?

It was working fine last week. The only thing that has changed is the volume of localised content. Which is quite large.

How to use LIKE operator for fetching items

Hi,
I'm desperately trying to fetch all items whose Title contains MY_QUERY with vault + RxJava.

I've tried tons of variants, including:
.observe(Guide.class).where("title LIKE '%?%'", "MY_QUERY").all()
.observe(Guide.class).where("query", "MY_QUERY").all()

And many other options... Can you advise, please?

Querying for content based on linked sub objects

Hi.

We are starting to create some complex queries and was trying to figure out how we can search for content based on linked objects.

What sort of ORM model are you using and does it allow table joins?
Is it possible to query for content using a SQL statement?

Throw nicer error when initialized with invalid class

Example:

static class Foo { }
Vault vault = Vault.with(context, Foo.class); // passes
vault.requestSync(...); // fails

Exception:

java.lang.RuntimeException: java.lang.ClassNotFoundException: 
com.pkg.Whatever$Foo$$SpaceHelper
    at com.contentful.vault.Vault.createSpaceHelper(Vault.java:157)
    at com.contentful.vault.Vault.getOrCreateSqliteHelper(Vault.java:173)
    at com.contentful.vault.Vault.requestSync(Vault.java:107)
    at com.contentful.vaultintegration.BaseTest.sync(BaseTest.java:122)
    at com.contentful.vaultintegration.BaseTest.sync(BaseTest.java:98)
    at com.contentful.vaultintegration.ArrayTest.testArray(ArrayTest.java:40)

This should fail faster, right when Vault.with() is invoked. The error message should also be more informative.

Download all available locales

Hi.

Is there a way to download content for all available locales without knowing those specifically?

Because now, when I add new locale to contentful, I should add it to annotation and release new build to Play Market.

NoClassDefFoundError: com/contentful/vault/ContentType after upgrading to Android Studio 3.0 Canary 3

Hi,
After upgrading to Android Studio 3.0 Canary 3 and migrating everything according to the guide, project fails to build and shows
NoClassDefFoundError: com/contentful/vault/ContentType

My build.gradle contains:

    buildToolsVersion "26.0.0-rc2"
...
    implementation 'com.contentful.vault:core:2.1.0'
    annotationProcessor 'com.contentful.vault:compiler:2.1.0'
    
    implementation 'com.squareup.okhttp:okhttp:2.3.0'
    implementation 'com.squareup.okhttp:okhttp-urlconnection:2.3.0'
... 
    // ButterKnife compiles well
    implementation 'com.jakewharton:butterknife:8.6.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'

Thanks in advance.

Another model type

How feasible would be to use a different model type in Vault? Instead of using:

@ContentType("cat")
public class Cat extends Resource {
  @Field public String name;
  @Field public Cat bestFriend;
  @Field public Asset image;
}

define model in a different way:

public class Entry extends Resource {
  Map<String, Object> fields;
}

What I'm going to achieve is to fetch different content type objects in a single line of code, e.g.:

vault.fetch(Entry.class).where("contentType = ?", "Cat")

Fields null when sync

Hi,

I'm facing a problem, when i try to synchronize the contentful database, the most part of fields get null value and i don't know why, i'm using the default locale 'tlh'. I show you an example of one object result:

Brand{companyName='null', logo=null, companyDescription='null', website='null', twitter='null', email='null', phone=[+45 35 55 11 22]}

I only get values on list fields like 'phone' in this case.

Greetings

Vault enters an unmanagable loop when loading sub objects

Hi.

This is more of a problem with our content model itself but it would be a good idea to raise this as an issue and safeguard against it because it causes the app to freeze

At the moment, I have Content Type A that references Content Type B.
Due to poor design on our part, Content Type B contains links to Content Type A which causes the looping problem.

I do understand that the quickest way to solve this is to fix the links between the content types, but is there a strategy to introduce into the vault ORM that prevents such links from being loaded?

Asset metadata is incomplete

Currently only the URL and mime-type of an asset are provided by the Asset class. title should also be supported as well as the file JSON element and description.

Exception thrown after the content type is changed

I added a new field into existing content type. Model object was updated to reflect this field. Also I had previously many entries created for this content type. I got then the following exception in ModelHelper of that content type (fromCursor method):

Caused by: java.lang.IllegalStateException: Couldn't read row 0, col 6 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it. at android.database.CursorWindow.nativeGetString(Native Method) at android.database.CursorWindow.getString(CursorWindow.java:438) at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51)

I think a null check should be added somewhere inside the appendFromCursor method of com.contentful.vault.compiler.ModelInjection class.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.