本文整理了Java中org.visallo.core.model.workspace.WorkspaceRepository.findById()
方法的一些代码示例,展示了WorkspaceRepository.findById()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WorkspaceRepository.findById()
方法的具体详情如下:
包路径:org.visallo.core.model.workspace.WorkspaceRepository
类名称:WorkspaceRepository
方法名:findById
暂无
代码示例来源:origin: org.visallo/visallo-core
@Override
protected Workspace convert(String workspaceId) {
if (workspaceId == null) {
return null;
}
try {
return findById(workspaceId, user);
} catch (VisalloAccessDeniedException ex) {
return null;
}
}
};
代码示例来源:origin: org.visallo/visallo-core
public abstract Workspace findById(String workspaceId, boolean includeHidden, User user);
代码示例来源:origin: org.visallo/visallo-core
public void updateEntityOnWorkspace(
String workspaceId,
String vertexId,
User user
) {
Workspace workspace = findById(workspaceId, user);
updateEntityOnWorkspace(workspace, vertexId, user);
}
代码示例来源:origin: org.visallo/visallo-core
public void updateEntitiesOnWorkspace(
String workspaceId,
Collection<String> vertexIds,
User user
) {
Workspace workspace = workspaceRepository.findById(workspaceId, user);
workspaceRepository.updateEntitiesOnWorkspace(workspace, vertexIds, user);
workQueueRepository.pushUserCurrentWorkspaceChange(user, workspaceId);
graph.flush();
}
代码示例来源:origin: org.visallo/visallo-core-test
@Test
public void testFindByIdNotExists() {
Workspace ws = getWorkspaceRepository().findById("workspaceNotExists", false, user);
assertEquals(null, ws);
}
代码示例来源:origin: org.visallo/visallo-core-test
@Test
public void testPushWorkspaceChangeDifferentUser() {
ClientApiWorkspace clientApiWorkspace = new ClientApiWorkspace();
clientApiWorkspace.setWorkspaceId("ws1");
List<ClientApiWorkspace.User> previousUsers = new ArrayList<>();
ClientApiWorkspace.User previousUser = new ClientApiWorkspace.User();
previousUser.setUserId("mockUser1");
previousUsers.add(previousUser);
String changedByUserId = "mockUser2";
String changedBySourceGuid = "123-123-1234";
Authorizations mockUser1Auths = graph.createAuthorizations("mockUser1Auths");
when(userRepository.findById(changedByUserId)).thenReturn(mockUser2);
when(workspaceRepository.findById(eq("ws1"), eq(mockUser2))).thenReturn(workspace);
when(userRepository.findById(eq("mockUser1"))).thenReturn(mockUser1);
when(authorizationRepository.getGraphAuthorizations(eq(mockUser1), eq("ws1"))).thenReturn(mockUser1Auths);
when(workspaceRepository.toClientApi(eq(workspace), eq(mockUser1), any())).thenReturn(clientApiWorkspace);
workQueueRepository.pushWorkspaceChange(clientApiWorkspace, previousUsers, changedByUserId, changedBySourceGuid);
assertEquals(1, workQueueRepository.broadcastJsonValues.size());
JSONObject json = workQueueRepository.broadcastJsonValues.get(0);
assertEquals("workspaceChange", json.getString("type"));
assertEquals("mockUser2", json.getString("modifiedBy"));
assertEquals(new JSONObject("{\"users\":[\"mockUser1\"]}").toString(), json.getJSONObject("permissions").toString());
assertEquals(
new JSONObject("{\"editable\":false,\"users\":[],\"commentable\":false,\"workspaceId\":\"ws1\",\"sharedToUser\":false}").toString(),
json.getJSONObject("data").toString()
);
assertEquals("123-123-1234", json.getString("sourceGuid"));
}
代码示例来源:origin: org.visallo/visallo-tools-import
@Override
protected int run() throws Exception {
Workspace workspace;
if (workspaceId == null) {
workspace = null;
} else {
workspace = workspaceRepository.findById(workspaceId, getUser());
}
fileImport.importDirectory(dataDir, queueDuplicates, conceptTypeIRI, visibilitySource, workspace, priority, getUser(), getAuthorizations());
return 0;
}
代码示例来源:origin: org.visallo/visallo-web
@Handle
public ClientApiWorkspaceDiff handle(
@ActiveWorkspaceId String workspaceId,
FormulaEvaluator.UserContext userContext,
User user
) throws Exception {
Workspace workspace = workspaceRepository.findById(workspaceId, true, user);
if (workspace == null) {
throw new VisalloResourceNotFoundException("Cannot find workspace: " + workspaceId);
}
return this.workspaceRepository.getDiff(workspace, user, userContext);
}
}
代码示例来源:origin: org.visallo/visallo-web
private void switchWorkspace(String authUserId, String workspaceId) {
if (!workspaceId.equals(userRepository.getCurrentWorkspaceId(authUserId))) {
User authUser = userRepository.findById(authUserId);
Workspace workspace = workspaceRepository.findById(workspaceId, authUser);
userRepository.setCurrentWorkspace(authUserId, workspace.getWorkspaceId());
workQueueRepository.pushUserCurrentWorkspaceChange(authUser, workspace.getWorkspaceId());
LOGGER.debug("User %s switched current workspace to %s", authUserId, workspaceId);
}
}
代码示例来源:origin: org.visallo/visallo-core
protected void broadcastWorkspace(
ClientApiWorkspace workspace,
List<ClientApiWorkspace.User> previousUsers,
String changedByUserId,
String changedBySourceGuid
) {
User changedByUser = getUserRepository().findById(changedByUserId);
Workspace ws = getWorkspaceRepository().findById(workspace.getWorkspaceId(), changedByUser);
previousUsers.forEach(workspaceUser -> {
boolean isChangingUser = workspaceUser.getUserId().equals(changedByUserId);
User user = isChangingUser ? changedByUser : getUserRepository().findById(workspaceUser.getUserId());
Authorizations authorizations = getAuthorizationRepository().getGraphAuthorizations(user, workspace.getWorkspaceId());
// No need to regenerate client api if changing user
try {
ClientApiWorkspace userWorkspace = isChangingUser ? workspace : getWorkspaceRepository().toClientApi(ws, user, authorizations);
JSONObject json = new JSONObject();
json.put("type", "workspaceChange");
json.put("modifiedBy", changedByUserId);
json.put("permissions", getPermissionsWithUsers(null, Arrays.asList(workspaceUser)));
json.put("data", new JSONObject(ClientApiConverter.clientApiToString(userWorkspace)));
json.putOpt("sourceGuid", changedBySourceGuid);
broadcastJson(json);
} catch (VisalloAccessDeniedException e) {
/* Ignore push message if lost access */
}
});
}
代码示例来源:origin: org.visallo/visallo-web
@Handle
public ClientApiSuccess handle(
@Required(name = "workspaceId") String workspaceId,
User user,
Authorizations authorizations
) throws Exception {
LOGGER.info("Deleting workspace with id: %s", workspaceId);
Workspace workspace = workspaceRepository.findById(workspaceId, user);
if (workspace == null) {
throw new VisalloResourceNotFoundException("Could not find workspace: " + workspaceId);
}
ClientApiWorkspace clientApiWorkspaceBeforeDeletion = workspaceRepository.toClientApi(workspace, user, authorizations);
workspaceRepository.delete(workspace, user);
workQueueRepository.pushWorkspaceDelete(clientApiWorkspaceBeforeDeletion);
return VisalloResponse.SUCCESS;
}
}
代码示例来源:origin: org.visallo/visallo-web
Workspace workspace = workspaceRepository.findById(workspaceId, user);
代码示例来源:origin: org.visallo/visallo-web
@Handle
public ClientApiWorkspace handle(
@Required(name = "workspaceId") String workspaceId,
User user,
Authorizations authorizations
) throws Exception {
LOGGER.info("Attempting to retrieve workspace: %s", workspaceId);
try {
final Workspace workspace = workspaceRepository.findById(workspaceId, user);
if (workspace == null) {
throw new VisalloResourceNotFoundException("Could not find workspace: " + workspaceId);
} else {
LOGGER.debug("Successfully found workspace");
return workspaceRepository.toClientApi(workspace, user, authorizations);
}
} catch (SecurityVertexiumException ex) {
throw new VisalloAccessDeniedException("Could not get workspace " + workspaceId, user, workspaceId);
}
}
}
代码示例来源:origin: org.visallo/visallo-web-product-graph
Workspace workspace = workspaceRepository.findById(workspaceId, user);
ClientApiWorkspace clientApiWorkspace = workspaceRepository.toClientApi(workspace, user, authorizations);
代码示例来源:origin: org.visallo/visallo-web-plugins-admin-user-tools
@Handle
public ClientApiSuccess handle(
@Required(name = "workspaceId") String workspaceId,
@Required(name = "user-name") String userName,
User me
) throws Exception {
User user = userRepository.findByUsername(userName);
if (user == null) {
throw new VisalloResourceNotFoundException("Could not find user: " + userName);
}
Workspace workspace = workspaceRepository.findById(workspaceId, user);
if (workspace == null) {
throw new VisalloResourceNotFoundException("Could not find workspace: " + workspaceId);
}
workspaceRepository.updateUserOnWorkspace(workspace, me.getUserId(), WorkspaceAccess.WRITE, user);
return VisalloResponse.SUCCESS;
}
}
代码示例来源:origin: org.visallo/visallo-web
@Handle
public ClientApiWorkspace handle(
@Required(name = "data") ClientApiWorkspaceUpdateData updateData,
@ActiveWorkspaceId String workspaceId,
@SourceGuid String sourceGuid,
ResourceBundle resourceBundle,
User user,
Authorizations authorizations
) throws Exception {
Workspace workspace = workspaceRepository.findById(workspaceId, user);
if (workspace == null) {
throw new VisalloResourceNotFoundException("Could not find workspace: " + workspaceId);
}
if (updateData.getTitle() != null) {
setTitle(workspace, updateData.getTitle(), user);
}
updateUsers(workspace, updateData.getUserUpdates(), resourceBundle, user);
workspace = workspaceRepository.findById(workspaceId, user);
ClientApiWorkspace clientApiWorkspaceAfterUpdateButBeforeDelete = workspaceRepository.toClientApi(
workspace,
user,
authorizations
);
List<ClientApiWorkspace.User> previousUsers = clientApiWorkspaceAfterUpdateButBeforeDelete.getUsers();
deleteUsers(workspace, updateData.getUserDeletes(), user);
ClientApiWorkspace clientApiWorkspace = workspaceRepository.toClientApi(workspace, user, authorizations);
workQueueRepository.pushWorkspaceChange(clientApiWorkspace, previousUsers, user.getUserId(), sourceGuid);
return workspaceRepository.toClientApi(workspace, user, authorizations);
}
代码示例来源:origin: org.visallo/visallo-web
Workspace workspace = this.workspaceRepository.findById(workspaceId, user);
代码示例来源:origin: org.visallo/visallo-web-product-graph
graph.flush();
Workspace workspace = workspaceRepository.findById(workspaceId, user);
ClientApiWorkspace clientApiWorkspace = workspaceRepository.toClientApi(workspace, user, authorizations);
代码示例来源:origin: org.visallo/visallo-web-product-graph
Workspace workspace = workspaceRepository.findById(workspaceId, user);
ClientApiWorkspace clientApiWorkspace = workspaceRepository.toClientApi(workspace, user, authorizations);
代码示例来源:origin: org.visallo/visallo-web-product-graph
Workspace workspace = workspaceRepository.findById(workspaceId, user);
ClientApiWorkspace clientApiWorkspace = workspaceRepository.toClientApi(workspace, user, authorizations);
内容来源于网络,如有侵权,请联系作者删除!