Example usage for java.lang Module Module

List of usage examples for java.lang Module Module

Introduction

In this page you can find the example usage for java.lang Module Module.

Prototype

Module

Source Link

Usage

From source file:com.healthcit.cacure.model.ModuleTest.java

@Test(expected = PersistenceException.class)
public void testNotNullAuthor() {
    Module module = new Module();
    module.setAuthor(null);//from   w  ww . ja  v  a  2  s . c  o  m

    em.persist(module);
    em.flush();
}

From source file:com.healthcit.cacure.model.ModuleTest.java

@Test
public void testStatuses() {
    Module module = new Module();
    assertEquals(ModuleStatus.IN_PROGRESS, module.getStatus());

    //      Ignored statuses
    module.setStatus(null);/*from ww w  . ja  v  a 2s  . c om*/
    assertEquals(ModuleStatus.IN_PROGRESS, module.getStatus());
    module.setStatus(ModuleStatus.QUESTION_LIBRARY);
    assertEquals(ModuleStatus.IN_PROGRESS, module.getStatus());
    module.setStatus(ModuleStatus.FORM_LIBRARY);
    assertEquals(ModuleStatus.IN_PROGRESS, module.getStatus());

    //      Allowed statuses      
    module.setStatus(ModuleStatus.IN_PROGRESS);
    assertEquals(ModuleStatus.IN_PROGRESS, module.getStatus());
    module.setStatus(ModuleStatus.APPROVED_FOR_PILOT);
    assertEquals(ModuleStatus.APPROVED_FOR_PILOT, module.getStatus());
    module.setStatus(ModuleStatus.APPROVED_FOR_PRODUCTION);
    assertEquals(ModuleStatus.APPROVED_FOR_PRODUCTION, module.getStatus());
    module.setStatus(ModuleStatus.RELEASED);
    assertEquals(ModuleStatus.RELEASED, module.getStatus());
}

From source file:org.metamorphosis.core.ModuleManager.java

private void monitorRoot(final File root) {
    FileMonitor monitor = new FileMonitor(root);
    monitor.addListener(new FileListener() {

        @Override/*w w  w  .j a v  a 2s .  c o  m*/
        public void onCreated(String file) {
            File folder = new File(root + "/" + file);
            if (folder.isDirectory()) {
                logger.log(Level.INFO, "adding module  : " + folder.getName());
                final Module module = new Module();
                module.setFolder(folder);
                initModule(module);
                addModule(module);
                monitorModule(module);
            }
        }

        @Override
        public void onDeleted(String file) {
            Module module = getModuleById(file);
            if (module != null) {
                logger.log(Level.INFO, "removing module  : " + module.getName());
                removeModule(module);
            }
        }

    });
    monitor.watch();
}

From source file:com.healthcit.cacure.model.ModuleTest.java

@Test
public void testNewForm() {
    Module module = new Module();
    BaseForm newForm = module.newForm();
    assertNotNull(newForm);//from w ww  .  ja va2s . c  o  m
    assertTrue(newForm instanceof QuestionnaireForm);
    assertEquals(module, newForm.getModule());
}

From source file:com.healthcit.cacure.model.ModuleTest.java

@Test
@DataSet("classpath:users_roles_dataset.xml")
public void testIsNew() {
    Module module = new Module();
    module.setAuthor(em.find(UserCredentials.class, 1L));
    assertTrue(module.isNew());// w w  w . j a v a  2  s.  com

    em.persist(module);
    assertFalse(module.isNew());
}

From source file:org.etudes.component.app.melete.MeleteImportServiceImpl.java

