Example usage for java.util EnumSet allOf

List of usage examples for java.util EnumSet allOf

Introduction

In this page you can find the example usage for java.util EnumSet allOf.

Prototype

public static <E extends Enum<E>> EnumSet<E> allOf(Class<E> elementType) 

Source Link

Document

Creates an enum set containing all of the elements in the specified element type.

Usage

From source file:org.lockss.exporter.kbart.KbartExportFilter.java

/**
 * Calculate which fields have no values across the whole range of titles. 
 * Iterates through all the titles for each field value, until an entry is 
 * found or the end of the title list is reached.
 * //from   ww w .  ja  va2s. com
 * @return a set of fields which are empty
 */
private EnumSet<Field> findEmptyFields() {
    long s = System.currentTimeMillis();
    EnumSet<Field> empty = EnumSet.allOf(Field.class);
    for (Field f : Field.getFieldSet()) {
        // Check if any title has a value for this field
        for (KbartTitle kbt : titles) {
            if (kbt.hasFieldValue(f)) {
                empty.remove(f);
                break;
            }
        }
    }
    // Log the time, as this is an expensive way to monitor empty fields.
    // It should be done somehow during title conversion.
    log.debug("findEmptyFields() took " + (System.currentTimeMillis() - s) + "s");
    return empty;
}

From source file:org.seedstack.mqtt.internal.MqttPlugin.java

private void configureMqttClients() {
    String[] clients = mqttConfiguration.getStringArray(CONNECTION_CLIENTS);

    for (String clientName : clients) {
        LOGGER.debug("Configure new MqttClient [{}]", clientName);
        Configuration clientConfiguration = mqttConfiguration.subset(CONNECTION_CLIENT + "." + clientName);
        String uri = clientConfiguration.getString(BROKER_URI);
        String clientId = clientConfiguration.getString(MQTTCLIENT_ID);
        if (uri == null) {
            throw SeedException.createNew(MqttErrorCodes.MISCONFIGURED_MQTT_CLIENT).put("clients", clientName);
        }/*from ww  w  . j  ava  2s  . co m*/
        if (clientId == null) {
            clientId = MqttClient.generateClientId();
            LOGGER.debug("Generate new client id [{}] for client name [{}]", clientId, clientName);
        }

        MqttClientDefinition def = new MqttClientDefinition(uri, clientId);
        Configuration reconnectConfiguration = clientConfiguration.subset(RECONNECTION_PROPS);
        if (!reconnectConfiguration.isEmpty()) {
            try {
                String reconnection = reconnectConfiguration.getString(RECONNECTION_MODE);
                if (reconnection != null) {
                    MqttReconnectionMode mode = Enum.valueOf(MqttReconnectionMode.class, reconnection);
                    def.setReconnectionMode(mode);
                }
                String inter = reconnectConfiguration.getString(RECONNECTION_INTERVAL);
                if (inter != null) {
                    def.setReconnectionInterval(Integer.parseInt(inter));
                }
            } catch (Exception e) {
                throw SeedException.createNew(MqttErrorCodes.MISCONFIGURED_MQTT_RECONNECTION).put("values",
                        EnumSet.allOf(MqttReconnectionMode.class));
            }
        }
        MqttConnectOptionsDefinition connectOptionsDefinition = new MqttConnectOptionsDefinition(
                clientConfiguration.subset(MQTT_OPTIONS));
        def.setConnectOptionsDefinition(connectOptionsDefinition);

        // Check ThreadPool Configuration
        def.setPoolDefinition(new MqttPoolDefinition(clientConfiguration.subset(POOL_PROPS)));

        mqttClientDefinitions.put(clientName, def);
    }
}

From source file:org.silverpeas.migration.jcr.service.repository.DocumentRepositoryTest.java

/**
 * Test of listComponentsWithWysiwyg method, of class DocumentRepository.
 */// ww w  .j a v  a 2  s.  c om
