use of jetbrains.exodus.entitystore.EntityIterable 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;
});
}
use of jetbrains.exodus.entitystore.EntityIterable 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;
});
}
use of jetbrains.exodus.entitystore.EntityIterable 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;
});
}
use of jetbrains.exodus.entitystore.EntityIterable in project meghanada-server by mopemope.
the class ProjectDatabaseHelper method deleteUnunsedSource.
public static boolean deleteUnunsedSource(Project p) {
ProjectDatabase database = ProjectDatabase.getInstance();
return database.execute(txn -> {
EntityIterable all = txn.getAll(Source.ENTITY_TYPE);
boolean result = false;
for (Entity entity : all) {
String path = (String) entity.getProperty("filePath");
if (!Files.exists(Paths.get(path))) {
entity.delete();
try {
FileUtils.getClassFile(path, p.getSources(), p.getOutput()).ifPresent(File::delete);
FileUtils.getClassFile(path, p.getTestSources(), p.getTestOutput()).ifPresent(File::delete);
} catch (IOException e) {
log.catching(e);
}
result = true;
}
}
return result;
});
}
use of jetbrains.exodus.entitystore.EntityIterable in project meghanada-server by mopemope.
the class ProjectDatabaseHelper method getCallerMap.
@Nonnull
@SuppressWarnings("unchecked")
public static Map<String, Set<String>> getCallerMap(String projectRoot) {
ProjectDatabase database = ProjectDatabase.getInstance();
Optional<Map<String, Set<String>>> result = database.computeInReadonly(txn -> {
EntityIterable entities = txn.find(Project.ENTITY_TYPE, ProjectDatabase.ID, projectRoot).intersect(txn.findWithBlob(Project.ENTITY_TYPE, BLOB_PROP_CALLER));
Entity entity = entities.getFirst();
if (isNull(entity)) {
return Optional.empty();
}
try (InputStream in = entity.getBlob(BLOB_PROP_CALLER)) {
return Optional.ofNullable(Serializer.readObject(in, ConcurrentHashMap.class));
} catch (Exception e) {
log.warn(e.getMessage());
return Optional.empty();
}
});
return result.orElse(new ConcurrentHashMap<>(32));
}
Aggregations