Skip to Content.
Sympa Menu

notify-dpml - r1419 - in trunk/main/lang/process: etc etc/test src/test/net/dpml/lang/process

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r1419 - in trunk/main/lang/process: etc etc/test src/test/net/dpml/lang/process
  • Date: Sat, 29 Apr 2006 22:22:25 +0200

Author: mcconnell
Date: 2006-04-29 22:22:24 +0200 (Sat, 29 Apr 2006)
New Revision: 1419

Modified:
trunk/main/lang/process/etc/process.xsd
trunk/main/lang/process/etc/test/sample.xml

trunk/main/lang/process/src/test/net/dpml/lang/process/ProcessXsdTestCase.java
Log:
moving forward with product/process model

Modified: trunk/main/lang/process/etc/process.xsd
===================================================================
--- trunk/main/lang/process/etc/process.xsd 2006-04-29 18:11:41 UTC (rev
1418)
+++ trunk/main/lang/process/etc/process.xsd 2006-04-29 20:22:24 UTC (rev
1419)
@@ -81,14 +81,22 @@

<complexType name="ProcessType">
<sequence>
+ <element name="dependencies" type="this:DependenciesType"
minOccurs="0" maxOccurs="1"/>
<element name="consumes" type="this:ConsumesType" minOccurs="0"
maxOccurs="1"/>
<element name="produces" type="this:ProducesType" minOccurs="0"
maxOccurs="1"/>
</sequence>
<attribute name="name" type="string" use="required"/>
<attribute name="class" type="string" use="required"/>
<attribute name="implicit" type="boolean" default="false"/>
+ <attribute name="depends" type="string"/>
</complexType>

+ <complexType name="DependenciesType">
+ <sequence>
+ <element name="include" type="this:DependencyType" minOccurs="0"
maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
<complexType name="ConsumesType">
<sequence>
<element name="input" type="this:InputType" minOccurs="0"
maxOccurs="unbounded"/>
@@ -103,6 +111,10 @@
<attribute name="policy" type="this:PolicyType"/>
</complexType>

+ <complexType name="DependencyType">
+ <attribute name="id" type="string"/>
+ </complexType>
+
<complexType name="InputType">
<attribute name="id" type="string"/>
<attribute name="policy" type="this:PolicyType"/>

Modified: trunk/main/lang/process/etc/test/sample.xml
===================================================================
--- trunk/main/lang/process/etc/test/sample.xml 2006-04-29 18:11:41 UTC (rev
1418)
+++ trunk/main/lang/process/etc/test/sample.xml 2006-04-29 20:22:24 UTC (rev
1419)
@@ -61,6 +61,7 @@

<process name="prepare-test"
class="net.dpml.tools.process.PrepareTestProcess">
<consumes policy="conditional">
+ <input id="target.build.main.dir" policy="optional"/>
<input id="etc.test" policy="optional"/>
<input id="src.test" policy="optional"/>
</consumes>
@@ -81,6 +82,7 @@

<process name="compile-test"
class="net.dpml.tools.process.CompileTestProcess" implicit="true">
<consumes>
+ <input id="target.classes.main.dir" policy="optional"/>
<input id="target.build.test.dir" policy="conditional"/>
</consumes>
<produces>
@@ -92,6 +94,7 @@
<consumes>
<input id="target.test.dir" policy="optional"/>
<input id="target.classes.test.dir" policy="conditional"/>
+ <input id="target.classes.main.dir"/>
</consumes>
<produces>
<output id="target.reports.test.dir"/>
@@ -109,6 +112,9 @@
</process>

<process name="rmic" class="net.dpml.tools.process.RMICProcess">
+ <dependencies>
+ <include id="compile-main"/>
+ </dependencies>
<consumes>
<input id="target.classes.main.dir" policy="conditional"/>
</consumes>

Modified:
trunk/main/lang/process/src/test/net/dpml/lang/process/ProcessXsdTestCase.java
===================================================================
---
trunk/main/lang/process/src/test/net/dpml/lang/process/ProcessXsdTestCase.java
2006-04-29 18:11:41 UTC (rev 1418)
+++
trunk/main/lang/process/src/test/net/dpml/lang/process/ProcessXsdTestCase.java
2006-04-29 20:22:24 UTC (rev 1419)
@@ -23,6 +23,7 @@
import java.util.Map;
import java.util.ArrayList;
import java.util.Hashtable;
+import java.util.List;

import net.dpml.util.DOM3DocumentBuilder;
import net.dpml.util.ElementHelper;
@@ -126,7 +127,7 @@
}

/**
- * List the processes that are declared as implicit.
+ * Test the evaluation of implicit targets.
* @exception Exception if an error occurs
*/
public void testImplicitTargets() throws Exception
@@ -135,15 +136,58 @@
for( int i=0; i<implicits.length; i++ )
{
Element implicit = implicits[i];
- listProcess( implicit );
+ String name = ElementHelper.getAttribute( implicit, "name" );
+ System.out.println( "# process: " + name );
}
+ System.out.println( "" );
}