@Test
public void listComponentsWithWysiwyg() throws Exception {
    new JcrDocumentRepositoryTest() {
        @Override
        public void run(final Session session) throws Exception {
            Set<String> createdIds = new HashSet<String>();
            // No WYSIWYG content exists
            List<String> components = getDocumentRepository().listComponentsWithWysiwyg(session);
            assertThat(components, notNullValue());
            assertThat(components, hasSize(0));

            // Creating an FR "attachment" content.
            String createdUuid = createAttachmentForTest(
                    defaultDocumentBuilder("fId_1").setDocumentType(attachment), defaultFRContentBuilder(),
                    "fId_1_fr").getId();
            createdIds.add(createdUuid);
            SimpleDocument enDocument = getDocumentById(createdUuid, "en");
            assertThat(enDocument, notNullValue());
            assertThat(enDocument.getAttachment(), nullValue());
            SimpleDocument frDocument = getDocumentById(createdUuid, "fr");
            assertThat(frDocument, notNullValue());
            assertThat(frDocument.getAttachment(), notNullValue());
            assertThat(frDocument.getDocumentType(), is(attachment));

            // Updating attachment with EN content.
            setEnData(frDocument);
            updateAttachmentForTest(frDocument, "en", "fId_1_en");
            createdIds.add(frDocument.getId());

            // Vrifying the attachment exists into both of tested languages.
            enDocument = getDocumentById(createdUuid, "en");
            assertThat(enDocument, notNullValue());
            assertThat(enDocument.getAttachment(), notNullValue());
            assertThat(enDocument.getDocumentType(), is(attachment));
            checkEnglishSimpleDocument(enDocument);
            frDocument = getDocumentById(createdUuid, "fr");
            assertThat(frDocument, notNullValue());
            assertThat(frDocument.getAttachment(), notNullValue());
            assertThat(frDocument.getDocumentType(), is(attachment));
            checkFrenchSimpleDocument(frDocument);

            // No WYSIWYG : that is what it is expected
            components = getDocumentRepository().listComponentsWithWysiwyg(session);
            assertThat(components, hasSize(0));

            // Adding several documents, but no WYSIWYG
            Set<DocumentType> documentTypes = EnumSet.allOf(DocumentType.class);
            documentTypes.remove(DocumentType.wysiwyg);
            int id = 2;
            for (DocumentType documentType : documentTypes) {
                createdIds.add(createAttachmentForTest(
                        defaultDocumentBuilder("fId_" + id).setDocumentType(documentType),
                        defaultFRContentBuilder(), "fId_" + id + "_fr").getId());
                id++;
            }

            // No WYSIWYG : that is what it is expected
            components = getDocumentRepository().listComponentsWithWysiwyg(session);
            assertThat(components, hasSize(0));

            // Number of expected created documents
            int nbDocuments = 1 + (DocumentType.values().length - 1);
            assertThat(createdIds.size(), is(nbDocuments));

            // Adding the first WYSIWYG EN content
            createdUuid = createAttachmentForTest(defaultDocumentBuilder("fId_26").setDocumentType(wysiwyg),
                    defaultENContentBuilder(), "fId_26_en").getId();
            createdIds.add(createdUuid);

            // One WYSIWYG
            components = getDocumentRepository().listComponentsWithWysiwyg(session);
            assertThat(components, hasSize(1));
            assertThat(components, contains(instanceId));

            // Adding the FR content to the first WYSIWYG document
            enDocument = getDocumentById(createdUuid, "en");
            setEnData(enDocument);
            updateAttachmentForTest(enDocument, "fr", "fId_26_fr");
            createdIds.add(enDocument.getId());

            // One WYSIWYG on one Component
            components = getDocumentRepository().listComponentsWithWysiwyg(session);
            assertThat(components, hasSize(1));
            assertThat(components, contains(instanceId));

            // Adding the second WYSIWYG document (on same component)
            createdUuid = createAttachmentForTest(defaultDocumentBuilder("fId_27").setDocumentType(wysiwyg),
                    defaultFRContentBuilder(), "fId_27_fr").getId();
            createdIds.add(createdUuid);

            // Two WYSIWYG on one Component
            components = getDocumentRepository().listComponentsWithWysiwyg(session);
            assertThat(components, hasSize(1));
            assertThat(components, contains(instanceId));

            // Adding a third WYSIWYG document (on other component that does not respect component id
            // pattern)
            createdUuid = createAttachmentForTest(defaultDocumentBuilder("fId_28")
                    .setPk(new SimpleDocumentPK("-1", "badInstanceIdPattern")).setDocumentType(wysiwyg),
                    defaultENContentBuilder(), "fId_28_en").getId();
            createdIds.add(createdUuid);

            // Three WYSIWYG on two Components (one component id is not taken into account because
            // its instanceId)
            components = getDocumentRepository().listComponentsWithWysiwyg(session);
            assertThat(components, hasSize(1));
            assertThat(components, containsInAnyOrder(instanceId));

            // Adding a fourth WYSIWYG document (on other component that respects component id
            // pattern)
            createdUuid = createAttachmentForTest(defaultDocumentBuilder("fId_29")
                    .setPk(new SimpleDocumentPK("-1", "otherInstanceId38")).setDocumentType(wysiwyg),
                    defaultFRContentBuilder(), "fId_29_fr").getId();
            createdIds.add(createdUuid);

            // Number of expected created documents
            nbDocuments = nbDocuments + 4;
            assertThat(createdIds.size(), is(nbDocuments));

            // Four WYSIWYG on three Components (one component id is not taken into account because
            // its instanceId)
            components = getDocumentRepository().listComponentsWithWysiwyg(session);
            assertThat(components, hasSize(2));
            assertThat(components, containsInAnyOrder(instanceId, "otherInstanceId38"));
        }
    }.execute();
}

From source file:org.apache.zeppelin.server.ZeppelinServer.java

private static WebAppContext setupWebAppContext(ContextHandlerCollection contexts, ZeppelinConfiguration conf) {

    WebAppContext webApp = new WebAppContext();
    webApp.setContextPath(conf.getServerContextPath());
    File warPath = new File(conf.getString(ConfVars.ZEPPELIN_WAR));
    if (warPath.isDirectory()) {
        // Development mode, read from FS
        // webApp.setDescriptor(warPath+"/WEB-INF/web.xml");
        webApp.setResourceBase(warPath.getPath());
        webApp.setParentLoaderPriority(true);
    } else {/*from  ww  w  .  j a va2 s  .  c om*/
        // use packaged WAR
        webApp.setWar(warPath.getAbsolutePath());
        File warTempDirectory = new File(conf.getRelativeDir(ConfVars.ZEPPELIN_WAR_TEMPDIR));
        warTempDirectory.mkdir();
        LOG.info("ZeppelinServer Webapp path: {}", warTempDirectory.getPath());
        webApp.setTempDirectory(warTempDirectory);
    }
    // Explicit bind to root
    webApp.addServlet(new ServletHolder(new DefaultServlet()), "/*");
    contexts.addHandler(webApp);

    webApp.addFilter(new FilterHolder(CorsFilter.class), "/*", EnumSet.allOf(DispatcherType.class));

    webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed",
            Boolean.toString(conf.getBoolean(ConfVars.ZEPPELIN_SERVER_DEFAULT_DIR_ALLOWED)));

    return webApp;

}

