Java Code Examples for freemarker.ext.beans.StringModel#getWrappedObject()
The following examples show how to use
freemarker.ext.beans.StringModel#getWrappedObject() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IsFileADirectoryMethod.java From windup with Eclipse Public License 1.0 | 6 votes |
@Override public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException { ExecutionStatistics.get().begin(NAME); // Function arguments FileModel fileModel = null; // The file may *not* be null. if (arguments.size() >= 1) { StringModel fileArg = (StringModel) arguments.get(0); fileModel = (FileModel) fileArg.getWrappedObject(); } if (fileModel == null) { String errorMessage = "IsFileADirectoryMethod: No file present to check"; throw new WindupException(errorMessage); } Boolean result = fileModel.isDirectory(); ExecutionStatistics.get().end(NAME); return result; }
Example 2
Source File: GetNumberOfLibrariesMethod.java From windup with Eclipse Public License 1.0 | 6 votes |
@Override public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException { ExecutionStatistics.get().begin(NAME); // Function arguments ProjectModel projectModel = null; // The project. May *not* be null. All input applications should be passed into this method individually if (arguments.size() >= 1) { StringModel projectArg = (StringModel) arguments.get(0); projectModel = (ProjectModel) projectArg.getWrappedObject(); } if (projectModel == null) { String errorMessage = "GetNumberOfLibrariesMethod: No project present to count libraries"; throw new WindupException(errorMessage); } Integer result = countLibrariesInModel(this.graphContext, projectModel); ExecutionStatistics.get().end(NAME); return result; }
Example 3
Source File: GetTechReportPunchCardStatsMethod.java From windup with Eclipse Public License 1.0 | 6 votes |
@Override public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException { ExecutionStatistics.get().begin(NAME); // Function arguments ProjectModel projectModel = null; // The project. May be null -> all input applications. if (arguments.size() >= 1) { StringModel projectArg = (StringModel) arguments.get(0); projectModel = (ProjectModel) projectArg.getWrappedObject(); } MatrixAndAggregated result = computeProjectAndTagsMatrix(this.graphContext, projectModel); ExecutionStatistics.get().end(NAME); return result; }
Example 4
Source File: ProjectModelToApplicationIndexMethod.java From windup with Eclipse Public License 1.0 | 6 votes |
@Override public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException { ExecutionStatistics.get().begin(NAME); if (arguments.size() != 1) { throw new TemplateModelException("Error, method expects one argument (ProjectModel)"); } StringModel stringModelArg = (StringModel) arguments.get(0); if (stringModelArg == null) { throw new IllegalArgumentException("FreeMarker Method " + NAME + " called with null project model"); } ProjectModel projectModel = (ProjectModel) stringModelArg.getWrappedObject(); ApplicationReportIndexModel index = service.getApplicationReportIndexForProjectModel(projectModel); if (index == null) { LOG.warning("Could not find an application index for project model: " + projectModel.getName() + " (Vertex ID: " + projectModel.getElement().id() + ")"); } ExecutionStatistics.get().end(NAME); return index; }
Example 5
Source File: SortTechUsageStatsMethod.java From windup with Eclipse Public License 1.0 | 6 votes |
@Override public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException { ExecutionStatistics.get().begin(NAME); // Function arguments if (arguments.size() > 1) throw new TemplateModelException("Expected 0 or 1 argument - project."); // The project. May be null -> count from all applications. ProjectModel application = null; if (arguments.size() == 1) { StringModel projectArg = (StringModel) arguments.get(0); if (null != projectArg) application = (ProjectModel) projectArg.getWrappedObject(); } TechReportService.TechStatsMatrix matrix = techReportService.getTechStatsMap(application); ExecutionStatistics.get().end(NAME); return matrix; }
Example 6
Source File: ProjectModelToSha1.java From windup with Eclipse Public License 1.0 | 6 votes |
@Override public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException { Object result = null; ExecutionStatistics.get().begin(NAME); if (arguments.size() != 1) { throw new TemplateModelException("Error, method expects one argument (ProjectModel)"); } StringModel stringModelArg = (StringModel) arguments.get(0); if (stringModelArg == null) { throw new IllegalArgumentException("FreeMarker Method " + NAME + " called with null project model"); } ProjectModel projectModel = (ProjectModel) stringModelArg.getWrappedObject(); if(projectModel.getRootFileModel() instanceof IdentifiedArchiveModel) { result = projectModel.getRootFileModel().getSHA1Hash(); } ExecutionStatistics.get().end(NAME); return result; }
Example 7
Source File: GetClassificationForFile.java From windup with Eclipse Public License 1.0 | 6 votes |
@Override public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException { ExecutionStatistics.get().begin(NAME); if (arguments.size() != 1) { throw new TemplateModelException("Error, method expects one argument (" + FileModel.class.getSimpleName() + ")"); } StringModel stringModelArg = (StringModel) arguments.get(0); FileModel fileModel = (FileModel) stringModelArg.getWrappedObject(); ClassificationService classificationService = new ClassificationService(context); Iterable<ClassificationModel> result = classificationService.getClassifications(fileModel); ExecutionStatistics.get().end(NAME); return result; }
Example 8
Source File: GetArchiveSHA1ToPathsMapperMethod.java From windup with Eclipse Public License 1.0 | 5 votes |
@Override public Object exec(List arguments) throws TemplateModelException { ExecutionStatistics.get().begin(NAME); if (arguments.size() < 1) { throw new TemplateModelException("Error, method expects at least one argument (" + ProjectModel.class.getSimpleName() + ")"); } StringModel stringModelArg = (StringModel) arguments.get(0); ProjectModelTraversal traversal = (ProjectModelTraversal) stringModelArg.getWrappedObject(); ArchiveSHA1ToFilePathMapper mapper = new ArchiveSHA1ToFilePathMapper(traversal); ExecutionStatistics.get().end(NAME); return mapper; }
Example 9
Source File: GetProblemSummariesMethod.java From windup with Eclipse Public License 1.0 | 5 votes |
@Override public Object exec(List arguments) throws TemplateModelException { if (arguments.isEmpty()) throw new TemplateModelException("Method " + getMethodName() + " requires the following parameters (GraphRewrite event, ProjectModel project, Set<String> includeTags, Set<String> excludeTags)"); // Gets the graph rewrite event final GraphRewrite event = (GraphRewrite)((StringModel)arguments.get(0)).getWrappedObject(); // Get the project if one was passed in final ProjectModel projectModel; StringModel projectModelArg = (StringModel) arguments.get(1); if (projectModelArg == null) projectModel = null; else projectModel = (ProjectModel) projectModelArg.getWrappedObject(); Set<String> includeTags = FreeMarkerUtil.simpleSequenceToSet((SimpleSequence) arguments.get(2)); Set<String> excludeTags = FreeMarkerUtil.simpleSequenceToSet((SimpleSequence) arguments.get(3)); Set<ProjectModel> projectModels = getProjects(projectModel); Map<IssueCategoryModel, List<ProblemSummary>> problemSummariesOriginal = ProblemSummaryService.getProblemSummaries(event.getGraphContext(), projectModels, includeTags, excludeTags); // Convert the keys to String to make Freemarker happy Comparator<IssueCategoryModel> severityComparator = new IssueCategoryModel.IssueSummaryPriorityComparator(); Map<IssueCategoryModel, List<ProblemSummary>> problemSummaries = new TreeMap<>(severityComparator); problemSummaries.putAll(problemSummariesOriginal); Map<String, List<ProblemSummary>> primarySummariesByString = new LinkedHashMap<>(problemSummariesOriginal.size()); for (Map.Entry<IssueCategoryModel, List<ProblemSummary>> entry : problemSummaries.entrySet()) { String severityString = entry.getKey() == null ? null : entry.getKey().getName(); primarySummariesByString.put(severityString, entry.getValue()); } return primarySummariesByString; }
Example 10
Source File: AbstractGetPrettyPathForFile.java From windup with Eclipse Public License 1.0 | 5 votes |
@Override public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException { ExecutionStatistics.get().begin(NAME); try { if (arguments.size() != 1) { throw new TemplateModelException("Error, method expects one argument (FileModel)"); } StringModel stringModelArg = (StringModel) arguments.get(0); FileModel fileModel = (FileModel) stringModelArg.getWrappedObject(); if (fileModel instanceof JavaClassFileModel) { return getPath((JavaClassFileModel) fileModel); } else if (fileModel instanceof ReportResourceFileModel) { return getPath((ReportResourceFileModel) fileModel); } else if (fileModel instanceof JavaSourceFileModel) { return getPath((JavaSourceFileModel) fileModel); } else { return getPath(fileModel); } } finally { ExecutionStatistics.get().end(NAME); } }
Example 11
Source File: IsReportableFile.java From windup with Eclipse Public License 1.0 | 5 votes |
@Override public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException { ExecutionStatistics.get().begin(NAME); try { if (arguments.size() != 3) { throw new TemplateModelException("Error, method expects one argument (FileModel, includeTags:Set<String>, excludeTags:Set<String>)"); } StringModel stringModelArg = (StringModel) arguments.get(0); FileModel fileModel = (FileModel) stringModelArg.getWrappedObject(); Set<String> includeTags = FreeMarkerUtil.simpleSequenceToSet((SimpleSequence) arguments.get(1)); Set<String> excludeTags = FreeMarkerUtil.simpleSequenceToSet((SimpleSequence) arguments.get(2)); SourceReportModel result = sourceReportService.getSourceReportForFileModel(fileModel); if (result == null) return false; return TagUtil.hasHintsOrClassificationsWithRelevantTags(result.getSourceFileModel(), includeTags, excludeTags); } finally { ExecutionStatistics.get().end(NAME); } }
Example 12
Source File: Sha1HexMethod.java From windup with Eclipse Public License 1.0 | 5 votes |
@Override public String exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException { if (arguments.size() != 1) { throw new TemplateModelException( "Error, method expects one argument (FileModel)"); } StringModel stringModel = (StringModel) arguments.get(0); FileModel fileModel = (FileModel) stringModel.getWrappedObject(); return !fileModel.isDirectory() ? fileModel.getSHA1Hash() : DigestUtils.sha1Hex(fileModel.getFileName()); }
Example 13
Source File: GetRuleExecutionResults.java From windup with Eclipse Public License 1.0 | 5 votes |
@Override public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException { ExecutionStatistics.get().begin(NAME); if (arguments.size() != 1) { throw new TemplateModelException("Error, method expects one argument (AbstractRuleProvider)"); } StringModel stringModelArg = (StringModel) arguments.get(0); AbstractRuleProvider ruleProvider = (AbstractRuleProvider) stringModelArg.getWrappedObject(); List<RuleExecutionInformation> result = RuleExecutionResultsListener.instance(this.event).getRuleExecutionInformation(ruleProvider); ExecutionStatistics.get().end(NAME); return result; }
Example 14
Source File: GetProjectTraversalMethod.java From windup with Eclipse Public License 1.0 | 5 votes |
@Override public Object exec(List arguments) throws TemplateModelException { ExecutionStatistics.get().begin(NAME); if (arguments.size() < 1) { throw new TemplateModelException("Error, method expects at least one argument (" + ProjectModel.class.getSimpleName() + ")"); } StringModel stringModelArg = (StringModel) arguments.get(0); ProjectModel projectModel = (ProjectModel) stringModelArg.getWrappedObject(); String traversalStrategyString = ALL; if (arguments.size() > 1) traversalStrategyString = ((SimpleScalar)arguments.get(1)).getAsString(); TraversalStrategy traversalStrategy; if (traversalStrategyString == null) traversalStrategyString = ALL; switch (traversalStrategyString) { case ONLY_ONCE: traversalStrategy = new OnlyOnceTraversalStrategy(); break; case SHARED: traversalStrategy = new SharedLibsTraversalStrategy(); break; default: Logger.getLogger(GetProjectTraversalMethod.class.getName()).warning("Unknown strategy name: " + traversalStrategyString); case ALL: traversalStrategy = new AllTraversalStrategy(); break; } ProjectModelTraversal traversal = new ProjectModelTraversal(projectModel, traversalStrategy); ExecutionStatistics.get().end(NAME); return traversal; }
Example 15
Source File: GetEffortForFile.java From windup with Eclipse Public License 1.0 | 5 votes |
@Override public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException { ExecutionStatistics.get().begin(NAME); if (arguments.size() != 1) { throw new TemplateModelException("Error, method expects one argument (FileModel)"); } StringModel fileModelArg = (StringModel) arguments.get(0); FileModel fileModel = (FileModel) fileModelArg.getWrappedObject(); Object result = classificationService.getMigrationEffortPoints(fileModel) + inlineHintService.getMigrationEffortPoints(fileModel); ExecutionStatistics.get().end(NAME); return result; }
Example 16
Source File: GetTechnologyTagsForFile.java From windup with Eclipse Public License 1.0 | 5 votes |
@Override public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException { ExecutionStatistics.get().begin(NAME); if (arguments.size() != 1) { throw new TemplateModelException("Error, method expects one argument (" + FileModel.class.getSimpleName() + ")"); } StringModel stringModelArg = (StringModel) arguments.get(0); FileModel fileModel = (FileModel) stringModelArg.getWrappedObject(); Iterable<TechnologyTagModel> result = new TechnologyTagService(this.context).findTechnologyTagsForFile(fileModel); ExecutionStatistics.get().end(NAME); return result; }
Example 17
Source File: RenderLinkDirective.java From windup with Eclipse Public License 1.0 | 4 votes |
@Override public void execute(Environment env, @SuppressWarnings("rawtypes") Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { final Writer writer = env.getOut(); StringModel stringModel = (StringModel) params.get(MODEL); SimpleScalar defaultTextModel = (SimpleScalar) params.get(TEXT); String defaultText = defaultTextModel == null ? null : defaultTextModel.getAsString(); if (stringModel == null || stringModel.getWrappedObject() == null) { if (StringUtils.isNotBlank(defaultText)) writer.append(defaultText); else { writer.append("unknown"); LOG.warning("Failed to resolve name or text for " + getClass().getName() + ". " + env); } return; } StringModel projectStringModel = (StringModel) params.get(PROJECT); ProjectModel project = null; if (projectStringModel != null && projectStringModel.getWrappedObject() instanceof ProjectModel) project = (ProjectModel)projectStringModel.getWrappedObject(); Object model = stringModel.getWrappedObject(); LayoutType layoutType = resolveLayoutType(params); String cssClass = resolveCssClass(params); if (model instanceof FileLocationModel) { processFileLocationModel(writer, cssClass, project, (FileLocationModel) model, defaultText); } else if (model instanceof FileModel) { processFileModel(writer, cssClass, project, (FileModel) model, defaultText); } else if (model instanceof JavaClassModel) { processJavaClassModel(writer, cssClass, project, (JavaClassModel) model, defaultText); } else if (model instanceof LinkableModel) { processLinkableModel(writer, layoutType, cssClass, project, (LinkableModel) model, defaultText); } else { throw new TemplateException("Object type not permitted: " + model.getClass().getSimpleName(), env); } }
Example 18
Source File: DirectivesUtils.java From onetwo with Apache License 2.0 | 4 votes |
public static RequestContext getRequestContext(Environment env){ StringModel val = (StringModel) getVariable(env, REQUEST_CONTEX, true); return (RequestContext)val.getWrappedObject(); }
Example 19
Source File: GetEffortCountForProjectByIssueCategoryMethod.java From windup with Eclipse Public License 1.0 | 4 votes |
@Override public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException { ExecutionStatistics.get().begin(NAME); if (arguments.size() < 3) { throw new TemplateModelException( "Error, method expects at least three arguments (event:GraphRewrite, projectModelTraversal:ProjectModelTraversal, recursive:Boolean, [includeTags:Set<String>]. [excludeTags:Set<String>])"); } GraphRewrite event = (GraphRewrite)((StringModel)arguments.get(0)).getWrappedObject(); StringModel projectModelTraversalArg = (StringModel) arguments.get(1); ProjectModelTraversal traversal = (ProjectModelTraversal) projectModelTraversalArg.getWrappedObject(); TemplateBooleanModel recursiveBooleanModel = (TemplateBooleanModel) arguments.get(2); boolean recursive = recursiveBooleanModel.getAsBoolean(); Set<String> includeTags = Collections.emptySet(); if (arguments.size() >= 4) { includeTags = FreeMarkerUtil.simpleSequenceToSet((SimpleSequence) arguments.get(3)); } Set<String> excludeTags = Collections.emptySet(); if (arguments.size() >= 5) { excludeTags = FreeMarkerUtil.simpleSequenceToSet((SimpleSequence) arguments.get(4)); } Map<IssueCategoryModel, Integer> classificationEffortDetails = classificationService.getMigrationEffortBySeverity(event, traversal, includeTags, excludeTags, Collections.emptySet(), recursive); Map<IssueCategoryModel, Integer> hintEffortDetails = inlineHintService.getMigrationEffortBySeverity(event, traversal, includeTags, excludeTags, Collections.emptySet(), recursive); Map<IssueCategoryModel, Integer> results = new TreeMap<>(new IssueCategoryModel.IssueSummaryPriorityComparator()); addAllIncidents(results, classificationEffortDetails); addAllIncidents(results, hintEffortDetails); ExecutionStatistics.get().end(NAME); return results; }
Example 20
Source File: RenderApplicationPieChartDirective.java From windup with Eclipse Public License 1.0 | 4 votes |
@Override public void execute(Environment env, @SuppressWarnings("rawtypes") Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { StringModel projectStringModel = (StringModel) params.get("project"); ProjectModel projectModel = null; if (projectStringModel != null) projectModel = (ProjectModel) projectStringModel.getWrappedObject(); StringModel projectTraversalStringModel = (StringModel) params.get("projectTraversal"); ProjectModelTraversal projectTraversal = null; if (projectTraversalStringModel != null) projectTraversal = (ProjectModelTraversal) projectTraversalStringModel.getWrappedObject(); if (projectModel != null && projectTraversal != null) throw new WindupException(NAME + " both 'project' and 'projectTraversal' were specified. Only one of these values should be specified."); else if (projectModel == null && projectTraversal == null) throw new WindupException(NAME + " neither 'project' nor 'projectTraversal' were specified. At least one of these must be specified."); TemplateBooleanModel recursiveBooleanModel = (TemplateBooleanModel) params.get("recursive"); boolean recursive = recursiveBooleanModel.getAsBoolean(); SimpleScalar elementIDStringModel = (SimpleScalar) params.get("elementID"); String elementID = elementIDStringModel.getAsString(); Set<String> includeTags = FreeMarkerUtil.simpleSequenceToSet((SimpleSequence) params.get("includeTags")); Set<String> excludeTags = FreeMarkerUtil.simpleSequenceToSet((SimpleSequence) params.get("excludeTags")); TypeReferenceService typeReferenceService = new TypeReferenceService(context); Map<String, Integer> data; if (projectModel != null) data = typeReferenceService.getPackageUseFrequencies(projectModel, includeTags, excludeTags, 2, recursive); else data = typeReferenceService.getPackageUseFrequencies(projectTraversal, includeTags, excludeTags, 2, recursive); if (data.keySet().size() > 0) { drawPie(env.getOut(), data, elementID); } else { // if we aren't drawing a pie, remove the element that would have held it Writer writer = env.getOut(); writer.append("<script type='text/javascript'>"); writer.append("$('#" + elementID + "').parent().remove()"); writer.append("</script>"); } }