private boolean containsInProcessedModules(Collection<Module> modules, Module m, File projectRoot) { PathEntry pathEntry = m.getRulesRootPath(); if (!new File(m.getRulesRootPath().getPath()).isAbsolute()) { pathEntry = new PathEntry(new File(projectRoot, m.getRulesRootPath().getPath()).getAbsolutePath()); } for (Module module : modules) { PathEntry modulePathEntry = module.getRulesRootPath(); if (!new File(module.getRulesRootPath().getPath()).isAbsolute()) { modulePathEntry = new PathEntry(new File(projectRoot, module.getRulesRootPath().getPath()).getAbsolutePath()); } if (pathEntry.getPath().equals(modulePathEntry.getPath())) { return true; } } return false; }
public boolean isModuleWithWildcard(Module module) { PathEntry rulesRootPath = module.getRulesRootPath(); if (rulesRootPath != null) { String path = rulesRootPath.getPath(); return path.contains("*") || path.contains("?"); } return false; }
public ProjectDescriptor resolveProject(File folder) throws ProjectResolvingException { Map<String, Module> modules = new TreeMap<String, Module>(); try { ProjectDescriptor project = createDescriptor(folder); for (File f : folder.listFiles()) { if (!f.isHidden() && f.isFile() && FileTypeHelper.isExcelFile(f.getName())) { String name = FileUtils.removeExtension(f.getName()); if (!modules.containsKey(name)) { PathEntry rootPath = new PathEntry(f.getCanonicalFile().getAbsolutePath()); Module module = createModule(project, rootPath, name); modules.put(name, module); } else { if (log.isErrorEnabled()){ log.error("A module with the same name already exists: {}", name); } } } } project.setModules(new ArrayList<Module>(modules.values())); return project; } catch (IOException e) { throw new ProjectResolvingException(e); } }
public boolean isModuleWithWildcard(Module module) { PathEntry rulesRootPath = module.getRulesRootPath(); if (rulesRootPath != null) { String path = rulesRootPath.getPath(); return path.contains("*") || path.contains("?"); } return false; }
protected ProjectDescriptor createNewProject() { ProjectDescriptor project = new ProjectDescriptor(); project.setName(defaultProjectName != null ? defaultProjectName : getDisplayName()); List<PathEntry> classpath = new ArrayList<PathEntry>(); for (String path : defaultClasspaths) { classpath.add(new PathEntry(path)); } project.setClasspath(classpath); return project; }
public String getSources() { ProjectDescriptor currentProject = studio.getCurrentProjectDescriptor(); List<PathEntry> sourceList = currentProject.getClasspath(); if (sourceList != null) { StringBuilder sb = new StringBuilder(); for (PathEntry source : sourceList) { sb.append(source.getPath()).append(StringTool.NEW_LINE); } sources = sb.toString(); } return sources; }
private boolean containsInProcessedModules(Collection<Module> modules, Module m, File projectRoot) { PathEntry pathEntry = m.getRulesRootPath(); if (!new File(m.getRulesRootPath().getPath()).isAbsolute()) { pathEntry = new PathEntry(new File(projectRoot, m.getRulesRootPath().getPath()).getAbsolutePath()); } for (Module module : modules) { PathEntry modulePathEntry = module.getRulesRootPath(); if (!new File(module.getRulesRootPath().getPath()).isAbsolute()) { modulePathEntry = new PathEntry(new File(projectRoot, module.getRulesRootPath().getPath()).getAbsolutePath()); } if (pathEntry.getPath().equals(modulePathEntry.getPath())) { return true; } } return false; }
protected ProjectDescriptor createNewProject() { ProjectDescriptor project = new ProjectDescriptor(); project.setName(defaultProjectName != null ? defaultProjectName : getDisplayName()); List<PathEntry> classpath = new ArrayList<PathEntry>(); for (String path : defaultClasspaths) { classpath.add(new PathEntry(path)); } project.setClasspath(classpath); return project; }
public String getSources() { ProjectDescriptor currentProject = studio.getCurrentProjectDescriptor(); List<PathEntry> sourceList = currentProject.getClasspath(); if (sourceList != null) { StringBuilder sb = new StringBuilder(); for (PathEntry source : sourceList) { sb.append(source.getPath()).append(StringTool.NEW_LINE); } sources = sb.toString(); } return sources; }
private void postProcess(ProjectDescriptor descriptor, File projectDescriptorFile) throws IOException{ File projectRoot = projectDescriptorFile.getParentFile().getCanonicalFile(); descriptor.setProjectFolder(projectRoot); processModulePathPatterns(descriptor, projectRoot); for (Module module : descriptor.getModules()) { module.setProject(descriptor); if (module.getMethodFilter() == null) { module.setMethodFilter(new MethodFilter()); } if (module.getMethodFilter().getExcludes() == null) { module.getMethodFilter().setExcludes(new HashSet<String>()); } else { // Remove empty nodes module.getMethodFilter().getExcludes().removeAll(Arrays.asList("", null)); } if (module.getMethodFilter().getIncludes() == null) { module.getMethodFilter().setIncludes(new HashSet<String>()); } else { // Remove empty nodes module.getMethodFilter().getIncludes().removeAll(Arrays.asList("", null)); } if (!new File(module.getRulesRootPath().getPath()).isAbsolute()) { PathEntry absolutePath = new PathEntry(new File(projectRoot, module.getRulesRootPath().getPath()).getCanonicalFile().getAbsolutePath()); module.setRulesRootPath(absolutePath); } } }
public ProjectDescriptor resolveProject(File folder) throws ProjectResolvingException { Map<String, Module> modules = new TreeMap<String, Module>(); try { ProjectDescriptor project = createDescriptor(folder); for (File f : folder.listFiles()) { if (!f.isHidden() && f.isFile() && FileTypeHelper.isExcelFile(f.getName())) { String name = FileUtils.removeExtension(f.getName()); if (!modules.containsKey(name)) { PathEntry rootPath = new PathEntry(f.getCanonicalFile().getAbsolutePath()); Module module = createModule(project, rootPath, name); modules.put(name, module); } else { if (log.isErrorEnabled()){ log.error("A module with the same name already exists: {}", name); } } } } project.setModules(new ArrayList<Module>(modules.values())); return project; } catch (IOException e) { throw new ProjectResolvingException(e); } }
@Override public String getUrlForModule(Module module) { // TODO Add "internal-workbook" parameter instead of playing with "sheet" XmlRulesModule xmlRulesModule = (XmlRulesModule) module; String moduleURI = new File(xmlRulesModule.getRulesRootPath().getPath()).toURI().toString(); if (xmlRulesModule.getInternalModulePath().equals(TYPES_WORKBOOK)) { moduleURI += "?sheet=" + TYPES_SHEET; } return moduleURI; }
try { File projectFolder = module.getProject().getProjectFolder(); String uri = new File(projectFolder, module.getRulesRootPath().getPath()).getCanonicalFile() .toURI() .toURL() ExtensionModule extensionModule = new ZipFileXmlDeserializer(uri).deserialize(); for (LazyWorkbook workbook : extensionModule.getWorkbooks()) { PathEntry rulesRootPath = new PathEntry(new File(projectFolder, module.getRulesRootPath().getPath()).getPath());
public void editSources() { List<PathEntry> sourceList = new ArrayList<PathEntry>(); String[] sourceArray = sources.split(StringTool.NEW_LINE); if (CollectionUtils.isNotEmpty(sourceArray)) { for (String source : sourceArray) { if (StringUtils.isNotBlank(source)) { PathEntry sourcePath = new PathEntry(source); sourceList.add(sourcePath); } } } ProjectDescriptor projectDescriptor = studio.getCurrentProjectDescriptor(); ProjectDescriptor newProjectDescriptor = cloneProjectDescriptor(projectDescriptor); clean(newProjectDescriptor); newProjectDescriptor.setClasspath(!sourceList.isEmpty() ? sourceList : null); save(newProjectDescriptor); }