From source file:org.photovault.imginfo.Test_PhotoInfo.java

/**
   Test that creating a new thumbnail using createThumbnail works
 *//*from w  ww.j a v  a2s.  co m*/
@Test
public void testThumbnailCreate() {
    String fname = "test1.jpg";
    File f = new File(testImgDir, fname);
    PhotoInfo photo = createPhoto(f);
    assertNotNull(photo);
    int copyCount = photo.getOriginal().getCopies().size();
    photo.createThumbnail();
    assertEquals("InstanceNum should be 1 greater after adding thumbnail", copyCount + 1,
            photo.getOriginal().getCopies().size());
    // Try to find the new thumbnail
    boolean foundThumbnail = false;
    CopyImageDescriptor thumbnail = (CopyImageDescriptor) photo.getPreferredImage(
            EnumSet.allOf(ImageOperations.class), EnumSet.allOf(ImageOperations.class), 0, 0, 100, 100);

    assertNotNull("Could not find the created thumbnail", thumbnail);
    assertEquals("Thumbnail width should be 100", 100, thumbnail.getWidth());
    File thumbnailFile = thumbnail.getFile().findAvailableCopy();
    assertTrue("Image file does not exist", thumbnailFile.exists());

    // Test the getThumbnail method
    Thumbnail thumb = photo.getThumbnail();
    assertNotNull(thumb);
    assertFalse("Thumbnail exists, should not return default thumbnail",
            thumb == Thumbnail.getDefaultThumbnail());

    session.flush();
    assertMatchesDb(photo);

    photo.delete();
    assertFalse("Image file does exist after delete", thumbnailFile.exists());
}

From source file:org.apache.hadoop.yarn.server.resourcemanager.TestClientRMService.java

@Test
public void testGetClusterNodes() throws Exception {
    MockRM rm = new MockRM() {
        protected ClientRMService createClientRMService() {
            return new ClientRMService(this.rmContext, scheduler, this.rmAppManager,
                    this.applicationACLsManager, this.queueACLsManager,
                    this.getRMContext().getRMDelegationTokenSecretManager());
        };/*from w w  w.ja v a2  s . c o  m*/
    };
    rm.start();
    RMNodeLabelsManager labelsMgr = rm.getRMContext().getNodeLabelManager();
    labelsMgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("x", "y"));

    // Add a healthy node with label = x
    MockNM node = rm.registerNode("host1:1234", 1024);
    Map<NodeId, Set<String>> map = new HashMap<NodeId, Set<String>>();
    map.put(node.getNodeId(), ImmutableSet.of("x"));
    labelsMgr.replaceLabelsOnNode(map);
    rm.sendNodeStarted(node);
    node.nodeHeartbeat(true);

    // Add and lose a node with label = y
    MockNM lostNode = rm.registerNode("host2:1235", 1024);
    rm.sendNodeStarted(lostNode);
    lostNode.nodeHeartbeat(true);
    rm.NMwaitForState(lostNode.getNodeId(), NodeState.RUNNING);
    rm.sendNodeLost(lostNode);

    // Create a client.
    Configuration conf = new Configuration();
    YarnRPC rpc = YarnRPC.create(conf);
    InetSocketAddress rmAddress = rm.getClientRMService().getBindAddress();
    LOG.info("Connecting to ResourceManager at " + rmAddress);
    ApplicationClientProtocol client = (ApplicationClientProtocol) rpc.getProxy(ApplicationClientProtocol.class,
            rmAddress, conf);

    // Make call
    GetClusterNodesRequest request = GetClusterNodesRequest.newInstance(EnumSet.of(NodeState.RUNNING));
    List<NodeReport> nodeReports = client.getClusterNodes(request).getNodeReports();
    Assert.assertEquals(1, nodeReports.size());
    Assert.assertNotSame("Node is expected to be healthy!", NodeState.UNHEALTHY,
            nodeReports.get(0).getNodeState());

    // Check node's label = x
    Assert.assertTrue(nodeReports.get(0).getNodeLabels().contains("x"));

    // Now make the node unhealthy.
    node.nodeHeartbeat(false);

    // Call again
    nodeReports = client.getClusterNodes(request).getNodeReports();
    Assert.assertEquals("Unhealthy nodes should not show up by default", 0, nodeReports.size());

    // Change label of host1 to y
    map = new HashMap<NodeId, Set<String>>();
    map.put(node.getNodeId(), ImmutableSet.of("y"));
    labelsMgr.replaceLabelsOnNode(map);

    // Now query for UNHEALTHY nodes
    request = GetClusterNodesRequest.newInstance(EnumSet.of(NodeState.UNHEALTHY));
    nodeReports = client.getClusterNodes(request).getNodeReports();
    Assert.assertEquals(1, nodeReports.size());
    Assert.assertEquals("Node is expected to be unhealthy!", NodeState.UNHEALTHY,
            nodeReports.get(0).getNodeState());

    Assert.assertTrue(nodeReports.get(0).getNodeLabels().contains("y"));

    // Remove labels of host1
    map = new HashMap<NodeId, Set<String>>();
    map.put(node.getNodeId(), ImmutableSet.of("y"));
    labelsMgr.removeLabelsFromNode(map);

    // Query all states should return all nodes
    rm.registerNode("host3:1236", 1024);
    request = GetClusterNodesRequest.newInstance(EnumSet.allOf(NodeState.class));
    nodeReports = client.getClusterNodes(request).getNodeReports();
    Assert.assertEquals(3, nodeReports.size());

    // All host1-3's label should be empty (instead of null)
    for (NodeReport report : nodeReports) {
        Assert.assertTrue(report.getNodeLabels() != null && report.getNodeLabels().isEmpty());
    }

    rpc.stopProxy(client, conf);
    rm.close();
}

