<?xml version="1.0" encoding="UTF-8"?>
<plugin
  name="%pluginName"
  id="ru.biosoft.access.javascript"
  version="0.8.6"  
  provider-name="%providerName">
  
  <requires>  
    <import plugin="org.eclipse.core.runtime"/>	
    <import plugin="com.beanexplorer"/>
    <import plugin="com.developmentontheedge.util"/>
    <import plugin="org.apache.log4j"/>
    <import plugin="org.mozilla.javascript"/>
    <import plugin="ru.biosoft.plugins.javascript"/>	
    <import plugin="javax.help"/>
    <import plugin="ru.biosoft.access"/>
    <import plugin="ru.biosoft.table"/>
    <import plugin="ru.biosoft.graph"/>		
  </requires>
  
  <runtime>
    <library name="javascript.jar">
      <export name="*"/>
    </library>
  </runtime>
  
   <extension id="dataFilter" point="ru.biosoft.plugins.javascript.hostObject"> 
    <hostObject name="dataFilter" class="ru.biosoft.access.javascript.JavaScriptFilter" >
        <doc description="Facade for data-filtering">
			<function name="byValue" description="returns error from last stament or null if there is no such">    														
				<argument name="source" type="Object" obligatory="true" description="data-source, can be String (path to DC) or DataCollection"/>			
				<argument name="property" type="String" obligatory="true" description="DataElement name value"/>
				<argument name="values" type="String" obligatory="true" description="column value"/>
	            <returns type="ru.biosoft.access.FilteredDataCollection" description="null on failure"/>
			</function>
			<function name="byExpression" description="filters by given javascript expression">
				<argument name="source" type="Object" obligatory="true" description="data-source, can be String (path to DC) or DataCollection"/>
				<argument name="expression" type="String" obligatory="true" description="data-source, can be String (path to DC) or DataCollection"/>
				<returns type="ru.biosoft.access.FilteredDataCollection" description="null on failure"/>
			</function>
			<function name="bySet" description="filters by given data collection, used as permitable set of values">
				<argument name="source" type="Object" obligatory="true" description="data-source, can be String (path to DC) or DataCollection"/>
				<argument name="filterSource" type="Object" obligatory="true" description="filter data-source, can be String (path to DC) or DataCollection"/>
				<returns type="ru.biosoft.access.FilteredDataCollection" description="null on failure"/>
			</function>
		</doc>
      </hostObject>
  </extension>
  
  <extension id="data" point="ru.biosoft.plugins.javascript.hostObject"> 
    <hostObject name="data" class="ru.biosoft.access.javascript.JavaScriptData" >
        <doc description="Facade for data-manipulations">
		
		<function name="getLastError" description="returns error from last stament or null if there is no such">    														
            <returns type="String" description="last error message"/>              
        </function>
		
		<function name="addColumn" description="DataCollection to modify">
            <argument name="source" type="Object" obligatory="true" description="data-source, can be String (path to DC) or DataCollection"/>			
			<argument name="columnName" type="String" obligatory="true" description="name of the column to add"/>
			<argument name="columnType" type="String" obligatory="true" description="type of the column to add. Can be TEXT,DBREF,SAMPLE or CALCULATED"/>             
			<returns type="Boolean" description="true if OK"/>              
        </function>
		
		<function name="removeColumn" description="DataCollection to modify">    								
			<argument name="source" type="Object" obligatory="true" description="data-source, can be String (path to DC) or DataCollection"/>			
            <returns type="Boolean" description="true if OK"/>              
        </function>
		
		<function name="contains" description="whether DataElement exists at path specified">    								
			<argument name="path" type="String" obligatory="true" description="path to check"/>			
            <returns type="Boolean" description="true if exists"/>              
        </function>
		
		<function name="contains2" description="whether DataElement exists at relative path specified.">    		
			<argument name="path" type="String" obligatory="true" description="root for relative path"/>			
			<argument name="dc" type="ru.biosoft.access.DataCollection" obligatory="true" description="ancestor"/>			
            <returns type="Boolean" description="true if exists"/>              
        </function>
		
		<function name="put" description="puts DataElement in to the DataCollection">    		
			<argument name="dc" type="ru.biosoft.access.DataCollection" obligatory="true" description="DataCollection to modify"/>			
			<argument name="path" type="String" obligatory="true" description="if non-empty, then used as relative path from DataCollection"/>			
			<argument name="de" type="ru.biosoft.access.DataElement" obligatory="true" description="element to put"/>
            <returns type="Boolean" description="true on success"/>              
        </function>
		
		<function name="remove" description="removes DataElement from DataCollection">    		
			<argument name="dc" type="ru.biosoft.access.DataCollection" obligatory="true" description="DataCollection to modify"/>
			<argument name="path" type="String" obligatory="true" description="path for DataElement to remove"/>			
            <returns type="Boolean" description="put return descr"/>              
        </function>
		
		<function name="get" description="gets DataElement">    					
			<argument name="path" type="String" obligatory="true" description="path for DataElement"/>			
            <returns type="ru.biosoft.access.DataElement" description="null on failure"/>              
        </function>
		
		<function name="get2" description="gets DataElement">    		
			<argument name="dc" type="ru.biosoft.access.DataCollection" obligatory="true" description="ancestor"/>			
			<argument name="path" type="String" obligatory="true" description="relative path for DataElement"/>			
            <returns type="ru.biosoft.access.DataCollection" description="null on failure"/>              
        </function>
		
		<function name="value" description="gets value from given data-source">    		
			<argument name="source" type="Object" obligatory="true" description="data-source, can be String (path to DC) or DataCollection"/>			
			<argument name="element" type="String" obligatory="true" description="DataElement name value"/>
			<argument name="column" type="String" obligatory="true" description="column value"/>
            <returns type="Object" description="value return descr"/>              
        </function>
		
		<function name="recalc" description="calculates values using java-script exprs and puts them to target DC">    		
			<argument name="dc" type="ru.biosoft.access.DataCollection" obligatory="true" description="DC from modify"/>						
			<argument name="column" type="String" obligatory="true" description="column to affect"/>
			<argument name="expression" type="String" obligatory="true" description="expression, may include column names, they will be evaluated to column values at row being calculated."/>            
        </function>
		
		<function name="join" description="peforms join in SQL sense">    		
			<argument name="type" type="String" obligatory="true" description="type of join. Can be 'inner', 'left, 'right' and 'outer'"/>
			<argument name="leftSource" type="Object" obligatory="true" description="left DC data-source, can be String (path to DC) or DataCollection"/>
			<argument name="rightSource" type="Object" obligatory="true" description="right DC data-source, can be String (path to DC) or DataCollection"/>						
			<argument name="leftColumns" type="String" obligatory="true" description="comma separated column names in left DC. If empty, all columns are used."/>
			<argument name="rightColumns" type="String" obligatory="true" description="comma separated column names in right DC. If empty, all columns are used."/>
			<argument name="resultName" type="String" obligatory="true" description="Name of the resultant TableDataCollection"/>
            <returns type="ru.biosoft.access.TableDataCollection" description="null on failure"/>              
        </function>
		
		<function name="trim" description="takes only [from,to] rows from DataCollection. ">    		
			<argument name="source" type="Object" obligatory="true" description="DC data-source, can be String (path to DC) or DataCollection"/>			
			<argument name="from" type="Integer" obligatory="true" description=""/>
			<argument name="to" type="Integer" obligatory="true" description=""/>
            <returns type="ru.biosoft.access.FilteredDataCollection" description="null on failure"/>              
        </function>
		
		<function name="save" description="saves DC on given path">    		
			<argument name="dc" type="ru.biosoft.access.DataCollection" obligatory="true" description="DC to save"/>			
			<argument name="path" type="String" obligatory="true" description="path where to save"/>			
            <returns type="Boolean" description="true on success"/>                 
        </function>
		
		<function name="columnNames" description="list of fields in given dc">    		
			<argument name="dc" type="ru.biosoft.access.DataCollection" obligatory="true" description="DC to save"/>								
            <returns type="Scriptable" description="javascript array"/>                 
        </function>
		
        </doc>
      </hostObject>
  </extension>  

</plugin>