public int mergeAndBuildModules(Document ArchiveDoc, String unZippedDirPath, String fromSiteId)
        throws Exception {
    if (logger.isDebugEnabled())
        logger.debug("Entering mergeAndBuildModules");

    int count = 0;
    try {// w ww  .j  a v  a2s  .  com
        Element rootEle = ArchiveDoc.getRootElement();

        Map uris = new HashMap();
        uris.put("imscp", DEFAULT_NAMESPACE_URI);
        uris.put("imsmd", IMSMD_NAMESPACE_URI);

        // organizations
        List elements = rootEle.selectNodes("//organization/item");
        logger.debug("sz of elements is" + elements.size());
        count = elements.size();
        for (Iterator iter = elements.iterator(); iter.hasNext();) {
            Element element = (Element) iter.next();

            //build module
            Module module = new Module();
            boolean keywords = false;
            boolean descr = false;
            for (Iterator iter1 = element.elementIterator(); iter1.hasNext();) {
                Element childele = (Element) iter1.next();

                if (childele.getName().equals("title"))
                    buildModuleTitle(childele, module);
                if (childele.getName().equals("imsmd:lom")) {
                    List<Element> modulegeneralList = childele.elements();
                    List moduleMetadataList = modulegeneralList.get(0).elements();

                    for (Iterator iter2 = moduleMetadataList.iterator(); iter2.hasNext();) {
                        Element metaElement = (Element) iter2.next();

                        if (metaElement.getName().equals("imsmd:description"))
                            descr = buildModuleDescription(metaElement, module);
                        if (!descr)
                            module.setDescription("    ");
                        if (metaElement.getName().equals("imsmd:keyword"))
                            keywords = buildModuleKeyword(metaElement, module);
                        if (!keywords)
                            module.setKeywords(module.getTitle());
                    }
                }

            }
            createModule(module, fromSiteId);
            // build sections

            sectionUtil = new SubSectionUtilImpl();
            Document seqDocument = sectionUtil.createSubSection4jDOM();

            for (Iterator iter3 = element.elementIterator("item"); iter3.hasNext();) {
                Element itemelement = (Element) iter3.next();

                if (itemelement.attributeValue("identifier").startsWith("NEXTSTEPS"))
                    mergeWhatsNext(itemelement, ArchiveDoc, module, unZippedDirPath);
                else
                    mergeSection(itemelement, ArchiveDoc, module, addBlankSection(null, seqDocument),
                            unZippedDirPath, seqDocument, fromSiteId);
            }

            // update module seqXml
            logger.debug("checking seqXML now at the end of buildModule process" + seqDocument.asXML());
            module.setSeqXml(seqDocument.asXML());
            moduleDB.updateModule(module);

        }
    } catch (Exception e) {
        // no organization tag so create one flat module
        //   e.printStackTrace();
    }

    if (logger.isDebugEnabled())
        logger.debug("Exiting mergeAndBuildModules");
    return count;
}

From source file:com.healthcit.cacure.model.ModuleTest.java

@Test
public void testIsLibrary() {
    Module module = new Module();
    assertFalse(module.isLibrary());
}

From source file:com.healthcit.cacure.model.ModuleTest.java

@Test
public void testIsEditable() {
    Module module = new Module();
    assertTrue(module.isEditable());/*  w  w  w  .j a  v a2s  .  co  m*/
    module.setStatus(ModuleStatus.IN_PROGRESS);
    assertTrue(module.isEditable());
    module.setStatus(ModuleStatus.APPROVED_FOR_PILOT);
    assertFalse(module.isEditable());
    module.setStatus(ModuleStatus.APPROVED_FOR_PRODUCTION);
    assertFalse(module.isEditable());
    module.setStatus(ModuleStatus.RELEASED);
    assertFalse(module.isEditable());
}

From source file:org.cruxframework.crux.core.rebind.module.Modules.java

/**
 * /*from   w w  w .  j ava 2s .  com*/
 * @param templateId
 * @param template
 */
