Search in sources :

Example 16 with Entity

use of jetbrains.exodus.entitystore.Entity in project meghanada-server by mopemope.

the class ProjectDatabaseHelper method saveMemberDescriptors.

public static boolean saveMemberDescriptors(final String fqcn, final List<MemberDescriptor> members) {
    ProjectDatabase database = ProjectDatabase.getInstance();
    return database.execute(txn -> {
        EntityIterable it = txn.find(ClassIndex.ENTITY_TYPE, ProjectDatabase.ID, fqcn);
        Entity entity = it.getFirst();
        if (isNull(entity)) {
            return false;
        }
        try {
            ProjectDatabase.setSerializeBlobData(entity, BLOB_PROP_MEMBERS, members);
        } catch (IOException e) {
            log.catching(e);
            txn.abort();
            return false;
        }
        // txn.saveEntity(entity);
        return true;
    });
}
Also used : Entity(jetbrains.exodus.entitystore.Entity) EntityIterable(jetbrains.exodus.entitystore.EntityIterable) IOException(java.io.IOException)

Example 17 with Entity

use of jetbrains.exodus.entitystore.Entity in project meghanada-server by mopemope.

the class Source method deleteLinks.

private static void deleteLinks(StoreTransaction txn, Entity mainEntity) {
    Set<String> names = new HashSet<>(3);
    names.add(LINK_VARIABLE);
    names.add(LINK_FIELD_ACCESS);
    names.add(LINK_METHOD_CALL);
    for (Entity entity : mainEntity.getLinks(names)) {
        entity.delete();
    }
    for (String name : names) {
        mainEntity.deleteLinks(name);
    }
// mainEntity.deleteLinks(LINK_REV_CLASS_REFERENCES);
}
Also used : Entity(jetbrains.exodus.entitystore.Entity) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 18 with Entity

use of jetbrains.exodus.entitystore.Entity in project meghanada-server by mopemope.

the class CompileResult method store.

@Override
public void store(StoreTransaction txn, Entity entity) {
    long now = Instant.now().getEpochSecond();
    entity.setProperty("createdAt", now);
    entity.setProperty("result", this.success);
    entity.setProperty("problems", this.diagnostics.size());
    for (Diagnostic<? extends JavaFileObject> diagnostic : this.diagnostics) {
        String kind = diagnostic.getKind().toString();
        long line = diagnostic.getLineNumber();
        long column = diagnostic.getColumnNumber();
        String message = diagnostic.getMessage(null);
        if (isNull(message)) {
            message = "";
        }
        JavaFileObject fileObject = diagnostic.getSource();
        String path = null;
        if (fileObject != null) {
            final URI uri = fileObject.toUri();
            final File file = new File(uri);
            try {
                path = file.getCanonicalPath();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }
        String code = diagnostic.getCode();
        Entity subEntity = txn.newEntity(CompileResult.DIAGNOSTIC_ENTITY_TYPE);
        subEntity.setProperty("kind", kind);
        subEntity.setProperty("line", line);
        subEntity.setProperty("column", column);
        subEntity.setProperty("message", message);
        if (nonNull(path)) {
            subEntity.setProperty("path", path);
        }
        if (nonNull(code)) {
            subEntity.setProperty("code", code);
        }
        entity.addLink("diagnostic", entity);
    }
}
Also used : SimpleJavaFileObject(javax.tools.SimpleJavaFileObject) JavaFileObject(javax.tools.JavaFileObject) Entity(jetbrains.exodus.entitystore.Entity) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) URI(java.net.URI) File(java.io.File)

Example 19 with Entity

use of jetbrains.exodus.entitystore.Entity in project meghanada-server by mopemope.

the class ProjectDatabaseHelper method deleteMemberDescriptors.

public static boolean deleteMemberDescriptors(String fqcn) {
    ProjectDatabase database = ProjectDatabase.getInstance();
    return database.execute(txn -> {
        EntityIterable it = txn.find(ClassIndex.ENTITY_TYPE, ProjectDatabase.ID, fqcn);
        Entity entity = it.getFirst();
        if (isNull(entity)) {
            return false;
        }
        boolean result = entity.deleteBlob(BLOB_PROP_MEMBERS);
        // txn.saveEntity(entity);
        return result;
    });
}
Also used : Entity(jetbrains.exodus.entitystore.Entity) EntityIterable(jetbrains.exodus.entitystore.EntityIterable)

Example 20 with Entity

use of jetbrains.exodus.entitystore.Entity in project meghanada-server by mopemope.

the class ProjectDatabaseHelper method getClassIndexLinks.

public static void getClassIndexLinks(String fqcn, String linkName, Consumer<EntityIterable> fn) throws Exception {
    Map<String, ClassIndex> globalClassIndex = CachedASMReflector.getInstance().getGlobalClassIndex();
    if (!globalClassIndex.containsKey(fqcn)) {
        return;
    }
    ClassIndex index = globalClassIndex.get(fqcn);
    EntityId entityId = index.getEntityId();
    ProjectDatabase database = ProjectDatabase.getInstance();
    boolean result = database.execute(txn -> {
        Entity classEntity = txn.getEntity(entityId);
        EntityIterable iterable = classEntity.getLinks(linkName);
        fn.accept(iterable);
        return true;
    });
}
Also used : EntityId(jetbrains.exodus.entitystore.EntityId) ClassIndex(meghanada.reflect.ClassIndex) Entity(jetbrains.exodus.entitystore.Entity) EntityIterable(jetbrains.exodus.entitystore.EntityIterable)

Aggregations

Entity (jetbrains.exodus.entitystore.Entity)44 EntityIterable (jetbrains.exodus.entitystore.EntityIterable)23 IOException (java.io.IOException)13 EntityIterableBase (jetbrains.exodus.entitystore.iterate.EntityIterableBase)7 InputStream (java.io.InputStream)6 UncheckedIOException (java.io.UncheckedIOException)5 ArrayList (java.util.ArrayList)5 ComparableGetter (jetbrains.exodus.entitystore.ComparableGetter)4 EntityStoreException (jetbrains.exodus.entitystore.EntityStoreException)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 EntityId (jetbrains.exodus.entitystore.EntityId)3 File (java.io.File)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 NoSuchElementException (java.util.NoSuchElementException)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Nonnull (javax.annotation.Nonnull)2 ExodusException (jetbrains.exodus.ExodusException)2 EntityMetaData (jetbrains.exodus.query.metadata.EntityMetaData)2 Serializable (java.io.Serializable)1