public static String removeExtension(final Path path, final String extension) { if (path == null) { return null; } final String fileName = path.getFileName(); return removeExtension(fileName, extension); }
public static String removeExtension(final Path path, final ResourceTypeDefinition type) { if (path == null) { return null; } final String fileName = path.getFileName(); if (type == null) { return fileName; } return removeExtension(path, type.getSuffix()); }
@WorkbenchPartTitle public String getTitleText() { String fileName = FileNameUtil.removeExtension(versionRecordManager.getCurrentPath(), resourceType); return Constants.INSTANCE.form_modeler_title(fileName); }
@Override @WorkbenchPartTitle public String getTitleText() { String fileName = FileNameUtil.removeExtension(versionRecordManager.getCurrentPath(), resourceType); return translationService.format(FormEditorConstants.FormEditorPresenterTitle, fileName); }
@Test public void removeExtensionFromFileNameTest() { assertNull(removeExtension((String) null, ".java")); assertEquals("file.java", removeExtension("file.java", null)); assertEquals("file.java", removeExtension("file.java", "")); assertEquals("file", removeExtension("file.java", "java")); }
@Test public void removeExtensionFromPathTest() { final Path path = mock(Path.class); doReturn("file.java").when(path).getFileName(); assertNull(removeExtension((Path) null, ".java")); assertEquals("file.java", removeExtension(path, (String) null)); assertEquals("file.java", removeExtension(path, "")); assertEquals("file", removeExtension(path, "java")); }
@Test public void removeExtensionFromPathTest() { final Path path = mock(Path.class); doReturn("file.java").when(path).getFileName(); assertNull(removeExtension((Path) null, ".java")); assertEquals("file.java", removeExtension(path, (String) null)); assertEquals("file.java", removeExtension(path, "")); assertEquals("file", removeExtension(path, "java")); }
@Test public void removeExtensionFromFileNameTest() { assertNull(removeExtension((String) null, ".java")); assertEquals("file.java", removeExtension("file.java", null)); assertEquals("file.java", removeExtension("file.java", "")); assertEquals("file", removeExtension("file.java", "java")); }
@Test public void removeResourceTypeDefinitionSuffixFromPathTest() { final Path path = mock(Path.class); doReturn("file.java").when(path).getFileName(); final ResourceTypeDefinition resourceTypeDefinition = mock(ResourceTypeDefinition.class); doReturn("java").when(resourceTypeDefinition).getSuffix(); assertNull(removeExtension((Path) null, ".java")); assertEquals("file", removeExtension(path, resourceTypeDefinition)); } }
@Test public void removeResourceTypeDefinitionSuffixFromPathTest() { final Path path = mock(Path.class); doReturn("file.java").when(path).getFileName(); final ResourceTypeDefinition resourceTypeDefinition = mock(ResourceTypeDefinition.class); doReturn("java").when(resourceTypeDefinition).getSuffix(); assertNull(removeExtension((Path) null, ".java")); assertEquals("file", removeExtension(path, resourceTypeDefinition)); } }
@Override public GuidedDecisionTree load(final Path path) { try { final String drl = ioService.readAllString(Paths.convert(path)); final String baseFileName = FileNameUtil.removeExtension(path, resourceType); final PackageDataModelOracle oracle = dataModelService.getDataModel(path); final GuidedDecisionTree model = GuidedDecisionTreeDRLPersistence.getInstance().unmarshal(drl, baseFileName, oracle); return model; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@Override public GuidedDecisionTree load(final Path path) { try { final String drl = ioService.readAllString(Paths.convert(path)); final String baseFileName = FileNameUtil.removeExtension(path, resourceType); final PackageDataModelOracle oracle = dataModelService.getDataModel(path); final GuidedDecisionTree model = GuidedDecisionTreeDRLPersistence.getInstance().unmarshal(drl, baseFileName, oracle); return model; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@Override public void postProcess(final Path source, final Path destination) { //Load existing file final org.uberfire.java.nio.file.Path _destination = Paths.convert(destination); final String drl = ioService.readAllString(Paths.convert(destination)); final String baseFileName = FileNameUtil.removeExtension(source, resourceType); final PackageDataModelOracle oracle = dataModelService.getDataModel(source); final GuidedDecisionTree model = GuidedDecisionTreeDRLPersistence.getInstance().unmarshal(drl, baseFileName, oracle); //Update tree name final String treeName = FileNameUtil.removeExtension(destination, resourceType); model.setTreeName(treeName); //Save file ioService.write(_destination, GuidedDecisionTreeDRLPersistence.getInstance().marshal(model), commentedOptionFactory.makeCommentedOption("File [" + source.toURI() + "] renamed to [" + destination.toURI() + "].")); } }
@Override public void postProcess(final Path source, final Path destination) { //Load existing file final org.uberfire.java.nio.file.Path _destination = Paths.convert(destination); final String drl = ioService.readAllString(Paths.convert(destination)); final String baseFileName = FileNameUtil.removeExtension(source, resourceType); final PackageDataModelOracle oracle = dataModelService.getDataModel(source); final GuidedDecisionTree model = GuidedDecisionTreeDRLPersistence.getInstance().unmarshal(drl, baseFileName, oracle); //Update tree name final String treeName = FileNameUtil.removeExtension(destination, resourceType); model.setTreeName(treeName); //Save file ioService.write(_destination, GuidedDecisionTreeDRLPersistence.getInstance().marshal(model), commentedOptionFactory.makeCommentedOption("File [" + source.toURI() + "] copied to [" + destination.toURI() + "].")); } }
@Override public void postProcess( final Path source, final Path destination ) { //Load existing file final org.uberfire.java.nio.file.Path _destination = Paths.convert( destination ); final String content = ioService.readAllString( Paths.convert( destination ) ); final TemplateModel model = RuleTemplateModelXMLPersistenceImpl.getInstance().unmarshal( content ); //Update rule name final String ruleName = FileNameUtil.removeExtension( destination, resourceType ); model.name = ruleName; //Save file ioService.write( _destination, RuleTemplateModelXMLPersistenceImpl.getInstance().marshal( model ), commentedOptionFactory.makeCommentedOption( "File [" + source.toURI() + "] renamed to [" + destination.toURI() + "]." ) ); }
@Override public void postProcess( final Path source, final Path destination ) { //Load existing file final org.uberfire.java.nio.file.Path _destination = Paths.convert( destination ); final String content = ioService.readAllString( Paths.convert( destination ) ); final TemplateModel model = RuleTemplateModelXMLPersistenceImpl.getInstance().unmarshal( content ); //Update rule name final String ruleName = FileNameUtil.removeExtension( destination, resourceType ); model.name = ruleName; //Save file ioService.write( _destination, RuleTemplateModelXMLPersistenceImpl.getInstance().marshal( model ), commentedOptionFactory.makeCommentedOption( "File [" + source.toURI() + "] copied to [" + destination.toURI() + "]." ) ); }
@Override public void postProcess( final Path source, final Path destination ) { //Load existing file final org.uberfire.java.nio.file.Path _destination = Paths.convert( destination ); final String content = ioService.readAllString( Paths.convert( destination ) ); final TemplateModel model = RuleTemplateModelXMLPersistenceImpl.getInstance().unmarshal( content ); //Update rule name final String ruleName = FileNameUtil.removeExtension( destination, resourceType ); model.name = ruleName; //Save file ioService.write( _destination, RuleTemplateModelXMLPersistenceImpl.getInstance().marshal( model ), commentedOptionFactory.makeCommentedOption( "File [" + source.toURI() + "] copied to [" + destination.toURI() + "]." ) ); }
@Override public void postProcess( final Path source, final Path destination ) { //Load existing file final org.uberfire.java.nio.file.Path _destination = Paths.convert( destination ); final String content = ioService.readAllString( Paths.convert( destination ) ); final TemplateModel model = RuleTemplateModelXMLPersistenceImpl.getInstance().unmarshal( content ); //Update rule name final String ruleName = FileNameUtil.removeExtension( destination, resourceType ); model.name = ruleName; //Save file ioService.write( _destination, RuleTemplateModelXMLPersistenceImpl.getInstance().marshal( model ), commentedOptionFactory.makeCommentedOption( "File [" + source.toURI() + "] renamed to [" + destination.toURI() + "]." ) ); }
@Override public void postProcess( final Path source, final Path destination ) { //Load existing file final org.uberfire.java.nio.file.Path _destination = Paths.convert( destination ); final String content = ioService.readAllString( Paths.convert( destination ) ); final GuidedDecisionTable52 model = GuidedDTXMLPersistence.getInstance().unmarshal( content ); //Update table name final String tableName = FileNameUtil.removeExtension( destination, resourceType ); model.setTableName( tableName ); //Save file ioService.write( _destination, GuidedDTXMLPersistence.getInstance().marshal( model ), commentedOptionFactory.makeCommentedOption( "File [" + source.toURI() + "] renamed to [" + destination.toURI() + "]." ) ); }
@Override public void postProcess( final Path source, final Path destination ) { //Load existing file final org.uberfire.java.nio.file.Path _destination = Paths.convert( destination ); final String content = ioService.readAllString( Paths.convert( destination ) ); final GuidedDecisionTable52 model = GuidedDTXMLPersistence.getInstance().unmarshal( content ); //Update table name final String tableName = FileNameUtil.removeExtension( destination, resourceType ); model.setTableName( tableName ); //Save file ioService.write( _destination, GuidedDTXMLPersistence.getInstance().marshal( model ), commentedOptionFactory.makeCommentedOption( "File [" + source.toURI() + "] copied to [" + destination.toURI() + "]." ) ); }