From source file:org.apache.hadoop.yarn.server.applicationhistoryservice.timeline.HBaseTimelineStore.java

@Override
public TimelineEntity getEntity(String entityId, String entityType, EnumSet<Field> fieldsToRetrieve)
        throws IOException {
    byte[] revStartTime = getStartTime(entityId, entityType, null, null);
    if (revStartTime == null) {
        return null;
    }/*from  w  ww  .  j  av a2  s. co m*/

    Get get = new Get(HBaseTimelineStoreUtil.createEntityRow(entityId, entityType, revStartTime));
    TimelineEntity entity = new TimelineEntity();
    entity.setEntityId(entityId);
    entity.setEntityType(entityType);
    entity.setStartTime(readReverseOrderedLong(revStartTime, 0));

    if (fieldsToRetrieve == null) {
        fieldsToRetrieve = EnumSet.allOf(Field.class);
    }
    if (fieldsToRetrieve.contains(Field.EVENTS) || fieldsToRetrieve.contains(Field.LAST_EVENT_ONLY)) {
        get.addFamily(EVENTS_COLUMN);
    }
    if (fieldsToRetrieve.contains(Field.RELATED_ENTITIES)) {
        get.addFamily(RELATED_ENTITIES_COLUMN);
    }
    if (fieldsToRetrieve.contains(Field.PRIMARY_FILTERS)) {
        get.addFamily(PRIMARY_FILTERS_COLUMN);
    }
    if (fieldsToRetrieve.contains(Field.OTHER_INFO)) {
        get.addFamily(OTHER_INFO_COLUMN);
    }

    HTableInterface table = getTable(ENTITY_TABLE);
    try {
        Result result = table.get(get);
        getEntityFromResult(entity, result, fieldsToRetrieve);
        return entity;
    } finally {
        IOUtils.cleanup(LOG, table);
    }
}

From source file:com.gtwm.pb.servlets.AppController.java

