Script Reference
Static class for converting XML templates to programming code.
//convert XML to code
var tmpGeneratedCodeFile = ...;
CodeGeneratorTools . ConvertXmlToPhpCode ( generatedFileName , tmpGeneratedCodeFile , true );
Method
Description
CodeGeneratorTools
static object
ConvertXmlToPhpCode(inputFile,outputFile, useFirstChild)
convert XML to PHP code
CFileEnumerator
Class for file enumeration
var fe = new CFileEnumerator ( feNotifier );
fe . AddDirMask ( " .svn " , CFileEnumerator . MASK_WILDCARD , CFileEnumerator . FILE_EXCLUDE );
fe . Enumerate ( directoryFileName );
//get found files
var fl = fe . GetFoundFiles ();
Method
Description
CFileEnumerator()
construct file enumerator without binding to notifier object
CFileEnumerator(notifier)
construct file enumerator with binding to notifier object
AddFileMask(mask,maskType,includeExclude)
add file mask
AddDirMask(mask,maskType,includeExclude)
add directory mask
AddFullFilePathMask(mask,maskType,includeExclude)
add full path file mask
AddFullDirPathMask(mask,maskType,includeExclude)
add full path directory mask
AddFileSizeRule(fileSize,ruleSizeType)
add rule by file size
Enumerate(path, clearPreviousResults)
enumerate files and directories based on rules
ResetAllRules()
clear all rules
GetFoundDirs(ordered = true)
return array of found directories
GetFoundFiles(ordered = true)
return array of found files
Constant
Type
Description
MASK_WILDCARD
maskType
search by wildcard
MASK_REGEX
maskType
search by regex
FILE_INCLUDE
includeExclude
include file if rule is true
FILE_EXCLUDE
includeExclude
exclude file if rule is true
FILESIZE_MINIMUM
ruleSizeType
passed value is minimum file size
FILESIZE_MAXIMUM
ruleSizeType
passed value is maximum file size
FILESIZE_EXACT
ruleSizeType
passed value have to be exact file size
CFileEnumeratorNotifier
This class allows to pass notification callback to CFileEnumerator
class.
var feNotifier = new CFileEnumeratorNotifier ;
feNotifier . fceOnDirectory =
function ( path ){ MessageCenter . ProgressSetMessage ( " status " , path ); };
//scan for files by path and extension
var fe = new CFileEnumerator ( feNotifier );
Method
Description
CFileEnumeratorNotifier()
construct file enumerator notifier
Property
Description
fceOnDirectory
callback function onDirectory
Static class with file manipulation routines.
//convert XML to code
var fileName = ...;
FileTools . ExistsFile ( fileName );
Method
Description
FileTools
static object
CopyFile(inputFileName, outputFileName)
copy file
DeleteFile(fileName)
delete file
AppendFile(inputFileName, appendToFileName)
append file to another file
AppendString(inputContent, appendToFileName)
append string to file
ReplaceFileContent(inputFileName, destinationFileName)
replace content in destinationFileName by using content from inputFileName
CreateFilePath(path,...)
create file path from multiple parts
IsAbsolutePath(fileName)
test if path is absolute
GetFileExtension(fileName)
get file extension
GetPathFromFullFileName(fileName)
get path from full file name
GetFileNameFromFullFileName(fileName,withExtension)
get filename from full file name
GetRelativePathDirToFile(startDirectory,toFile)
get relative path - directory to file
GetRelativePathDirToDir(startDirectory,toDirectory,returnDotInsteadEmpty)
get relative path - directory to directory
ExtractZipFile(zipFile, extractDirectory)
extract zip files to directory (returns list of files)
GetNormalizedPath(path)
normalize path
ConvertPathToUniversalFormat(path)
convert path to universal format file path
CompareFiles(file1, file2)
compare files (true/false)
ExistsFile(file)
test if file exists (true/false)
ExistsDirectory(file)
test if directory exists (true/false)
MessageCenter
Helper class for displaying progress messages during script execution.
//status
MessageCenter . ProgressSetMessage ( " operation " , " Exporting Doctrine files... " );
MessageCenter . ProgressSetMessage ( " status " , " Transforming project file " );
Method
Description
ProgressSetMessage(channel,text)
send progress text to specified channel
Message(messageText)
debug message
Trace(traceText)
debug trace
Static class with markup langages (XML,YML,XSLT) routines.
//convert YML to XML
MLTools . ConvertYamlToXml ( ymlFile , xmlFile );
//setup transform params
var xslParams = new Array ();
xslParams [ " import-path " ] = fileName ;
xslParams [ " import-format " ] = " DoctrineYml " ;
MLTools . XslTransformation ( inputXml , inputXslt , outputFile , xslParams );
//split and merge files
var splitFiles = MLTools . XmlSplitFile ( inputXmlFile );
MLTools . XmlMergeFiles ( splitFiles , outputFile );
//read values from xml
var xmlQuery = { " destinationPath " : " /import-export-file/@import-path " };
MLTools . XmlReadValues ( fileName , xmlQuery );
var result = xmlQuery [ " destinationPath " ];
Method
Description
ConvertYamlToXml(inputFileName,outputFileName)
convert YML file to YML-in-XML file
ConvertXmlToYaml(inputFileName,outputFileName)
convert YML-in-XML to YML file
XslTransformation(inputFN,xsltFN,outputFN,mapParams)
execute XSL transformation
XmlMergeFiles(lstInputXmlFiles,outputFile)
merge multiple XML files to one
XmlSplitFile(inputFile)
split single file to multiple XML files (array of files)
XmlReadValues(inputFileName,varParams)
read values by xpath from XML
XmlReadValue(inputFileName,xpath)
read single value by xpath from XML
YamlReadValues(inputFileName,varParams)
read values by xpath from YML
MergeTagsInXml(inputFileName, XPathMergeElements, UuidAttribute='uuid', MoveEncapsulerElements=false)
merge passed elements with the rest of documents based on uuid attribute. use MoveEncapsulerElements to move also encapsuler element.
RemoveSpecificElement
(strInputFileName, strXpathToElementsToRemove)`
remove specific elements
RemoveElementsAndMoveChildren(strInputFileName, strXpathToElementsToRemove)
remove specific element and move all his children to original element location
OrmdProject
Class object representing current Skipper project. This clas is passed to all functions and it isn’t possible to create new one.
function DoctrineImport ( objProject , arrayInputFiles )
{
//type of objProject is OrmdProject
}
Method
Description
LoadProject(inputFileName, proceedUpdate=false)
load project file to object. if proceedUpdate is true, ORMD updates project to latest version
SaveProjectToSpecificFile(outputFN,withExportTags,asSingleFile=true)
save project to specified file.
GetProjectRootDirectory()
return project root directory
LocateConfigurationFileName(fileName)
search for specified filename in configuration directories
GetProjectSettingsValue(keyName)
get setting value from <skipper-configuration>/<specific-settings>/<setting>
by name
Static class with Skipper tools. Currently empty.
//usage example
SkipperTools . Method ( params );
Method
Description
Method
description
Static class for string manipulation.
Method
Description
RegExGet(inputString,regEx,position=0)
get substring based on regex
RegExMatch(inputString,regEx)
test string based on regex
Replace(text,from,to)
replace values in string
ConvertToUnderLine(text)
convert string to underline
SubstringBeforeLast(text,substr,caseSensitive=1,returnAllWhenNotFound=0)
get substring before last occurence
CTemporaryFile
Class for creating temporary file path.
var tmpFileConvertToXml = new CTemporaryFile ;
Method
Description
CTemporaryFile()
construct temporary file path
CTemporaryFile(prefix)
construct temporary file path with specified prefix
CTemporaryFile(prefix,extension)
construct temporary file path with specified prefix and extension
GetFileName()
get file name
toString()
convert to string
CTemporaryDirectory
Class for creating temporary file directory.
var tmpDirectory = new CTemporaryDirectory ;
Method
Description
CTemporaryDirectory()
construct temporary directory path
CTemporaryDirectory(prefix)
construct temporary directory path with specified prefix
GetDirectoryPath()
get directory path
toString()
convert to string
Static class for unit-testing purposes.
var tmpFileConvertToXml = new CTemporaryFile ;
Method
Description
CopyFile(source,destination)
copy file from source to destination. Copies file only in UnitTest mode
IsUnitTest()
test if application is in UnitTst mode
TEST_CHECK(expression)
test expression and result pass to UnitTest framework
TEST_CHECK_EQUAL(v1,v2)
compare v1 and v2 and result pass to UnitTest framework
trace(text)
send trace to UnitTest framework
CAbstractManipulator
Base class for manipulation with code files.
var mergeRules = new CAstMergeRules ;
var phpResult = new CPhpManipulator ;
phpResult . ParseSourceFile ( fullDestinationPath );
phpResult . OptimizeAstTree ();
phpResult . MergeWithAst ( phpGenerated , mergeRules );
Method
Description
ParseSourceFile(filePath)
parse source file to inner AST tree
SaveSourceFile(filePath)
save inner AST tree as source file
LoadAstFile(filePath)
load AST XML tree
SaveAstFile(filePath)
save AST XML tree
InvalidateAllElements()
mark all AST elements as modified
RemoveAllWhitespaces()
remove all whitespaces from AST tree
RemoveAllGenerableContent()
remove all generable content from AST tree
OptimizeAstTree()
optimize AST tree to proceed-able state
UnoptimizeAstTree()
revert back optimized AST tree to original
ReformatAst(modifyOnly,maxRowLength=80,newLine="\n",indent="_")
reformat AST tree (spacing, tabs, newlines)
MergeWithAst(phpManipulatorSource,mergeRules)
merge two AST trees based on rules
RegisterDefaultNamespaceForAnnotations(namespace, annotations)
register default namespaces for annotations
UnitTestSaveAstFile(filePath,saveModifiedFlags=false)
save ast tree when running UnitTests
UnitTestSaveSourceFile(filePath)
save source file when running UnitTests
CPhpManipulator
Class for manipulation with PHP files. Derived from CAbstractManipulator.
CJavaManipulator
Class for manipulation with JAVA files. Derived from CAbstractManipulator
CProgramAnnotationsDetector
Class for searching files with specified annotations.
//setup PHP annotations scanner
var annotationsScanner = new CProgramAnnotationsDetector ;
annotationsScanner . InsertSearchedAnnotations ( " Doctrine \\ ORM \\ Mapping \\ Entity " );
annotationsScanner . InsertStopMarks ( " class " );
annotationsScanner . RegisterDefaultNamespaceForAnnotations ( " Doctrine \\ ORM \\ Mapping " , " Entity " );
annotationsScanner . SetMaximumScanLength ( 4096 );
var bIsFileWithEntity = annotationsScanner . ScanFile ( file );
Method
Description
InsertSearchedAnnotations(searchedAnnotation)
setup annotation to find
RegisterDefaultNamespaceForAnnotations(namespace, annotations)
register default namespaces for specified annotations
ScanFile(filePath)
Scan passed file for specified annotation
InsertStopMarks(stopMarks)
define string stop for scanned files
SetMaximumScanLength(scanLength)
define maximum size of file to scan
CAstMergeRules
Class for defining AST merge rules. Rules are evaluated from bottom to top. So the rule entered as latest has the highest priority during evaluation.
var mergeRules = new CAstMergeRules ;
//default behavior is ADD anything new, DON'T DELETE or UPDATE anything.
//If elements are equal, KEEP them
mergeRules . SetDefaultRule (
CAstMergeRules . ACTION_MERGE , CAstMergeRules . RULE_KEEP ,
CAstMergeRules . RULE_KEEP , CAstMergeRules . RULE_KEEP
);
//set special rule for functions. If function exists, DONT't test content(child)
mergeRules . AddRuleByType ( true , " function " ,
CAstMergeRules . RULE_MERGE , CAstMergeRules . RULE_KEEP ,
CAstMergeRules . RULE_KEEP , CAstMergeRules . RULE_SKIP
);
//set special rule for Doctrine2 annotations (and everything else in Doctrine NS).
//Insert missing, remove excess, update different, merge-the-same (if you want to keep
//unmodified values, set this value to RULE_KEEP)
mergeRules . AddRuleByTypeNameNamespace ( true , "" , "" , " Doctrine \\ ORM \\ Mapping " ,
CAstMergeRules . RULE_MERGE , CAstMergeRules . RULE_MERGE ,
CAstMergeRules . RULE_MERGE , CAstMergeRules . RULE_MERGE
);
Method
Description
ruleWhenMissing, ruleWhenExcess, ruleWhenDifferent, ruleWhenEqual
rule params
SetDefaultRule(*rules)
set default rule for all elements
AddRuleByName(ifMatchResult, name, *rules)
set rule by element name
AddRuleByType(ifMatchResult, type, *rules)
set rule by element type
AddRuleByTypeName(ifMatchResult, type, name,*rules)
set rule by element name and type
AddRuleByTypeNameNamespace(ifMatchResult, type, name, namespace, *rules)
set rule by name and namespace
AddParentTypeRuleByType(ifMatchResult, parentType, type, *rules)
set rule by parent type and element type
SetDeepHashForElement(fullElementName)
setup elements for deep hashing instead local hashing
ClearRules()
clear all rules
Parameter
Description
ruleWhenMissing
rule applied when annotation is missing in destination tree
ruleWhenExcess
rule applied when annotation excess in destination tree
ruleWhenDifferent
rule applied when source and destination annotation is different
ruleWhenEqual
rule applied when source and desgination annotation is eual
ifMatchResult
determines if we’re looking for match or differ => ax_xor(ifMatchResult,expression)
name
rule by annotation name
type
rule by annotation type
namespace
rule by annotation namespace
Constants
Description
RULE_MERGE
merge found elements to one (child elements are copied)
RULE_KEEP
keep found element
RULE_SKIP
keep found element and don’t proceed child
RULE_UNDEFINED
proceed by default rules
Static class with system routines.
//execute command
var command = ...;
SystemTools . ExecuteCommand ( command );
Method
Description
SystemTools
static object
ExecuteCommand(command, workingDir)
execute passed command in working dir (optional)
CNamespaceAbsoluteCalculator
This class allows to calculate all missing namespaces in source XML. It’s useful when importing schema files with relative namespaces inside to simplify following XSLT transfomations.
Note: Xpath evaluator has mapped “dns” namespace alias to document’s default namespace.
var namespaceCalculator = new CNamespaceAbsoluteCalculator ;
namespaceCalculator . DefineNamespace ( " http://inventic.eu " , " inv " );
namespaceCalculator . ConfigureObject ( " /inv:document/inv:entity " , " entity " , " name " );
namespaceCalculator . ConfigureReference ( " //association " , " from " );
namespaceCalculator . ConfigureReference ( " //one-to-many " , Array ( " from " , " to " ));
namespaceCalculator . CalculateNamespaces ( filePath );
Method
Description
CNamespaceAbsoluteCalculator()
construct namespace calculator
ConfigureObject(objectXpath,objectElement, nameAttribute)
configure object with namespaces, object element and attribute which holds object name
ConfigureReference(objectXpath, setAttributes)
configure elements which references to objects and attributes which hold referenced names
CalculateNamespaces(pathFile)
execute namespace calculation on selected file
DefineNamespace(strNamespace, strPrefix)
Define new namespace for Xpath (for element localization)