@@ -133,14 +133,17 @@ public class LabsStudyView extends VerticalLayout {

private static final Logger LOG = LoggerFactory.getLogger(ContainerView.class);

public LabsStudyView(final EscidocServiceLocation serviceLocation, final MainSite mainSite, final ResourceProxy resourceProxy, final Window mainWindow,
final CurrentUser currentUser, final Repositories repositories) throws EscidocClientException {
public LabsStudyView(final EscidocServiceLocation serviceLocation, final MainSite mainSite,
final ResourceProxy resourceProxy, final Window mainWindow, final CurrentUser currentUser,
final Repositories repositories) throws EscidocClientException {
Preconditions.checkNotNull(serviceLocation, "serviceLocation is null: %s", serviceLocation);
Preconditions.checkNotNull(mainSite, "mainSite is null: %s", mainSite);
Preconditions.checkNotNull(resourceProxy, "resourceProxy is null: %s", resourceProxy);
Preconditions.checkArgument(resourceProxy instanceof ContainerProxy, resourceProxy.getClass() + " is not an instance of ContainerProxy.class");
Preconditions.checkArgument(resourceProxy instanceof ContainerProxy, resourceProxy.getClass()
+ " is not an instance of ContainerProxy.class");
Preconditions.checkNotNull(resourceProxy, "resourceProxy is null: %s", resourceProxy);
Preconditions.checkArgument(resourceProxy instanceof ContainerProxy, resourceProxy.getClass() + " is not an instance of ContainerProxy.class");
Preconditions.checkArgument(resourceProxy instanceof ContainerProxy, resourceProxy.getClass()
+ " is not an instance of ContainerProxy.class");
this.serviceLocation = serviceLocation;
this.mainSite = mainSite;
appHeight = mainSite.getApplicationHeight();
@@ -165,17 +168,19 @@ private void init() throws EscidocClientException {
}

private void addMetadataRecords() {
rightCell(new MetadataRecs(resourceProxy, accordionHeight, mainWindow, serviceLocation, repositories, currentUser, mainSite).asAccord());
rightCell(new MetadataRecs(resourceProxy, accordionHeight, mainWindow, serviceLocation, repositories,
currentUser, mainSite).asAccord());
}

private void addDirectMembers() throws EscidocClientException {
final DirectMember directMembers = new DirectMember(serviceLocation, mainSite, resourceProxy.getId(), mainWindow, currentUser, repositories);
final DirectMember directMembers =
new DirectMember(serviceLocation, mainSite, resourceProxy.getId(), mainWindow, currentUser, repositories);
leftCell(DIRECT_MEMBERS, directMembers.containerAsTree());
}

/**
* This is the inner Right Cell within a Context By default a set of Organizational Unit / Admin Description / RelatedItem / Resources
* are bound
* This is the inner Right Cell within a Context By default a set of Organizational Unit / Admin Description /
* RelatedItem / Resources are bound
*
* @param comptoBind
*/
@@ -228,8 +233,9 @@ private void bindProperties() {
lblLockstatus.setStyleName("inset");
}
final Label descMetadata2 =
new Label(CREATED_BY + " " + resourceProxy.getCreator() + " on " + resourceProxy.getCreatedOn() + "<br/>" + LAST_MODIFIED_BY + " "
+ resourceProxy.getModifier() + " on " + resourceProxy.getModifiedOn() + "<br />" + "Released by " + resourceProxy.getReleasedBy() + " on "
new Label(CREATED_BY + " " + resourceProxy.getCreator() + " on " + resourceProxy.getCreatedOn() + "<br/>"
+ LAST_MODIFIED_BY + " " + resourceProxy.getModifier() + " on " + resourceProxy.getModifiedOn()
+ "<br />" + "Released by " + resourceProxy.getReleasedBy() + " on "
+ resourceProxy.getLatestVersionModifiedOn(), Label.CONTENT_XHTML);

vlPropertiesLeft.addComponent(descMetadata1);
@@ -330,7 +336,8 @@ public void layoutClick(final LayoutClickEvent event) {
// Is Label?
if (event.getChildComponent().getClass().getCanonicalName() == "com.vaadin.ui.Label") {
final Label child = (Label) event.getChildComponent();
if ((child.getDescription() == DESC_STATUS2) && (!lblStatus.getValue().equals(status + "withdrawn"))) {
if ((child.getDescription() == DESC_STATUS2)
&& (!lblStatus.getValue().equals(status + "withdrawn"))) {
reSwapComponents();
oldComponent = event.getClickedComponent();
swapComponent = editStatus(child.getValue().toString().replace(status, ""));
@@ -436,7 +443,8 @@ else if (publicStatus.equals("withdrawn")) {

private boolean hasAccessDelResource() {
try {
return repositories.pdp().forUser(currentUser.getUserId()).isAction(ActionIdConstants.DELETE_CONTAINER)
return repositories
.pdp().forUser(currentUser.getUserId()).isAction(ActionIdConstants.DELETE_CONTAINER)
.forResource(resourceProxy.getId()).permitted();
}
catch (UnsupportedOperationException e) {
@@ -497,17 +505,19 @@ public void buttonClick(ClickEvent event) {

private void updatePublicStatus(Container container, String comment) {
// Update PublicStatus if there is a change
if (!resourceProxy.getVersionStatus().equals(lblCurrentVersionStatus.getValue().toString().replace(status, ""))) {
repositories.container().changePublicStatus(container, lblCurrentVersionStatus.getValue().toString().replace(status, "").toUpperCase(),
comment);
if (!resourceProxy.getVersionStatus().equals(
lblCurrentVersionStatus.getValue().toString().replace(status, ""))) {
repositories.container().changePublicStatus(container,
lblCurrentVersionStatus.getValue().toString().replace(status, "").toUpperCase(), comment);
}
}

private void updateLockStatus(Container container, String comment) {
// Update LockStatus if there is a change
if (!resourceProxy.getLockStatus().equals(lblLockstatus.getValue().toString().replace(lockStatus, ""))) {
repositories.container()
.changeLockStatus(container, lblLockstatus.getValue().toString().replace(lockStatus, "").toUpperCase(), comment);
if (!resourceProxy.getLockStatus().equals(
lblLockstatus.getValue().toString().replace(lockStatus, ""))) {
repositories.container().changeLockStatus(container,
lblLockstatus.getValue().toString().replace(lockStatus, "").toUpperCase(), comment);
}
}

@@ -538,15 +548,16 @@ private void updateContainer(String comment) {
}

/**
* Checks if a resource has previous history and returns a string TODO in the future it should be a Link (Button Link) that holds a
* reference to the history of the resource
* Checks if a resource has previous history and returns a string TODO in the future it should be a Link (Button
* Link) that holds a reference to the history of the resource
*
* @return String
*/
private Component getHistory() {
if (resourceProxy.getPreviousVersion()) {
final Button versionHistory =
new Button(" Has previous version", new VersionHistoryClickListener(resourceProxy, mainWindow, serviceLocation, repositories));
new Button(" Has previous version", new VersionHistoryClickListener(resourceProxy, mainWindow,
serviceLocation, repositories));
versionHistory.setStyleName(BaseTheme.BUTTON_LINK);

return versionHistory;
@@ -559,8 +570,9 @@ private Component getHistory() {

private boolean hasAccess() {
try {
return repositories.pdp().forUser(currentUser.getUserId()).isAction(ActionIdConstants.UPDATE_CONTAINER).forResource(resourceProxy.getId())
.permitted();
return repositories
.pdp().forUser(currentUser.getUserId()).isAction(ActionIdConstants.UPDATE_CONTAINER)
.forResource(resourceProxy.getId()).permitted();
}
catch (EscidocClientException e) {
mainWindow.showNotification(e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE);
@@ -110,22 +110,27 @@ private void buildPanelGUI() {
LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndLabelData(ELabViewContants.L_INSTRUMENT_DESC,
getPojoItem().getItemProperty(ELabViewContants.P_INSTRUMENT_DESC));
HorizontalLayout h3 =
LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndCheckBoxData(ELabViewContants.L_INSTRUMENT_CONFIGURATION_KEY,
ELabViewContants.L_INSTRUMENT_CONFIGURATION_VALUE, getPojoItem().getItemProperty(ELabViewContants.P_INSTRUMENT_CONFIGURATION));
LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndCheckBoxData(
ELabViewContants.L_INSTRUMENT_CONFIGURATION_KEY, ELabViewContants.L_INSTRUMENT_CONFIGURATION_VALUE,
getPojoItem().getItemProperty(ELabViewContants.P_INSTRUMENT_CONFIGURATION));
HorizontalLayout h4 =
LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndCheckBoxData(ELabViewContants.L_INSTRUMENT_CALIBRATION_KEY,
ELabViewContants.L_INSTRUMENT_CALIBRATION_VALUE, getPojoItem().getItemProperty(ELabViewContants.P_INSTRUMENT_CALIBRATION));
LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndCheckBoxData(
ELabViewContants.L_INSTRUMENT_CALIBRATION_KEY, ELabViewContants.L_INSTRUMENT_CALIBRATION_VALUE,
getPojoItem().getItemProperty(ELabViewContants.P_INSTRUMENT_CALIBRATION));
HorizontalLayout h5 =
LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndLabelData(ELabViewContants.L_INSTRUMENT_ESYNC_DAEMON,
LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndLabelData(
ELabViewContants.L_INSTRUMENT_ESYNC_DAEMON,
getPojoItem().getItemProperty(ELabViewContants.P_INSTRUMENT_ESYNCDAEMON));
HorizontalLayout h6 =
LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndLabelData(ELabViewContants.L_INSTRUMENT_FOLDER,
getPojoItem().getItemProperty(ELabViewContants.P_INSTRUMENT_FOLDER));
HorizontalLayout h7 =
LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndLabelData(ELabViewContants.L_INSTRUMENT_FILE_FORMAT,
LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndLabelData(
ELabViewContants.L_INSTRUMENT_FILE_FORMAT,
getPojoItem().getItemProperty(ELabViewContants.P_INSTRUMENT_FILEFORMAT));
HorizontalLayout h8 =
LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndLabelData(ELabViewContants.L_INSTRUMENT_DEVICE_SUPERVISOR,
LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndLabelData(
ELabViewContants.L_INSTRUMENT_DEVICE_SUPERVISOR,
getPojoItem().getItemProperty(ELabViewContants.P_INSTRUMENT_DEVICESUPERVISOR));
HorizontalLayout h9 =
LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndLabelData(ELabViewContants.L_INSTRUMENT_INSTITUTE,
@@ -142,7 +142,7 @@ public class ViewConstants {
public static final String METADATA = "Metadata";

public static final String UPLOAD_A_WELLFORMED_XML_FILE_TO_REPLACE_METADATA =
"Upload a wellformed XML file to replace metadata!";
"Upload a wellformed XML file to replace metadata!";

public static final String ORGANIZATIONAL_UNIT = "Organizational Unit";

@@ -124,8 +124,7 @@ private void buildContainerForm() throws EscidocClientException {
private void addNameField() {
nameField.setRequired(true);
nameField.setRequiredError(ViewConstants.PLEASE_ENTER_A_CONTAINER_NAME);
nameField.addValidator(new StringLengthValidator(ViewConstants.CONTAINER_LENGTH, 3, 50,
false));
nameField.addValidator(new StringLengthValidator(ViewConstants.CONTAINER_LENGTH, 3, 50, false));
nameField.setImmediate(true);
addContainerForm.addComponent(nameField);
}
@@ -129,8 +129,9 @@ public class ContainerView extends VerticalLayout {

private static final Logger LOG = LoggerFactory.getLogger(ContainerView.class);

public ContainerView(final EscidocServiceLocation serviceLocation, final MainSite mainSite, final ResourceProxy resourceProxy,
final Window mainWindow, final CurrentUser currentUser, final Repositories repositories) throws EscidocClientException {
public ContainerView(final EscidocServiceLocation serviceLocation, final MainSite mainSite,
final ResourceProxy resourceProxy, final Window mainWindow, final CurrentUser currentUser,
final Repositories repositories) throws EscidocClientException {
Preconditions.checkNotNull(serviceLocation, "serviceLocation is null: %s", serviceLocation);
Preconditions.checkNotNull(mainSite, "mainSite is null: %s", mainSite);
Preconditions.checkNotNull(resourceProxy, "resourceProxy is null: %s", resourceProxy);
@@ -163,8 +164,8 @@ private void init() throws EscidocClientException {
}

private void addMetadataRecords() {
rightCell(new MetadataRecs(resourceProxy, accordionHeight, mainWindow, serviceLocation, repositories, currentUser, mainSite)
.asAccord());
rightCell(new MetadataRecs(resourceProxy, accordionHeight, mainWindow, serviceLocation, repositories,
currentUser, mainSite).asAccord());
}

private void addDirectMembers() throws EscidocClientException {
@@ -174,8 +175,8 @@ private void addDirectMembers() throws EscidocClientException {
}

/**
* This is the inner Right Cell within a Context By default a set of Organizational Unit / Admin Description / RelatedItem / Resources
* are bound
* This is the inner Right Cell within a Context By default a set of Organizational Unit / Admin Description /
* RelatedItem / Resources are bound
*
* @param comptoBind
*/
@@ -228,9 +229,10 @@ private void bindProperties() {
lblLockstatus.setStyleName("inset");
}
final Label descMetadata2 =
new Label(CREATED_BY + " " + resourceProxy.getCreator() + " on " + resourceProxy.getCreatedOn() + "<br/>" + LAST_MODIFIED_BY
+ " " + resourceProxy.getModifier() + " on " + resourceProxy.getModifiedOn() + "<br />" + "Released by "
+ resourceProxy.getReleasedBy() + " on " + resourceProxy.getLatestVersionModifiedOn(), Label.CONTENT_XHTML);
new Label(CREATED_BY + " " + resourceProxy.getCreator() + " on " + resourceProxy.getCreatedOn() + "<br/>"
+ LAST_MODIFIED_BY + " " + resourceProxy.getModifier() + " on " + resourceProxy.getModifiedOn()
+ "<br />" + "Released by " + resourceProxy.getReleasedBy() + " on "
+ resourceProxy.getLatestVersionModifiedOn(), Label.CONTENT_XHTML);

vlPropertiesLeft.addComponent(descMetadata1);
if (hasAccess()) {
@@ -330,7 +332,8 @@ public void layoutClick(final LayoutClickEvent event) {
// Is Label?
if (event.getChildComponent().getClass().getCanonicalName() == "com.vaadin.ui.Label") {
final Label child = (Label) event.getChildComponent();
if ((child.getDescription() == DESC_STATUS2) && (!lblStatus.getValue().equals(status + "withdrawn"))) {
if ((child.getDescription() == DESC_STATUS2)
&& (!lblStatus.getValue().equals(status + "withdrawn"))) {
reSwapComponents();
oldComponent = event.getClickedComponent();
swapComponent = editStatus(child.getValue().toString().replace(status, ""));
@@ -436,7 +439,8 @@ else if (publicStatus.equals("withdrawn")) {

private boolean hasAccessDelResource() {
try {
return repositories.pdp().forUser(currentUser.getUserId()).isAction(ActionIdConstants.DELETE_CONTAINER)
return repositories
.pdp().forUser(currentUser.getUserId()).isAction(ActionIdConstants.DELETE_CONTAINER)
.forResource(resourceProxy.getId()).permitted();
}
catch (UnsupportedOperationException e) {
@@ -497,15 +501,17 @@ public void buttonClick(ClickEvent event) {

private void updatePublicStatus(Container container, String comment) {
// Update PublicStatus if there is a change
if (!resourceProxy.getVersionStatus().equals(lblCurrentVersionStatus.getValue().toString().replace(status, ""))) {
if (!resourceProxy.getVersionStatus().equals(
lblCurrentVersionStatus.getValue().toString().replace(status, ""))) {
repositories.container().changePublicStatus(container,
lblCurrentVersionStatus.getValue().toString().replace(status, "").toUpperCase(), comment);
}
}

private void updateLockStatus(Container container, String comment) {
// Update LockStatus if there is a change
if (!resourceProxy.getLockStatus().equals(lblLockstatus.getValue().toString().replace(lockStatus, ""))) {
if (!resourceProxy.getLockStatus().equals(
lblLockstatus.getValue().toString().replace(lockStatus, ""))) {
repositories.container().changeLockStatus(container,
lblLockstatus.getValue().toString().replace(lockStatus, "").toUpperCase(), comment);
}
@@ -538,16 +544,16 @@ private void updateContainer(String comment) {
}

/**
* Checks if a resource has previous history and returns a string TODO in the future it should be a Link (Button Link) that holds a
* reference to the history of the resource
* Checks if a resource has previous history and returns a string TODO in the future it should be a Link (Button
* Link) that holds a reference to the history of the resource
*
* @return String
*/
private Component getHistory() {
if (resourceProxy.getPreviousVersion()) {
final Button versionHistory =
new Button(" Has previous version", new VersionHistoryClickListener(resourceProxy, mainWindow, serviceLocation,
repositories));
new Button(" Has previous version", new VersionHistoryClickListener(resourceProxy, mainWindow,
serviceLocation, repositories));
versionHistory.setStyleName(BaseTheme.BUTTON_LINK);

return versionHistory;
@@ -560,7 +566,8 @@ private Component getHistory() {

private boolean hasAccess() {
try {
return repositories.pdp().forUser(currentUser.getUserId()).isAction(ActionIdConstants.UPDATE_CONTAINER)
return repositories
.pdp().forUser(currentUser.getUserId()).isAction(ActionIdConstants.UPDATE_CONTAINER)
.forResource(resourceProxy.getId()).permitted();
}
catch (EscidocClientException e) {
@@ -80,8 +80,9 @@ public class ContextView extends VerticalLayout {

private static final Logger LOG = LoggerFactory.getLogger(ContextView.class);

public ContextView(final EscidocServiceLocation serviceLocation, final MainSite mainSite, final ResourceProxy resourceProxy,
final Window mainWindow, final CurrentUser currentUser, final Repositories repositories) throws EscidocClientException {
public ContextView(final EscidocServiceLocation serviceLocation, final MainSite mainSite,
final ResourceProxy resourceProxy, final Window mainWindow, final CurrentUser currentUser,
final Repositories repositories) throws EscidocClientException {

Preconditions.checkNotNull(serviceLocation, "serviceLocation is null: %s", serviceLocation);
Preconditions.checkNotNull(mainSite, "mainSite is null: %s", mainSite);
@@ -116,13 +117,13 @@ private void addContextDetailsView() {
}

private void addDirectMembersView() throws EscidocClientException {
leftCell(DIRECT_MEMBERS,
new DirectMember(serviceLocation, mainSite, resourceProxy.getId(), mainWindow, currentUser, repositories).contextAsTree());
leftCell(DIRECT_MEMBERS, new DirectMember(serviceLocation, mainSite, resourceProxy.getId(), mainWindow,
currentUser, repositories).contextAsTree());
}

/**
* This is the inner Right Cell within a Context By default a set of Organizational Unit / Admin Description / RelatedItem / Resources
* are bound
* This is the inner Right Cell within a Context By default a set of Organizational Unit / Admin Description /
* RelatedItem / Resources are bound
*
* @param comptoBind
*/
@@ -166,16 +167,17 @@ private void leftCell(final String directMembers, final Component comptoBind) {
*/
private void bindProperties() {
final Label descMetadata1 =
new Label("ID: " + resourceProxy.getId() + " <br /> " + resourceProxy.getType().asLabel() + " is " + resourceProxy.getStatus(),
Label.CONTENT_RAW);
new Label("ID: " + resourceProxy.getId() + " <br /> " + resourceProxy.getType().asLabel() + " is "
+ resourceProxy.getStatus(), Label.CONTENT_RAW);
descMetadata1.setWidth("35%");
descMetadata1.setStyleName("floatleft columnheight50");
cssLayout.addComponent(descMetadata1);

// RIGHT SIDE
final Label descMetadata2 =
new Label(CREATED_BY + " " + resourceProxy.getCreator() + " on " + resourceProxy.getCreatedOn() + "<br/>" + LAST_MODIFIED_BY
+ " " + resourceProxy.getModifier() + " on " + resourceProxy.getModifiedOn(), Label.CONTENT_XHTML);
new Label(CREATED_BY + " " + resourceProxy.getCreator() + " on " + resourceProxy.getCreatedOn() + "<br/>"
+ LAST_MODIFIED_BY + " " + resourceProxy.getModifier() + " on " + resourceProxy.getModifiedOn(),
Label.CONTENT_XHTML);

descMetadata2.setStyleName("floatright columnheight50");
descMetadata2.setWidth("65%");
@@ -66,7 +66,8 @@ final class ActionHandlerImpl implements Action.Handler {

private final TreeDataSource treeDataSource;

public ActionHandlerImpl(final Window mainWindow, final Repositories repositories, final CurrentUser currentUser, final TreeDataSource treeDataSource) {
public ActionHandlerImpl(final Window mainWindow, final Repositories repositories, final CurrentUser currentUser,
final TreeDataSource treeDataSource) {

Preconditions.checkNotNull(mainWindow, "mainWindow is null: %s", mainWindow);
Preconditions.checkNotNull(repositories, "repositories is null: %s", repositories);
@@ -89,14 +90,17 @@ public Action[] getActions(final Object target, final Object sender) {
Preconditions.checkNotNull(contentModelId, "Content Model ID is null");

if (isContext(target) && contentModelId.equals(AppConstants.EMPTY_STRING)) {
return new Action[] { ActionList.ACTION_ADD_STUDY, ActionList.ACTION_ADD_RIG, ActionList.ACTION_ADD_INSTRUMENT };
return new Action[] { ActionList.ACTION_ADD_STUDY, ActionList.ACTION_ADD_RIG,
ActionList.ACTION_ADD_INSTRUMENT };
}
else if (isContainer(target)) {
if (contentModelId.equals(ELabsConstants.ELABS_DEFAULT_STUDY_CMODEL_ID)) {
return new Action[] { ActionList.ACTION_ADD_INVESTIGATION, ActionList.ACTION_MODIFY_STUDY, ActionList.ACTION_DELETE_STUDY };
return new Action[] { ActionList.ACTION_ADD_INVESTIGATION, ActionList.ACTION_MODIFY_STUDY,
ActionList.ACTION_DELETE_STUDY };
}
else if (contentModelId.equals(ELabsConstants.ELABS_DEFAULT_INVESTIGATION_CMODEL_ID)) {
return new Action[] { ActionList.ACTION_MODIFY_INVESTIGATION, ActionList.ACTION_DELETE_INVESTIGATION };
return new Action[] { ActionList.ACTION_MODIFY_INVESTIGATION,
ActionList.ACTION_DELETE_INVESTIGATION };
}
else {
LOG.error("Unsupported BW eLabs ContentModel in the context menu of the object tree!");
@@ -130,7 +134,8 @@ else if (contentModelId.equals(ELabsConstants.ELABS_DEFAULT_GENERATED_ITEM_CMODE
}

if (isContainer(target)) {
return new Action[] { ActionList.ACTION_ADD_CONTAINER, ActionList.ACTION_ADD_ITEM, ActionList.ACTION_DELETE_CONTAINER };
return new Action[] { ActionList.ACTION_ADD_CONTAINER, ActionList.ACTION_ADD_ITEM,
ActionList.ACTION_DELETE_CONTAINER };
}

if (isItem(target)) {
@@ -143,7 +148,9 @@ else if (contentModelId.equals(ELabsConstants.ELABS_DEFAULT_GENERATED_ITEM_CMODE
}

private boolean allowedToDeleteItem(final String resourceId) throws EscidocClientException, URISyntaxException {
return repositories.pdp().forUser(currentUser.getUserId()).isAction(ActionIdConstants.DELETE_ITEM).forResource(resourceId).permitted();
return repositories
.pdp().forUser(currentUser.getUserId()).isAction(ActionIdConstants.DELETE_ITEM).forResource(resourceId)
.permitted();
}

private static boolean isContext(final Object target) {
@@ -170,16 +177,18 @@ public void handleAction(final Action action, final Object sender, final Object
}
catch (final EscidocClientException e) {
LOG.error(e.getMessage(), e);
mainWindow.showNotification(new Window.Notification("Application Error", e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE));
mainWindow.showNotification(new Window.Notification("Application Error", e.getMessage(),
Window.Notification.TYPE_ERROR_MESSAGE));
}
catch (final URISyntaxException e) {
LOG.error(e.getMessage(), e);
mainWindow.showNotification(new Window.Notification("Application Error", e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE));
mainWindow.showNotification(new Window.Notification("Application Error", e.getMessage(),
Window.Notification.TYPE_ERROR_MESSAGE));
}
}

private void doActionIfAllowed(final Action action, final Object selectedResource, final String contextId) throws EscidocClientException,
URISyntaxException {
private void doActionIfAllowed(final Action action, final Object selectedResource, final String contextId)
throws EscidocClientException, URISyntaxException {

// original doActions
if (action.equals(ActionList.ACTION_ADD_CONTAINER)) {
@@ -220,7 +229,8 @@ else if (action.equals(ActionList.ACTION_MODIFY_INSTRUMENT)) {
else if (action.equals(ActionList.ACTION_DELETE_INSTRUMENT)) {
}
else {
mainWindow.showNotification("Unknown Action: " + action.getCaption(), Window.Notification.TYPE_ERROR_MESSAGE);
mainWindow.showNotification("Unknown Action: " + action.getCaption(),
Window.Notification.TYPE_ERROR_MESSAGE);
}
}

@@ -230,8 +240,8 @@ private void tryDeleteItem(final Object target) throws EscidocClientException, U
deleteItem((ItemModel) target);
}
else {
mainWindow.showNotification(new Window.Notification(ViewConstants.NOT_AUTHORIZED, "You do not have the right to delete the item: " + itemId,
Window.Notification.TYPE_WARNING_MESSAGE));
mainWindow.showNotification(new Window.Notification(ViewConstants.NOT_AUTHORIZED,
"You do not have the right to delete the item: " + itemId, Window.Notification.TYPE_WARNING_MESSAGE));
}
}

@@ -242,11 +252,13 @@ private void tryDeleteContainer(final Object target) throws EscidocClientExcepti
}
else {
mainWindow.showNotification(new Window.Notification(ViewConstants.NOT_AUTHORIZED,
"You do not have the right to delete a container: " + containerId, Window.Notification.TYPE_WARNING_MESSAGE));
"You do not have the right to delete a container: " + containerId,
Window.Notification.TYPE_WARNING_MESSAGE));
}
}

private void tryShowCreateItemView(final Object target, final String contextId) throws EscidocClientException, URISyntaxException {
private void tryShowCreateItemView(final Object target, final String contextId) throws EscidocClientException,
URISyntaxException {
if (allowedToCreateItem(contextId)) {
if (target instanceof ContextModel) {
showCreateItemView(target, contextId);
@@ -255,17 +267,20 @@ else if (target instanceof ContainerModel && allowedToAddMember((ResourceModel)
showCreateItemView(target, contextId);
}
else {
mainWindow.showNotification(new Window.Notification(ViewConstants.NOT_AUTHORIZED, "You do not have the right to add an item to "
+ ((ResourceModel) target).getName(), Window.Notification.TYPE_WARNING_MESSAGE));
mainWindow.showNotification(new Window.Notification(ViewConstants.NOT_AUTHORIZED,
"You do not have the right to add an item to " + ((ResourceModel) target).getName(),
Window.Notification.TYPE_WARNING_MESSAGE));
}
}
else {
mainWindow.showNotification(new Window.Notification(ViewConstants.NOT_AUTHORIZED, "You do not have the right to create an item in context: "
+ contextId, Window.Notification.TYPE_WARNING_MESSAGE));
mainWindow.showNotification(new Window.Notification(ViewConstants.NOT_AUTHORIZED,
"You do not have the right to create an item in context: " + contextId,
Window.Notification.TYPE_WARNING_MESSAGE));
}
}

private void tryShowCreateContainerView(final Object target, final String contextId) throws EscidocClientException, URISyntaxException {
private void tryShowCreateContainerView(final Object target, final String contextId) throws EscidocClientException,
URISyntaxException {
if (allowedToCreateContainer(contextId)) {
if (target instanceof ContextModel) {
showCreateContainerView(target, contextId);
@@ -274,31 +289,40 @@ else if ((target instanceof ContainerModel) && allowedToAddMember((ResourceModel
showCreateContainerView(target, contextId);
}
else {
mainWindow.showNotification(new Window.Notification(ViewConstants.NOT_AUTHORIZED, "You do not have the right to add a container to "
+ ((ResourceModel) target).getName(), Window.Notification.TYPE_WARNING_MESSAGE));
mainWindow.showNotification(new Window.Notification(ViewConstants.NOT_AUTHORIZED,
"You do not have the right to add a container to " + ((ResourceModel) target).getName(),
Window.Notification.TYPE_WARNING_MESSAGE));
}
}
else {
mainWindow.showNotification(new Window.Notification(ViewConstants.NOT_AUTHORIZED, "You do not have the right to create a container in context: "
+ contextId, Window.Notification.TYPE_WARNING_MESSAGE));
mainWindow.showNotification(new Window.Notification(ViewConstants.NOT_AUTHORIZED,
"You do not have the right to create a container in context: " + contextId,
Window.Notification.TYPE_WARNING_MESSAGE));
}
}

private boolean allowedToAddMember(final ResourceModel target) throws EscidocClientException, URISyntaxException {
return repositories.pdp().forUser(currentUser.getUserId()).isAction(ActionIdConstants.ADD_MEMBERS_TO_CONTAINER).forResource(target.getId()).permitted();
return repositories
.pdp().forUser(currentUser.getUserId()).isAction(ActionIdConstants.ADD_MEMBERS_TO_CONTAINER)
.forResource(target.getId()).permitted();
}

private boolean allowedToDeleteContainer(final String containerId) throws EscidocClientException, URISyntaxException {
return repositories.pdp().forUser(currentUser.getUserId()).isAction(ActionIdConstants.DELETE_CONTAINER).forResource(containerId).permitted();
private boolean allowedToDeleteContainer(final String containerId) throws EscidocClientException,
URISyntaxException {
return repositories
.pdp().forUser(currentUser.getUserId()).isAction(ActionIdConstants.DELETE_CONTAINER)
.forResource(containerId).permitted();
}

private boolean allowedToCreateItem(final String contextId) throws EscidocClientException, URISyntaxException {
return repositories.pdp().forUser(currentUser.getUserId()).isAction(ActionIdConstants.CREATE_ITEM).forResource("")
return repositories
.pdp().forUser(currentUser.getUserId()).isAction(ActionIdConstants.CREATE_ITEM).forResource("")
.withTypeAndInContext(ResourceType.ITEM, contextId).permitted();
}

private boolean allowedToCreateContainer(final String contextId) throws EscidocClientException, URISyntaxException {
return repositories.pdp().forUser(currentUser.getUserId()).isAction(ActionIdConstants.CREATE_CONTAINER).forResource("")
return repositories
.pdp().forUser(currentUser.getUserId()).isAction(ActionIdConstants.CREATE_CONTAINER).forResource("")
.withTypeAndInContext(ResourceType.CONTAINER, contextId).permitted();
}

@@ -308,7 +332,8 @@ private void deleteContainer(final ContainerModel selected) {
treeDataSource.remove(selected);
}
catch (final EscidocClientException e) {
getWindow().showNotification("Can not delete " + selected.getName(), e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE);
getWindow().showNotification("Can not delete " + selected.getName(), e.getMessage(),
Window.Notification.TYPE_ERROR_MESSAGE);
}
}

@@ -346,7 +371,8 @@ private void showCreateItemView(final Object target, final String contextId) {
}

private ShowAddViewCommand buildCommand(final Object target, final String contextId) {
final ShowAddViewCommand showAddViewCommand = new ShowAddViewCommand(repositories, getWindow(), contextId, treeDataSource, currentUser);
final ShowAddViewCommand showAddViewCommand =
new ShowAddViewCommand(repositories, getWindow(), contextId, treeDataSource, currentUser);
showAddViewCommand.withParent((ResourceModel) target);
return showAddViewCommand;
}
@@ -52,23 +52,29 @@ public class ActionList {

static final Action ACTION_DELETE_STUDY = new Action(ELabViewContants.DELETE_STUDY, ELabsIcons.DELETE_ELEMENT_ICON);

static final Action ACTION_ADD_INVESTIGATION = new Action(ELabViewContants.ADD_INVESTIGATION, ELabsIcons.ADD_ELEMENT_ICON);
static final Action ACTION_ADD_INVESTIGATION = new Action(ELabViewContants.ADD_INVESTIGATION,
ELabsIcons.ADD_ELEMENT_ICON);

static final Action ACTION_MODIFY_INVESTIGATION = new Action(ELabViewContants.MODIFY_INVESTIGATION, ELabsIcons.MODIFY_ELEMENT_ICON);
static final Action ACTION_MODIFY_INVESTIGATION = new Action(ELabViewContants.MODIFY_INVESTIGATION,
ELabsIcons.MODIFY_ELEMENT_ICON);

static final Action ACTION_DELETE_INVESTIGATION = new Action(ELabViewContants.DELETE_INVESTIGATION, ELabsIcons.DELETE_ELEMENT_ICON);
static final Action ACTION_DELETE_INVESTIGATION = new Action(ELabViewContants.DELETE_INVESTIGATION,
ELabsIcons.DELETE_ELEMENT_ICON);

static final Action ACTION_ADD_RIG = new Action(ELabViewContants.ADD_RIG, ELabsIcons.ADD_ELEMENT_ICON);

static final Action ACTION_MODIFY_RIG = new Action(ELabViewContants.MODIFY_RIG, ELabsIcons.MODIFY_ELEMENT_ICON);

static final Action ACTION_DELETE_RIG = new Action(ELabViewContants.DELETE_RIG, ELabsIcons.DELETE_ELEMENT_ICON);

static final Action ACTION_ADD_INSTRUMENT = new Action(ELabViewContants.ADD_INSTRUMENT, ELabsIcons.ADD_ELEMENT_ICON);
static final Action ACTION_ADD_INSTRUMENT =
new Action(ELabViewContants.ADD_INSTRUMENT, ELabsIcons.ADD_ELEMENT_ICON);

static final Action ACTION_MODIFY_INSTRUMENT = new Action(ELabViewContants.MODIFY_INSTRUMENT, ELabsIcons.MODIFY_ELEMENT_ICON);
static final Action ACTION_MODIFY_INSTRUMENT = new Action(ELabViewContants.MODIFY_INSTRUMENT,
ELabsIcons.MODIFY_ELEMENT_ICON);

static final Action ACTION_DELETE_INSTRUMENT = new Action(ELabViewContants.DELETE_INSTRUMENT, ELabsIcons.DELETE_ELEMENT_ICON);
static final Action ACTION_DELETE_INSTRUMENT = new Action(ELabViewContants.DELETE_INSTRUMENT,
ELabsIcons.DELETE_ELEMENT_ICON);
//

}