protected Module registerModule(URL moduleDescriptor, String moduleFullName, Document moduleDocument) {
    Module module;
    ;
    if (moduleAliases.containsKey(moduleFullName)) {
        module = getModuleEager(moduleFullName);
        try {
            if (!URLUtils.isIdenticResource(moduleDescriptor, module.getDescriptorURL(),
                    moduleFullName + ".gwt.xml")) {
                throw new ModuleException(
                        "Duplicated module descriptor. Module [" + moduleFullName + "] is already registered.");
            }
        } catch (Exception e) {
            logger.error("Erro : moduleName[" + moduleFullName + "], module=" + module, e);
        }
    } else {
        module = new Module();

        Element element = moduleDocument.getDocumentElement();

        module.setFullName(moduleFullName);
        module.setName(getModuleName(moduleFullName, element));
        module.setSources(getModuleSources(element));
        module.setPublicPaths(getModulePublicPaths(element));
        module.setRootPath(getModuleRootPath(moduleFullName));
        module.setInherits(getModuleInherits(element));
        module.setDescriptorURL(moduleDescriptor);

        URL location = module.getDescriptorURL();
        location = URLResourceHandlersRegistry.getURLResourceHandler(location.getProtocol())
                .getParentDir(location);
        module.setLocation(location);

        modules.put(module.getName(), module);
        moduleAliases.put(moduleFullName, module.getName());
    }
    return module;
}

From source file:org.jahia.modules.modulemanager.forge.ForgeService.java

public List<Module> loadModules() {
    if (flushModules || (lastModulesLoad + loadModulesDelay) < new Date().getTime()) {
        modules.clear();//from  ww w.j a  v  a2s.  com
        for (Forge forge : forges) {
            String url = forge.getUrl() + "/contents/modules-repository.moduleList.json";
            Map<String, String> headers = new HashMap<String, String>();
            if (!StringUtils.isEmpty(forge.getUser())) {
                headers.put("Authorization",
                        "Basic " + Base64.encode((forge.getUser() + ":" + forge.getPassword()).getBytes()));
            }
            headers.put("accept", "application/json");

            String jsonModuleList = httpClientService.executeGet(url, headers);
            try {
                JSONArray modulesRoot = new JSONArray(jsonModuleList);

                JSONArray moduleList = modulesRoot.getJSONObject(0).getJSONArray("modules");
                for (int i = 0; i < moduleList.length(); i++) {
                    boolean add = true;

                    final JSONObject moduleObject = moduleList.getJSONObject(i);
                    for (Module m : modules) {
                        if (StringUtils.equals(m.getId(), moduleObject.getString("name"))
                                && StringUtils.equals(m.getGroupId(), moduleObject.getString("groupId"))) {
                            add = false;
                            break;
                        }
                    }
                    if (add) {
                        final JSONArray moduleVersions = moduleObject.getJSONArray("versions");

                        SortedMap<Version, JSONObject> sortedVersions = new TreeMap<Version, JSONObject>();

                        final Version jahiaVersion = new Version(Jahia.VERSION);

                        for (int j = 0; j < moduleVersions.length(); j++) {
                            JSONObject object = moduleVersions.getJSONObject(j);
                            Version version = new Version(object.getString("version"));
                            Version requiredVersion = new Version(StringUtils
                                    .substringAfter(object.getString("requiredVersion"), "version-"));
                            if (requiredVersion.compareTo(jahiaVersion) <= 0) {
                                sortedVersions.put(version, object);
                            }
                        }
                        if (!sortedVersions.isEmpty()) {
                            Module module = new Module();
                            JSONObject versionObject = sortedVersions.get(sortedVersions.lastKey());
                            module.setRemoteUrl(moduleObject.getString("remoteUrl"));
                            module.setRemotePath(moduleObject.getString("path"));
                            if (moduleObject.has("icon")) {
                                module.setIcon(moduleObject.getString("icon"));
                            }
                            module.setVersion(versionObject.getString("version"));
                            module.setName(moduleObject.getString("title"));
                            module.setId(moduleObject.getString("name"));
                            module.setGroupId(moduleObject.getString("groupId"));
                            module.setDownloadUrl(versionObject.getString("downloadUrl"));
                            module.setForgeId(forge.getId());
                            modules.add(module);
                        }
                    }
                }
            } catch (JSONException e) {
                logger.error("unable to parse JSON return string for " + url);
            } catch (Exception e) {
                logger.error("unable to get store information" + e.getMessage());
            }
        }
        Collections.sort(modules);
        lastModulesLoad = new Date().getTime();
        flushModules = false;
    }

    return modules;
}