private void updateTemplateCharacteristic( DbSession dbSession, PermissionTemplateCharacteristicDto templatePermission) { PermissionTemplateCharacteristicDto targetTemplatePermission = templatePermission.setUpdatedAt(system.now()).setWithProjectCreator(false); dbClient.permissionTemplateCharacteristicDao().update(dbSession, targetTemplatePermission); dbSession.commit(); }
private void addPermissionTemplateWithProjectCreator(long templateId, String permission) { dbClient .permissionTemplateCharacteristicDao() .insert( dbSession, new PermissionTemplateCharacteristicDto() .setWithProjectCreator(true) .setTemplateId(templateId) .setPermission(permission) .setCreatedAt(1_000_000_000L) .setUpdatedAt(2_000_000_000L)); db.commit(); }
private void doHandle(RemoveProjectCreatorFromTemplateWsRequest request) { DbSession dbSession = dbClient.openSession(false); try { PermissionTemplateDto template = dependenciesFinder.getTemplate( dbSession, WsTemplateRef.newTemplateRef(request.getTemplateId(), request.getTemplateName())); PermissionTemplateCharacteristicDao dao = dbClient.permissionTemplateCharacteristicDao(); Optional<PermissionTemplateCharacteristicDto> templatePermission = dao.selectByPermissionAndTemplateId(dbSession, request.getPermission(), template.getId()); if (templatePermission.isPresent()) { updateTemplateCharacteristic(dbSession, templatePermission.get()); } } finally { dbClient.closeSession(dbSession); } }