- private Element[] getImplicitProcesses()
+ /**
+ * test explicit targets.
+ * @exception Exception if an error occurs
+ */
+ public void testExplicitProducts() throws Exception
{
+ Element jar = (Element) m_products.get( "target.deliverables.jar" );
+ if( null == jar )
+ {
+ throw new NullPointerException( "target.deliverables.jar" );
+ }
ArrayList list = new ArrayList();
+ getInputProcesses( list, jar );
+ Element[] processors = (Element[]) list.toArray( new Element[0] );
+ for( int i=0; i<processors.length; i++ )
+ {
+ String name = ElementHelper.getAttribute( processors[i], "name"
);
+ System.out.println( "# process: " + name );
+ }
+ System.out.println( "" );
+ }
+
+ /**
+ * test explicit targets.
+ * @exception Exception if an error occurs
+ */
+ public void testProcessTarget() throws Exception
+ {
+ ArrayList list = new ArrayList();
+ Element rmic = (Element) m_processes.get( "rmic" );
+ Element jar = (Element) m_processes.get( "jar" );
+ getImpliedProcesses( list, rmic );
+ getImpliedProcesses( list, jar );
+ Element[] processors = (Element[]) list.toArray( new Element[0] );
+ for( int i=0; i<processors.length; i++ )
+ {
+ String name = ElementHelper.getAttribute( processors[i], "name"
);
+ System.out.println( "# process: " + name );
+ }
+ }
+
+ private Element[] getImplicitProcesses() throws DecodingException
+ {
+ ArrayList list = new ArrayList();
String[] keys = (String[]) m_processes.keySet().toArray( new
String[0] );
- for( int i=(keys.length-1); i>-1; i-- )
+ for( int i=0; i<keys.length; i++ )
{
String key = keys[i];
Element elem = (Element) m_processes.get( key );
@@ -152,40 +196,79 @@
list.add( elem );
}
}
- return (Element[]) list.toArray( new Element[0] );
+ Element[] implicits = (Element[]) list.toArray( new Element[0] );
+ ArrayList expanded = new ArrayList();
+ for( int i=0; i<implicits.length; i++ )
+ {
+ Element implicit = implicits[i];
+ getImpliedProcesses( expanded, implicit );
+ }
+ return (Element[]) expanded.toArray( new Element[0] );
}

- private void listProcess( Element process )
+ private void getImpliedProcesses( List list, Element process ) throws
DecodingException
{
+ getDepedentProcessors( list, process );
Element[] inputs = getInputElements( process );
for( int i=0; i<inputs.length; i++ )
{
Element e = inputs[i];
String id = ElementHelper.getAttribute( e, "id" );
Element product = (Element) m_products.get( id );
- //System.out.println( "# input: " + DecodingException.list(
product ) );
- Element[] processes = getInputProcesses( product );
- for( int j=0; j<processes.length; j++ )
+ getInputProcesses( list, product );
+ }
+ if( !list.contains( process ) )
+ {
+ list.add( process );
+ }
+ }
+
+ private void getDepedentProcessors( List list, Element process ) throws
DecodingException
+ {
+ Element dependencies = ElementHelper.getChild( process,
"dependencies" );
+ if( null == dependencies )
+ {
+ return;
+ }
+ else
+ {
+ Element[] children = ElementHelper.getChildren( dependencies );
+ String[] keys = new String[ children.length ];
+ for( int i=0; i<children.length; i++ )
{
- listProcess( processes[i] );
- //System.out.println( "# processes: " +
DecodingException.list( processes[i] ) );
+ Element child = children[i];
+ String key = ElementHelper.getAttribute( child, "id" );
+ Element proc = (Element) m_processes.get( key );
+ if( null == proc )
+ {
+ final String error =
+ "Processor dependency ["
+ + key
+ + "] not recognized.";
+ throw new DecodingException( child, error );
+ }
+ else
+ {
+ getImpliedProcesses( list, proc );
+ }
}
}
- String name = ElementHelper.getAttribute( process, "name" );
- System.out.println( "# process: " + name );
}

- private Element[] getInputProcesses( Element product )
+ private void getInputProcesses( List list, Element product ) throws
DecodingException
{
+ if( null == product )
+ {
+ throw new NullPointerException( "product" );
+ }
String name = ElementHelper.getAttribute( product, "name" );
- return getProducers( name );
+ getProducers( list, name );
}

- private Element[] getProducers( String id )
+ private void getProducers( List list, String id ) throws
DecodingException
{
- ArrayList list = new ArrayList();
String[] keys = (String[]) m_processes.keySet().toArray( new
String[0] );
- for( int i=(keys.length-1); i>-1; i-- )
+ for( int i=0; i<keys.length; i++ )
{
String key = keys[i];
Element process = (Element) m_processes.get( key );
@@ -195,11 +278,14 @@
String productionId = ids[j];
if( id.equals( productionId ) )
{
- list.add( process );
+ getImpliedProcesses( list, process );
+ if( !list.contains( process ) )
+ {
+ list.add( process );
+ }
}
}
}
- return (Element[]) list.toArray( new Element[0] );
}

private String[] getProcessProductionIDs( Element process )




  • r1419 - in trunk/main/lang/process: etc etc/test src/test/net/dpml/lang/process, mcconnell at BerliOS, 04/29/2006

Archive powered by MHonArc 2.6.24.

Top of Page