public static void carryOutAppActions(HttpServletRequest request, SessionDataInfo sessionData,
        DatabaseInfo databaseDefn, List<FileItem> multipartItems, StringBuffer appActionName)
        throws AgileBaseException, SQLException, FileUploadException, IOException, MessagingException {
    // perform any actions
    EnumSet<AppAction> appActions = EnumSet.allOf(AppAction.class);
    for (AppAction appAction : appActions) {
        // Store so exception handling has access to the action carried out
        appActionName.setLength(0);//from  www .  j a v a 2 s .  c om
        appActionName.append(appAction.toString());
        String appActionValue = ServletUtilMethods.getParameter(request,
                appAction.toString().toLowerCase(Locale.UK), multipartItems);
        if (appActionValue != null) {
            sessionData.setLastAppAction(appAction);
            switch (appAction) {
            // Most commonly used actions at the start
            case UPDATE_RECORD:
                ServletDataMethods.saveRecord(sessionData, request, false, databaseDefn, multipartItems);
                break;
            case SAVE_NEW_RECORD:
                ServletDataMethods.saveRecord(sessionData, request, true, databaseDefn, multipartItems);
                break;
            case CLONE_RECORD:
                ServletDataMethods.cloneRecord(sessionData, request, databaseDefn, multipartItems);
                break;
            case REMOVE_RECORD:
                ServletDataMethods.removeRecord(sessionData, request, databaseDefn);
                break;
            case GLOBAL_EDIT:
                ServletDataMethods.globalEdit(sessionData, request, databaseDefn, multipartItems);
                break;
            case CONTRACT_SECTION:
                ServletSchemaMethods.contractSection(sessionData, request, databaseDefn);
                break;
            case EXPAND_SECTION:
                ServletSchemaMethods.expandSection(sessionData, request, databaseDefn);
                break;
            case ADD_COMMENT:
                ServletDataMethods.addComment(sessionData, request, databaseDefn);
                break;
            case ADD_USER:
                ServletAuthMethods.addUser(sessionData, request, databaseDefn.getAuthManager());
                break;
            case REMOVE_USER:
                ServletAuthMethods.removeUser(sessionData, request, databaseDefn);
                break;
            case UPDATE_USER:
                ServletAuthMethods.updateUser(sessionData, request, databaseDefn.getAuthManager());
                break;
            case SEND_PASSWORD_RESET:
                ServletAuthMethods.sendPasswordReset(request, databaseDefn.getAuthManager());
                break;
            case ADD_ROLE:
                ServletAuthMethods.addRole(sessionData, request, databaseDefn.getAuthManager());
                break;
            case UPDATE_ROLE:
                ServletAuthMethods.updateRole(sessionData, request, databaseDefn.getAuthManager());
                break;
            case REMOVE_ROLE:
                ServletAuthMethods.removeRole(sessionData, request, databaseDefn);
                break;
            case ASSIGN_USER_TO_ROLE:
                ServletAuthMethods.assignUserToRole(request, databaseDefn.getAuthManager());
                break;
            case REMOVE_USER_FROM_ROLE:
                ServletAuthMethods.removeUserFromRole(request, databaseDefn);
                break;
            case ADD_PRIVILEGE:
                ServletAuthMethods.addPrivilege(request, databaseDefn);
                break;
            case REMOVE_PRIVILEGE:
                ServletAuthMethods.removePrivilege(request, databaseDefn);
                break;
            case SET_MAX_TABLE_PRIVILEGE:
                ServletAuthMethods.setMaxTablePrivilege(sessionData, request, databaseDefn);
                break;
            case CLEAR_ALL_TABLE_PRIVILEGES:
                ServletAuthMethods.clearAllTablePrivileges(request, databaseDefn);
                break;
            case ADD_TABLE:
                ServletSchemaMethods.addTable(sessionData, request, databaseDefn);
                break;
            case UPDATE_TABLE:
                ServletSchemaMethods.updateTable(sessionData, request, databaseDefn);
                break;
            case REMOVE_TABLE:
                ServletSchemaMethods.removeTable(sessionData, request, databaseDefn);
                break;
            case ADD_FIELD:
                ServletSchemaMethods.addField(sessionData, request, databaseDefn);
                break;
            case REMOVE_FIELD:
                ServletSchemaMethods.removeField(sessionData, request, databaseDefn);
                break;
            case UPDATE_FIELD:
                ServletSchemaMethods.updateField(sessionData, request, databaseDefn);
                break;
            case UPDATE_FIELD_OPTION:
                ServletSchemaMethods.updateFieldOption(sessionData, request, databaseDefn);
                break;
            case SET_FIELD_INDEX:
                ServletSchemaMethods.setFieldIndex(sessionData, request, databaseDefn);
                break;
            case ADD_REPORT:
                ServletSchemaMethods.addReport(sessionData, request, databaseDefn);
                break;
            case UPDATE_REPORT:
                ServletSchemaMethods.updateReport(sessionData, request, databaseDefn);
                break;
            case UPLOAD_CUSTOM_TEMPLATE:
                ServletSchemaMethods.uploadCustomReportTemplate(sessionData, request, databaseDefn,
                        multipartItems);
                break;
            case REMOVE_CUSTOM_TEMPLATE:
                ServletSchemaMethods.removeCustomReportTemplate(sessionData, request, databaseDefn);
                break;
            case REMOVE_REPORT:
                ServletSchemaMethods.removeReport(sessionData, request, databaseDefn);
                break;
            case ADD_FIELD_TO_REPORT:
                ServletSchemaMethods.addFieldToReport(sessionData, request, databaseDefn);
                break;
            case REMOVE_FIELD_FROM_REPORT:
                ServletSchemaMethods.removeFieldFromReport(sessionData, request, databaseDefn);
                break;
            case SET_REPORT_FIELD_INDEX:
                ServletSchemaMethods.setReportFieldIndex(sessionData, request, databaseDefn);
                break;
            case SET_REPORT_FIELD_SORTING:
                ServletSchemaMethods.setReportFieldSorting(sessionData, request, databaseDefn);
                break;
            case ADD_CALCULATION_TO_REPORT:
                ServletSchemaMethods.addCalculationToReport(sessionData, request, databaseDefn);
                break;
            case UPDATE_CALCULATION_IN_REPORT:
                ServletSchemaMethods.updateCalculationInReport(sessionData, request, databaseDefn);
                break;
            case ADD_FILTER_TO_REPORT:
                ServletSchemaMethods.addFilterToReport(sessionData, request, databaseDefn);
                break;
            case REMOVE_FILTER_FROM_REPORT:
                ServletSchemaMethods.removeFilterFromReport(sessionData, request, databaseDefn);
                break;
            case ADD_JOIN_TO_REPORT:
                ServletSchemaMethods.addJoinToReport(sessionData, request, databaseDefn);
                break;
            case REMOVE_JOIN_FROM_REPORT:
                ServletSchemaMethods.removeJoinFromReport(sessionData, request, databaseDefn);
                break;
            case ADD_GROUPING_TO_CHART:
                ServletSchemaMethods.addGroupingToChart(sessionData, request, databaseDefn);
                break;
            case REMOVE_GROUPING_FROM_CHART:
                ServletSchemaMethods.removeGroupingFromChart(sessionData, request, databaseDefn);
                break;
            case ADD_FUNCTION_TO_CHART:
                ServletSchemaMethods.addFunctionToChart(sessionData, request, databaseDefn);
                break;
            case REMOVE_FUNCTION_FROM_CHART:
                ServletSchemaMethods.removeFunctionFromChart(sessionData, request, databaseDefn);
                break;
            case SET_CHART_FILTER:
                ServletSchemaMethods.setChartFilter(sessionData, request, databaseDefn);
                break;
            case SET_CHART_FILTER_FIELD:
                ServletSchemaMethods.setChartFilterField(sessionData, request, databaseDefn);
                break;
            case SET_CHART_RANGE:
                ServletSchemaMethods.setChartRange(sessionData, request, databaseDefn);
                break;
            case SAVE_CHART:
                ServletSchemaMethods.saveChart(sessionData, request, databaseDefn);
                break;
            case REMOVE_CHART:
                ServletSchemaMethods.removeChart(sessionData, request, databaseDefn);
                break;
            case SET_WORD_CLOUD_FIELD:
                ServletSchemaMethods.setReportWordCloudField(sessionData, request, databaseDefn);
                break;
            case UPDATE_MAP:
                ServletSchemaMethods.updateMap(sessionData, request, databaseDefn);
                break;
            case SET_DASHBOARD_CHART_STATE:
                ServletDashboardMethods.setDashboardSummaryState(sessionData, request, databaseDefn);
                break;
            case CSV_IMPORT:
                ServletDataMethods.importRecords(sessionData, request, databaseDefn, multipartItems);
                break;
            case LOCK_RECORDS:
                ServletDataMethods.lockRecords(sessionData, request, databaseDefn);
                break;
            case ADD_COMPANY:
                ServletSchemaMethods.addCompany(request, databaseDefn);
                break;
            case REMOVE_COMPANY:
                ServletSchemaMethods.removeCompany(request, databaseDefn.getAuthManager());
                break;
            case ANONYMISE:
                ServletDataMethods.anonymiseTableData(sessionData, request, databaseDefn, multipartItems);
                break;
            case ADD_MODULE:
                ServletSchemaMethods.addModule(request, sessionData, databaseDefn);
                break;
            case REMOVE_MODULE:
                ServletSchemaMethods.removeModule(request, sessionData, databaseDefn);
                break;
            case UPDATE_MODULE:
                ServletSchemaMethods.updateModule(request, sessionData, databaseDefn.getAuthManager());
                break;
            case HIDE_REPORT:
                ServletSchemaMethods.hideReportFromUser(sessionData, request, databaseDefn);
                break;
            case UNHIDE_REPORT:
                ServletSchemaMethods.unhideReportFromUser(sessionData, request, databaseDefn);
                break;
            case ADD_OPERATIONAL_DASHBOARD_REPORT:
                ServletSchemaMethods.addOperationalDashboardReport(sessionData, request, databaseDefn);
                break;
            case REMOVE_OPERATIONAL_DASHBOARD_REPORT:
                ServletSchemaMethods.removeOperationalDashboardReport(sessionData, request, databaseDefn);
                break;
            case ADD_FORM_TABLE:
                ServletSchemaMethods.addFormTable(sessionData, request, databaseDefn);
                break;
            case REMOVE_FORM_TABLE:
                ServletSchemaMethods.removeFormTable(sessionData, request, databaseDefn);
                break;
            case ADD_FORM_TAB:
                ServletSchemaMethods.addFormTab(request, sessionData, databaseDefn);
                break;
            case REMOVE_FORM_TAB:
                ServletSchemaMethods.removeFormTab(request, sessionData, databaseDefn);
                break;
            case UPDATE_FORM_TAB:
                ServletSchemaMethods.updateFormTab(sessionData, request, databaseDefn);
                break;
            case SET_TABLE_FORM:
                ServletSchemaMethods.setTableForm(request, sessionData, databaseDefn);
                break;
            case SET_USER_DEFAULT_REPORT:
                ServletSchemaMethods.setUserDefaultReport(sessionData, request, databaseDefn);
                break;
            case SET_CALENDAR_SYNCABLE:
                boolean calendarSyncable = Helpers.valueRepresentsBooleanTrue(appActionValue);
                ServletSchemaMethods.setCalendarSyncable(sessionData, request, databaseDefn, calendarSyncable);
                break;
            case ENABLE_DISABLE_APP:
                ServletSchemaMethods.enableDisableApp(request, databaseDefn);
                break;
            case ADD_REPORT_DISTINCT:
                ServletSchemaMethods.addDistinctToReport(sessionData, request, databaseDefn);
                break;
            case REMOVE_REPORT_DISTINCT:
                ServletSchemaMethods.removeDistinctFromReport(sessionData, request, databaseDefn);
                break;
            }
        }
    }
}

