com.orientechnologies.orient.core.metadata.schema.OSchemaProxy Java Examples

The following examples show how to use com.orientechnologies.orient.core.metadata.schema.OSchemaProxy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConanUpgrade_1_1.java    From nexus-repository-conan with Eclipse Public License 1.0 6 votes vote down vote up
private void deleteDownloadUrls(final List<String> repositoryNames) {
  log.debug("Deleting DOWNLOAD_URLS assets from conan repositories ({}).", repositoryNames);

  DatabaseUpgradeSupport.withDatabaseAndClass(componentDatabaseInstance, ASSET_CLASS_NAME, (db, type) -> {
    OSchemaProxy schema = db.getMetadata().getSchema();
    if (schema.existsClass(ASSET_CLASS_NAME)) {
      repositoryNames.forEach(repositoryName -> {
        OIndex<?> bucketIdx = db.getMetadata().getIndexManager().getIndex(new OIndexNameBuilder()
            .type("bucket")
            .property(P_REPOSITORY_NAME)
            .build());
        OIdentifiable bucket = (OIdentifiable) bucketIdx.get(repositoryName);

        db.command(new OCommandSQL(DELETE_FROM_ASSET_WHERE_BUCKET_AND_ASSET_KIND))
            .execute(bucket, AssetKind.DOWNLOAD_URL.name());
      });
    }
  });
}
 
Example #2
Source File: ComponentDatabaseUpgrade_1_11.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void apply() throws Exception {
  List<String> repositoryNames;

  try (ODatabaseDocumentTx configDb = configDatabaseInstance.get().connect()) {
    repositoryNames = configDb.<List<ODocument>>query(
        new OSQLSynchQuery<ODocument>(SELECT_DOCKER_REPOSITORIES)).stream()
        .map(d -> (String) d.field(P_REPOSITORY_NAME))
        .collect(toList());
  }

  if (repositoryNames != null && !repositoryNames.isEmpty()) {
    log.info("Deleting browse_node data from docker repositories to be rebuilt ({}).", repositoryNames);

    try (ODatabaseDocumentTx componentDb = componentDatabaseInstance.get().connect()) {
      OSchemaProxy schema = componentDb.getMetadata().getSchema();
      if (schema.existsClass(C_BROWSE_NODE)) {
        componentDb.command(new OCommandSQL(DELETE_BROWSE_NODE_FROM_REPOSITORIES)).execute(repositoryNames);
      }
    }
  }
}
 
Example #3
Source File: P2Upgrade_1_1.java    From nexus-repository-p2 with Eclipse Public License 1.0 5 votes vote down vote up
private void updateP2BrowseNodes(final List<String> p2RepositoryNames) {
  log.info("Deleting browse_node data from p2 repositories to be rebuilt ({}).", p2RepositoryNames);

  DatabaseUpgradeSupport.withDatabaseAndClass(componentDatabaseInstance, C_BROWSE_NODE, (db, type) -> {
    OSchemaProxy schema = db.getMetadata().getSchema();
    if (schema.existsClass(C_BROWSE_NODE)) {
      db.command(new OCommandSQL(DELETE_BROWSE_NODE_FROM_REPOSITORIES)).execute(p2RepositoryNames);
    }
  });
}
 
Example #4
Source File: ConanUpgrade_1_1.java    From nexus-repository-conan with Eclipse Public License 1.0 5 votes vote down vote up
private void deleteConanBrowseNodes(final List<String> repositoryNames) {
  log.debug("Deleting browse_node data from conan repositories to be rebuilt ({}).", repositoryNames);

  DatabaseUpgradeSupport.withDatabaseAndClass(componentDatabaseInstance, C_BROWSE_NODE, (db, type) -> {
    OSchemaProxy schema = db.getMetadata().getSchema();
    if (schema.existsClass(C_BROWSE_NODE)) {
      db.command(new OCommandSQL(DELETE_BROWSE_NODE_FROM_REPOSITORIES)).execute(repositoryNames);
    }
  });
}
 
Example #5
Source File: OrientStatusHealthCheckStoreImplTest.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testDoStartRegistersEntity() {
  try (ODatabaseDocumentTx instance = db.getInstance().connect()) {
    OSchemaProxy schema = instance.getMetadata().getSchema();
    assertThat("database did not contain entity type after start", schema.getClass(entityAdapter.getTypeName()),
        is(notNullValue()));
  }
}