Package ro.isdc.wro.model.group

Examples of ro.isdc.wro.model.group.Group


        is(1));
  }

  private WroModel getModel() {
    WroModel model = new WroModel();
    Group group = new Group(TEST_GROUP);
    Resource js1 = Resource.create("a", ResourceType.JS);
    Resource js2 = Resource.create("b", ResourceType.JS);
    Resource css1 = Resource.create("c", ResourceType.CSS);

    group.setResources(Arrays.asList(js1, js2, css1));
    model.setGroups(Arrays.asList(group));

    return model;
  }
View Full Code Here


  @Override
  public List<String> getResources(ResourceType resourceType) {
   
    List<String> result = new ArrayList<String>();
   
    Group filteredGroup = group.collectResourcesOfType(resourceType);
    for (Resource resource: filteredGroup.getResources()) {
      String file = resource.getUri();
      result.add(file);
    }

    return result;
View Full Code Here

        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        Document doc = dBuilder.parse(sourcesXmlFile);

        final WroModel model = new WroModel();

        Group closureDepsGroup = new Group(GROUP_NAME_CLOSURE_DEPS);

        final NodeList includeNodes = doc.getElementsByTagName(INCLUDE_EL);

        for (int i = 0; i < includeNodes.getLength(); i++) {
            Element include = (Element) includeNodes.item(i);
            if (!include.hasAttribute(FILE_ATT)) {
                throw new AssertionError("include elements must have a " + FILE_ATT + " attribute");
            }

            Collection<IncludesStream> streams = null;
            try {
                streams = openIncludesStream(parentSourcesXmlFile, include.getAttribute(FILE_ATT));
                for (IncludesStream is : streams) {
                    InputStream stream = is.stream;
                    WroModel includedModel = createModel(is.locationLoadedFrom, stream);
                    for (Group group : includedModel.getGroups()) {
                        if (GROUP_NAME_CLOSURE_DEPS.equals(group.getName())) {
                            for (Resource resource : group.getResources()) {
                                closureDepsGroup.addResource(resource);
                            }
                        } else {
                            model.addGroup(group);
                        }
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (streams != null) {
                    for (IncludesStream stream : streams) {
                        IOUtils.closeQuietly(stream.stream);
                    }
                }
            }
        }

        final NodeList requireNodes = doc.getElementsByTagName(REQUIRE_EL);

        for (int i = 0; i < requireNodes.getLength(); i++) {
            Element require = (Element) requireNodes.item(i);
            loadGroupsUsingRequireDependencyManagement(require, model, closureDepsGroup);
        }
        if (!closureDepsGroup.getResources().isEmpty()) {
            model.addGroup(closureDepsGroup);
        }
        final NodeList declareNodes = doc.getElementsByTagName(DECLARATIVE_EL);

        for (int i = 0; i < declareNodes.getLength(); i++) {
View Full Code Here

        if (!declareEl.hasAttribute(DECLARATIVE_NAME_ATT)) {
            throw new AssertionError(DECLARATIVE_EL + " elements require a " + DECLARATIVE_NAME_ATT + " attribute.");
        }
        String name = declareEl.getAttribute(DECLARATIVE_NAME_ATT);

        Group group = new Group(name);
        for (int i = 0; i < jsSources.getLength(); i++) {
            final Element item = (Element) jsSources.item(i);
            final ResourceDesc desc = parseSource(item, defaultPathOnDisk);
            boolean isMinimized = !item.hasAttribute(MINIMIZED_ATT) || Boolean.parseBoolean(item.getAttribute(MINIMIZED_ATT));
            Resource resource = createResource(isMinimized, desc, ResourceType.JS);
            group.addResource(resource);
        }

        final NodeList cssSources = declareEl.getElementsByTagName(CSS_SOURCE_EL);

        for (int i = 0; i < cssSources.getLength(); i++) {
            final Element item = (Element) cssSources.item(i);
            final ResourceDesc desc = parseSource(item, defaultPathOnDisk);
            boolean isMinimized = !item.hasAttribute(MINIMIZED_ATT) || Boolean.parseBoolean(item.getAttribute(MINIMIZED_ATT));
            Resource resource = createResource(isMinimized, desc, ResourceType.CSS);
            group.addResource(resource);

        }

        model.addGroup(group);
View Full Code Here

                                                       "must have unique names");
                }

                cssGroups.add(groupId);

                final Group group;
                if (groups.containsKey(groupId)) {
                    group = groups.get(groupId);
                } else {
                    group = new Group(groupId);
                }

                boolean isMinimized = true;
                for (String s : notMinimized) {
                    if (file.getAbsolutePath().endsWith(s)) {
                        isMinimized = false;
                        break;
                    }
                }
                Resource resource = new Resource();
                resource.setMinimize(isMinimized);
                resource.setType(ResourceType.CSS);
                resource.setUri(file.toURI().toString());

                group.addResource(resource);
                if (!groups.containsKey(groupId)) {
                    model.addGroup(group);
                }
            }
        }
