@Test public void testExists() { try (ODatabaseDocumentTx db = database.getInstance().connect()) { entityAdapter.register(db); entityAdapter.addEntity(db, createComponent(bucket, "com.example", "testapp", "1.0")); entityAdapter.addEntity(db, createComponent(bucket, null, "foo", "2.0")); entityAdapter.addEntity(db, createComponent(bucket, null, "bar", null)); assertThat(entityAdapter.exists(db, "com.example", "testapp", "1.0", bucket), is(true)); assertThat(entityAdapter.exists(db, null, "foo", "2.0", bucket), is(true)); assertThat(entityAdapter.exists(db, null, "bar", null, bucket), is(true)); assertThat(entityAdapter.exists(db, "com.example", "foo", "1.0", bucket), is(false)); assertThat(entityAdapter.exists(db, null, "testapp", "1.0", bucket), is(false)); assertThat(entityAdapter.exists(db, "com.example", "bar", null, bucket), is(false)); assertThat(entityAdapter.exists(db, null, "foo", null, bucket), is(false)); } }
public boolean exists(final ODatabaseDocumentTx db, @Nullable final String group, final String name, @Nullable final String version, final Bucket bucket) { Map<String, Object> params = Maps.newHashMap(); params.put(P_GROUP, group); params.put(P_NAME, checkNotNull(name)); params.put(P_VERSION, version); params.put(P_BUCKET, recordIdentity(id(checkNotNull(bucket)))); OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<>(EXISTS_QUERY_STRING, 1); return !Iterables.isEmpty(db.command(query).<Iterable<ODocument>>execute(params)); }
ComponentEntityAdapter extends MetadataNodeEntityAdapter<Component> { public boolean exists(final ODatabaseDocumentTx db, @Nullable final String group, final String name, @Nullable final String version, final Bucket bucket) { Map<String, Object> params = Maps.newHashMap(); params.put(P_GROUP, group); params.put(P_NAME, checkNotNull(name)); params.put(P_VERSION, version); params.put(P_BUCKET, recordIdentity(id(checkNotNull(bucket)))); OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<>(EXISTS_QUERY_STRING, 1); return !Iterables.isEmpty(db.command(query).<Iterable<ODocument>>execute(params)); } }
ComponentEntityAdapter extends MetadataNodeEntityAdapter<Component> { public boolean exists(final ODatabaseDocumentTx db, @Nullable final String group, final String name, @Nullable final String version, final Bucket bucket) { Map<String, Object> params = Maps.newHashMap(); params.put(P_GROUP, group); params.put(P_NAME, checkNotNull(name)); params.put(P_VERSION, version); params.put(P_BUCKET, recordIdentity(id(checkNotNull(bucket)))); OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<>(EXISTS_QUERY_STRING, 1); return !Iterables.isEmpty(db.command(query).<Iterable<ODocument>>execute(params)); } @Inject  ComponentEntityAdapter(final BucketEntityAdapter bucketEntityAdapter,
                                final ComponentFactory componentFactory,
                                final Set<ComponentEntityAdapterExtension> componentEntityAdapterExtensions); }
ComponentEntityAdapter extends MetadataNodeEntityAdapter<Component> { public boolean exists(final ODatabaseDocumentTx db, @Nullable final String group, final String name, @Nullable final String version, final Bucket bucket) { Map<String, Object> params = Maps.newHashMap(); params.put(P_GROUP, group); params.put(P_NAME, checkNotNull(name)); params.put(P_VERSION, version); params.put(P_BUCKET, recordIdentity(id(checkNotNull(bucket)))); OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<>(EXISTS_QUERY_STRING, 1); return !Iterables.isEmpty(db.command(query).<Iterable<ODocument>>execute(params)); } @Inject  ComponentEntityAdapter(final BucketEntityAdapter bucketEntityAdapter,
                                final ComponentFactory componentFactory,
                                final Set<ComponentEntityAdapterExtension> componentEntityAdapterExtensions); Iterable<Component> browseByNameCaseInsensitive(final ODatabaseDocumentTx db,
                                                         final String name,
                                                         @Nullable final Iterable<Bucket> buckets,
                                                         @Nullable final String querySuffix); boolean exists(final ODatabaseDocumentTx db,
                        @Nullable final String group,
                        final String name,
                        @Nullable final String version,
                        final Bucket bucket); @Override boolean sendEvents(); @Override EntityEvent newEvent(final ODocument document, final EventKind eventKind); @Override String eventAffinity(final ODocument document); @Override boolean resolveConflicts(); }
ComponentEntityAdapter extends MetadataNodeEntityAdapter<Component> { public boolean exists(final ODatabaseDocumentTx db, @Nullable final String group, final String name, @Nullable final String version, final Bucket bucket) { Map<String, Object> params = Maps.newHashMap(); params.put(P_GROUP, group); params.put(P_NAME, checkNotNull(name)); params.put(P_VERSION, version); params.put(P_BUCKET, recordIdentity(id(checkNotNull(bucket)))); OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<>(EXISTS_QUERY_STRING, 1); return !Iterables.isEmpty(db.command(query).<Iterable<ODocument>>execute(params)); } @Inject  ComponentEntityAdapter(final BucketEntityAdapter bucketEntityAdapter,
                                final ComponentFactory componentFactory,
                                final Set<ComponentEntityAdapterExtension> componentEntityAdapterExtensions); Iterable<Component> browseByNameCaseInsensitive(final ODatabaseDocumentTx db,
                                                         final String name,
                                                         @Nullable final Iterable<Bucket> buckets,
                                                         @Nullable final String querySuffix); boolean exists(final ODatabaseDocumentTx db,
                        @Nullable final String group,
                        final String name,
                        @Nullable final String version,
                        final Bucket bucket); @Override boolean sendEvents(); @Override EntityEvent newEvent(final ODocument document, final EventKind eventKind); @Override String eventAffinity(final ODocument document); @Override boolean resolveConflicts(); static final String DB_CLASS; static final String P_GROUP; static final String P_VERSION; static final String P_CI_NAME; static final String I_BUCKET_GROUP_NAME_VERSION; static final String I_GROUP_NAME_VERSION_INSENSITIVE; }