From source file:com.alcatel_lucent.nz.wnmsextract.WNMSDataExtractor.java

/** readArgs. Read command line arguments and parse
 * @param args//from  ww w.  ja v  a  2 s.c om
 * @return read with/without error
 */
public boolean readArgs(String[] args) {
    boolean ret = true;
    boolean af = true;
    boolean bs = true;
    boolean ws = true;
    boolean vp = false;
    //boolean ns = false;
    DatabaseType df = DatabaseType.TNZ_NZRSDB;
    LogAppType lf = LogAppType.File;
    Calendar tf = Calendar.getInstance();
    tf.add(Calendar.DATE, -1);
    //DocumentType xf = null;//default is the list of all doc types so do that in init()
    String bsd = null;
    String bfd = null;

    try {
        Options opt = new Options();

        opt.addOption("h", "help", false, "Print help for this application");
        //opt.addOption("e", "extract", true,  "Extraction Source {c=CPV Archive, t=TNZ Ops TAR file, g=GTA ZIP file. No default.}");
        opt.addOption("l", "log", true, "Logging Appender {f=File (def), c=Console, s=Socket}");
        opt.addOption("t", "time", true, "Specific process date {yyyy-MM-dd}. Default to 'Yesterday'");
        opt.addOption("d", "database", true,
                "Database to send Results {NPO48, NPO33, TEST, MPM, TNZ_NZRSDB , GTA_NZRSDB. No Default}");
        opt.addOption("x", "doctype", true,
                "Document Type to parse {WNMS_NodeB, WMNS_INode, WNMS_RncCn, WIPS_mRNb, WIPS_mRVcc, WIPS_mFB, WIPS_cNbP}. Default to 'All'");
        opt.addOption("a", "aggskip", false, "Skip Aggregation Step (useful for batch requests)");
        opt.addOption("b", "borgskip", false, "Skip Borg Extraction Step (useful if Borg data is redundant)");
        opt.addOption("w", "wnmsskip", false, "Skip WNMS Extraction Step (useful if WNMS is overflowing disk)");
        opt.addOption("s", "borgstartdate", false, "Start date for selected Borg data range");
        opt.addOption("f", "borgfinishdate", false, "End date for selected Borg data range");
        opt.addOption("v", "variablexsl", false, "Use dynamic-position XSL transformer (def static)");
        opt.addOption("n", "network", true,
                "Selecting GTA or TNZ sets: scrape vs file read, xmlns:HTML vs xmlns namespace (will add db when mature)");

        BasicParser bp = new BasicParser();
        CommandLine cl = bp.parse(opt, args);

        if (cl.hasOption('h')) {
            HelpFormatter f = new HelpFormatter();
            f.printHelp("OptionsTip", opt);
            ret = false;
            System.exit(0);
        } else {

            //Extraction
            /*
            if (cl.hasOption('e')){
               String lval = cl.getOptionValue("e");
               if ("c".compareTo(lval.toLowerCase())==0){
                  extractor = new Extractor();
               }
               else if ("t".compareTo(lval.toLowerCase())==0){
                  extractor = new Extractor();
               }
               else if ("g".compareTo(lval.toLowerCase())==0){
                  extractor = new Extractor();
               }
               else {
                  System.out.println("Extractor specifier ["+lval+"] incorrect, default to 'TAR'");
                  extractor = new Extractor();
               }
                    
            }
            else{
               System.out.println("Extractor not specified, default to 'TAR'");
               System.out.println("*** TESTING!\n*** NO DEFAULT EXTRACOR SET UP.\nPrecaution to prevent cross network pollution, exiting");
               System.exit(1);
            }
            */

            //Logging
            if (cl.hasOption('l')) {
                String lval = cl.getOptionValue("l");
                if ("f".compareTo(lval.toLowerCase()) == 0) {
                    lf = LogAppType.File;
                } else if ("c".compareTo(lval.toLowerCase()) == 0) {
                    lf = LogAppType.Console;
                } else if ("s".compareTo(lval.toLowerCase()) == 0) {
                    lf = LogAppType.Socket;
                } else {
                    System.out.println("Logging Appender [" + lval + "] incorrect, default to 'File'");
                }

            } else {
                System.out.println("Logging Appender not specified, default to 'File'");
            }

            //DateTime
            if (cl.hasOption('t')) {
                try {
                    tf = parseTimestamp(cl.getOptionValue("t"));
                } catch (java.text.ParseException pe) {
                    System.err.println("Date not specified correctly. " + pe + ". Using Default 'today'");
                }
            } else {
                System.out.println("Date not specified. Using Default 'today'");
            }

            //Database
            /*
            if (cl.hasOption('d') && DatabaseType.valueOf(cl.getOptionValue("d"))!=null){
               df = DatabaseType.valueOf(cl.getOptionValue("d"));
            }
            else {
               System.out.println("DatabaseType not specified");
               System.out.println("*** ATTENTION! ***\nNO DEFAULT DATABASE SET UP.\nOnly you can prevent cross network data pollution. Exiting");
               System.exit(1);
            }
            */

            //Document
            if (cl.hasOption('x')) {
                String xstr = cl.getOptionValue("x");
                if ("WNMS_All".compareTo(xstr) == 0) {
                    System.out.println("DocumentType WNMS_All {RncCn,INode,NodeB,INodeVcc}");
                    this.alldocs = EnumSet.of(DocumentType.WNMS_RncCn, DocumentType.WNMS_INode,
                            DocumentType.WNMS_NodeB, DocumentType.WNMS_INodeVcc);
                } else if ("WIPS_All".compareTo(xstr) == 0) {
                    System.out.println("DocumentType WIPS_All {cNbP,mFB,mRNb,mRVcc}");
                    this.alldocs = EnumSet.of(DocumentType.WIPS_cNbP, DocumentType.WIPS_mFB,
                            DocumentType.WIPS_mRNb, DocumentType.WIPS_mRVcc);
                } else {
                    //get what is requested, assuming selection is correct
                    System.out.println("DocumentType {" + xstr + "}");
                    this.alldocs = EnumSet.of(DocumentType.valueOf(xstr));
                }
            } else {
                //get all the docs, WNMS and WiPS
                System.out.println(
                        "DocumentType not specified, Default All {RncCn,INode,NodeB,INodeVcc,cNbP,mFB,mRNb,mRVcc}");
                this.alldocs = EnumSet.allOf(DocumentType.class);
            }

            /* Aggregation.
             * if -a then SKIP aggregation and therefore skip WiPS import. Makes no
             * sense to set -x WIPS option if also setting -a option
             */
            if (cl.hasOption('a')) {
                af = false;
            } else {
                System.out.println("Post insert-log/aggregation not specified. Default to TRUE");
            }

            //Borg (skip Borg processing, just do WNMS)
            if (cl.hasOption('b')) {
                bs = false;
            } else {
                System.out.println("Borg Skip not requested. Default to TRUE");

                //borg start
                if (cl.hasOption('s')) {
                    bsd = cl.getOptionValue("s");
                } else {
                    System.out.println("Borg startdate not specified. Default to Yesterday");
                }

                //borg finish
                if (cl.hasOption('f')) {
                    bfd = cl.getOptionValue("f");
                } else {
                    System.out.println("Borg finishdate not specified. Default to Today");
                }

            }

            //WNMS (skip WNMS processing, just do Borg)
            if (cl.hasOption('w')) {
                ws = false;
            } else {
                System.out.println("Process WNMS Source not specified. Default to TRUE");
            }

            //Variable position Static/Dynamic XSL transformer for WNMS
            if (cl.hasOption('v')) {
                vp = true;
            } else {
                System.out.println("Variable/Dynamic parser not requested, default to static");
            }

            //Namespace has subdeclaration xmlns:HTML
            if (cl.hasOption('n')) {
                String netw = cl.getOptionValue("n");
                if ("GTA".compareTo(netw) == 0) {
                    this.networktype = NetworkType.GTA;
                } else if ("TNZ".compareTo(netw) == 0) {
                    this.networktype = NetworkType.TNZ;
                } else {
                    System.out.println("Network Selection invalid: " + netw + ", Exiting");
                    System.exit(1);

                }
            } else {
                System.out.println("Network Selection required! Exiting");
                System.exit(1);
            }
        }
    } catch (ParseException e) {
        e.printStackTrace();
        System.exit(1);
    }

    this.wdl.addLoggingAppender(lf);
    this.setAggregateTables(af);
    this.setBorgStep(bs);
    this.setWNMSStep(ws);
    //if(xf!=null)this.alldocs = EnumSet.of(xf);
    this.setDatabaseType(df);
    this.setCalendar(tf);

    this.setBorgStartDate(bsd);
    this.setBorgFinishDate(bfd);

    this.setTransformerType(vp);

    jlog.info("LG:" + lf + ", DT:" + tf.getTime() + ", DB:" + df + ", DC:" + this.alldocs + ", AT:" + af
            + ", BS:" + bs + ", NT:" + networktype);
    System.out.println("LG:" + lf + ", DT:" + tf.getTime() + ", DB:" + df + ", DC:" + this.alldocs + ", AT:"
            + af + ", BS:" + bs + ", WS:" + ws + ", NT:" + networktype + ", VP:" + vp);

    return ret;
}