View Full Code Here

            dependencyManager, Group closureDepsGroup) {
        final Set<String> moduleIds = dependencyManager.getAllModuleIds();
        Map<String, Group> groupMap = new HashMap<String, Group>((int) (moduleIds.size() * 1.5));

        for (String moduleId : moduleIds) {
            Group group = new Group(moduleId);
            groupMap.put(moduleId, group);

            closureDepsGroup.addResource(ClosureDependencyUriLocator.createClosureDepResource(dependencyManager.getNode(moduleId)));
            final Collection<ClosureRequireDependencyManager.Node> deps = dependencyManager.getTransitiveDependenciesFor(moduleId, true);

            List<Resource> resources = new ArrayList<Resource>();
            for (ClosureRequireDependencyManager.Node dep : deps) {
                group.addResource(createResourceFrom(dep));
                addTemplateResourceFrom(resources, dep);
                closureDepsGroup.addResource(ClosureDependencyUriLocator.createClosureDepResource(dep));
            }

            group.addResource(createResourceFrom(dependencyManager.getNode(moduleId)));
            if(resources.size() > 0) {
                group.addResource(getTemplateResource(TemplatesUriLocator.URI_PREFIX_HEADER));
                for (Resource resource : resources) {
                    group.addResource(resource);
                }
                group.addResource(getTemplateResource(TemplatesUriLocator.URI_PREFIX_FOOTER));
            }
            model.addGroup(group);
        }

        return groupMap;
View Full Code Here

        final WroModel wroModel = createRequireModel(sourcesXml);

        final Collection<Group> groups = wroModel.getGroups();

        Group depsGroup = null;
        for (Group group : groups) {
            if (group.getName().equals(GeonetWroModelFactory.GROUP_NAME_CLOSURE_DEPS)) {
                assertNull("There should only be one deps group but found at least 2", depsGroup);
                depsGroup = group;
            }
        }

        assertNotNull(depsGroup);

        final List<Resource> resources = depsGroup.getResources();

        String jsTestBaseDirAsPath = jsTestBaseDir.replace('\\', '/');
        if (jsTestBaseDirAsPath.charAt(0) == '/') {
            jsTestBaseDirAsPath = jsTestBaseDirAsPath.substring(1);
        }
View Full Code Here

                            + "</sources>";

        final WroModel wroModel = createRequireModel(sourcesXml);

        assertEquals(1, wroModel.getGroups().size());
        final Group group = wroModel.getGroups().iterator().next();

        assertEquals("groupName", group.getName());
        List<Resource> resources = group.getResources();

        assertEquals(4, resources.size());

        List<String> resourceNames = new ArrayList<String>(resources.size());
        final UriLocatorFactory uriLocatorFactory = new GeonetworkMavenWrojManagerFactory().newUriLocatorFactory();
View Full Code Here

    @Before
    public void setupFixture() {
        WroModel wroModel = new WroModel();

        Group group_one = new Group("group_one");
        Group group_two = new Group("group_two");
        wroModel.setGroups(Arrays.asList(group_one, group_two));

        group_one.addResource(Resource.create("group_one_css_uri_one", ResourceType.CSS));
        group_one.addResource(Resource.create("group_one_css_uri_two", ResourceType.CSS));
        group_one.addResource(Resource.create("group_one_js_uri_one", ResourceType.JS));
        group_one.addResource(Resource.create("group_one_js_uri_two", ResourceType.JS));

        group_two.addResource(Resource.create("group_two_css_uri_one", ResourceType.CSS));
        group_two.addResource(Resource.create("group_two_css_uri_two", ResourceType.CSS));
        group_two.addResource(Resource.create("group_two_js_uri_one", ResourceType.JS));
        group_two.addResource(Resource.create("group_two_js_uri_two", ResourceType.JS));

        when(wroModelHolder.getWroModel()).thenReturn(wroModel);

        mockHttpServletRequest = new MockHttpServletRequest();
        mockHttpServletRequest.setQueryString("");
View Full Code Here

  private void configureMojoForModelWithImportedCssResource(final String importResource)
      throws Exception {
    final String parentResource = "parent.css";

    final WroModel model = new WroModel();
    model.addGroup(new Group("g1").addResource(Resource.create(parentResource)));
    when(mockLocator.locate(Mockito.anyString())).thenAnswer(answerWithContent(""));
    final String parentContent = String.format("@import url(%s)", importResource);
    when(mockLocator.locate(Mockito.eq(parentResource))).thenAnswer(answerWithContent(parentContent));

    victim = new Wro4jMojo() {
View Full Code Here

TOP

Related Classes of ro.isdc.wro.model.group.Group

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.