/*
 * This is the quality assurance screen provider.
 */
package net.sourceforge.javydreamercsw.validation.manager.web.quality;

import com.vaadin.ui.Component;
import com.vaadin.ui.Notification;
import com.validation.manager.core.DataBaseManager;
import com.validation.manager.core.IMainContentProvider;
import com.validation.manager.core.db.ExecutionStep;
import com.validation.manager.core.db.controller.ExecutionStepJpaController;
import com.validation.manager.core.server.core.VMSettingServer;
import net.sourceforge.javydreamercsw.validation.manager.web.ValidationManagerUI;
import net.sourceforge.javydreamercsw.validation.manager.web.tester.ExecutionScreen;
import org.openide.util.lookup.ServiceProvider;

/**
 *
 * @author Javier A. Ortiz Bultron <javier.ortiz.78@gmail.com>
 */
@ServiceProvider(service = IMainContentProvider.class, position = 3)
public class QualityScreenProvider extends ExecutionScreen {

    @Override
    public String getComponentCaption() {
        return "quality.tab.name";
    }

    @Override
    public boolean shouldDisplay() {
        return ValidationManagerUI.getInstance().getUser() != null
                && ValidationManagerUI.getInstance()
                        .checkRight("quality.assurance")
                && VMSettingServer.getSetting("quality.review").getBoolVal();
    }

    @Override
    public Component getContent() {
        Component content = super.getContent();
        content.setId(getComponentCaption());
        return content;
    }

    @Override
    public void processNotification() {
        if (shouldDisplay()) {
            ExecutionStepJpaController c
                    = new ExecutionStepJpaController(DataBaseManager
                            .getEntityManagerFactory());
            for (ExecutionStep es : c.findExecutionStepEntities()) {
                if (es.getLocked() && !es.getReviewed()) {
                    //It has been assigned but not started
                    Notification.show("Quality Review Pending",
                            "You have test case(s) pending review.",
                            Notification.Type.TRAY_NOTIFICATION);
                    break;
                }
            }
        }
    }
}

@@ -361,16 +361,66 @@
 nStep;%0D%0A
+import com.validation.manager.core.db.VmSetting;%0D%0A
 import c
@@ -1138,24 +1138,99 @@
 isplay() %7B%0D%0A
+        VmSetting setting = VMSettingServer.getSetting(%22quality.review%22);%0D%0A
         retu
@@ -1420,52 +1420,51 @@
  && 
-VMS
+s
 etting
-Server.getSetting(%22quality.review%22)
+ != null%0D%0A                && setting
 .get

Handle missing setting.