From source file:org.photovault.swingui.PhotoInfoEditor.java

private void createRightsUI() {
    JPanel pane = new JPanel();
    tabPane.addTab("Rights", pane);

    JLabel copyrightLabel = new JLabel("Copyright");
    JTextField copyrightField = createMvTextField("usageRights.copyright", 30);
    JLabel attributionLabel = new JLabel("Name for attribution");
    JTextField attributionField = createMvTextField("usageRights.attributionName", 30);
    JLabel attributionUrlLabel = new JLabel("Url for attribution");
    JTextField attributionUrlField = createMvTextField("usageRights.attributionUrl", 30);

    JLabel licenseLabel = new JLabel("License");
    List<License> licenses = new ArrayList();
    licenses.addAll(EnumSet.allOf(License.class));
    JComboBox licenseCombo = createMvComboBox("usageRights.license", licenses);

    // Tech note text
    JLabel termsLabel = new JLabel("Usage terms");
    JTextArea termsTextArea = createMvTextArea("usageRights.usageTerms", 5, 40);
    termsTextArea.setLineWrap(true);/*from ww  w . ja  v a 2  s .  c o m*/
    termsTextArea.setWrapStyleWord(true);
    JScrollPane termsScrollPane = new JScrollPane(termsTextArea);
    termsScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    Border termsBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    termsBorder = BorderFactory.createTitledBorder(termsBorder, "Usage terms");
    termsScrollPane.setBorder(termsBorder);

    GridBagLayout layout = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    pane.setLayout(layout);
    JLabel[] labels = { copyrightLabel, licenseLabel, attributionLabel, attributionUrlLabel };
    JComponent[] fields = { copyrightField, licenseCombo, attributionField, attributionUrlField };
    addLabelTextRows(labels, fields, layout, pane);
    pane.add(termsScrollPane);
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.BOTH;
    layout.setConstraints(termsScrollPane, c);
}