<?xml version="1.0" encoding="UTF-8"?>
<ucp:component 
	xmlns:ucp="http://DigitalLeadersInitiative.com/EAMD.ucp/2.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://DigitalLeadersInitiative.com/EAMD.ucp/2.0 
	https://raw.githubusercontent.com/DigitalLeadersInitiative/EAMD.ucp/master/ucp/2.0/Component.xsd"
	>
	
	<!-- Nexus "dependency.groupId"."dependency.artifactId" -->
	<name uuid="${this.version.ucpComponentDescriptor.id}">${this.ucpComponent.package}.${this.ucpComponent.className}</name>
	
	<!-- Nexus "dependency.version" -->
	<version>${this.version.name}</version>
	

	<!-- 1 to 5 -->
	<layer>$-{this.ucpComponent.layer.value}</layer>
	
	<lifecycle phase="$-{this.version.ucpComponentDescriptor.lifecycle.name}"/>

	<!-- human-readable name, not necessarily unique -->
	<displayName>${this.ucpComponent.displayConfig.displayName}</displayName>
	
	<!-- human-readable name, not necessarily unique -->
	<detailText>
		${this.ucpComponent.displayConfig.detailText}
	</detailText>

	<!-- example of a linked resource, can also be embedded -->
	<displayImage href="${this.ucpComponent.displayConfig.displayImage.path}"></displayImage>

    <!-- NEW -->
	<!-- Refers to a class in a hierarchy. Name attribute values limited to the list of all possible class names. -->
	<!-- Default stereotype name defined in the XSD -->
	<stereotype name="Service"/>

	
	
	<unitList>
	<!-- default folders -->
		${{ 

			var This = Structr.this;
		
			var test= [];

			This.version.folders.forEach(function(f) {
				test.push(f);
			});


			test.forEach(function(f) {
				Structr.print(
"\n		<unit lifecycle='build'	type='Folder'   uuid='"+f.id+"'>./"+f.name+"</unit>"
				);
			});
		
		
		
		}}
	<!-- units.... -->
		${{ 

			var This = Structr.this;
		
			var test= [];

			This.version.ucpComponentDescriptor.units.forEach(function(f) {
				test.push(f);
			});


			test.forEach(function(f) {
				var fileDetails = Structr.from_json(Structr.to_json(f.file, "default"));
				fileDetails.id = f.file.id;
				fileDetails.type = f.file.type;
				
				Structr.print(
"\n		<unit lifecycle='"+f.lifecycle.name+"' type='"+f.unitType+"' name='"+f.name+"' uuid='"+f.id+"' href='"+f.href+"'>"+Structr.to_json(fileDetails)+"</unit>"
				);
			});
		
		
		
		}}
	<!-- default units....remove -->


		
		
		<unit type="someTypeString">value</unit>
		<unit type="maven:target:subTarget">string</unit>
		<unit type="WSDL-File" name="someWSDLunitName" href="reletive/path/to/Component.xml/file.wsdl"/>

		<unit lifecycle="build"					type="ant">build.xml</unit>
		<unit lifecycle="build"					type="ant::build">#!sh ant build</unit>
		<unit lifecycle="deploy"				type="ant::deploy">#!sh ant deploy</unit>
		<unit lifecycle="install"				type="apt-get">#!sh apt-get install thisComponent</unit>
		<unit lifecycle="install:configure"		type="ant::configure">#!sh ant configure</unit>
		<unit lifecycle="start"					type="sh">#!sh startServer -port ${server.port} -name MAIN</unit>
		<unit lifecycle="stop"					type="sh">#!sh stopServer -name MAIN</unit>
		<unit lifecycle="stop"					type="sh">#!sh stopServer -name MAIN</unit>
	</unitList>
	
	<interfaceList>
		${{ 

			var This = Structr.this;
		
			var test= [];

			This.version.ucpComponentDescriptor.implements.forEach(function(f) {
				test.push(f);
			});


			test.forEach(function(f) {
				Structr.print(
"\n		<interface type='"+f.InterfaceType+"' name='"+f.name+"' uuid='"+f.id+"'>"+Structr.to_json(f.specificationUnits, "default")+"</interface>"
				);
			});
		
		
		
		}}
	<!-- default interfaces....remove -->

		<interface type="Semantic" name="Object"/>
		<interface type="Semantic" name="List"/>
		<interface type="Semantic" name="Tree"/>

		<interface type="WSDL" unitName="someWSDLunitName"/>

	<!-- default properties....remove -->
		<property key="some.property.key"/>
		<property key="server.port"/>
	</interfaceList>

	<package> 
		${{ 
			var that = Structr.get("this");
		
			var test= [];

			that.ucpComponent.folders.forEach(function(f) {
				test.push(f);
			});


			test.forEach(function(f) {
				if( f.type === "UcpComponent") { 
					Structr.print(
"\n		<componentRef name='"+f.package+"."+f.name+"' version='"+that.version.name+"' minVersion='"+that.version.name+"' maxVersion='"+f.latestVersion.name+"'/>"
					);
				}
			});
		
		
		}}
	</package>

	
		${{ 
			var This = Structr.this;
		
			var test= [];

			This.version.ucpComponentDescriptor.uses.forEach(function(f) {
				test.push(f);
			});


			test.forEach(function(f) {
				if( f.type === "UcpComponentDescriptor") { 
					Structr.print(
"\n		<dependency type='requires' name='"+f.ucpComponent.package+"."+f.ucpComponent.className+"' version='"+f.version.name+"' minVersion='0.0.0' uuid='"+f.id+"'/>"
					);
				}
			});
		
		
		}}
<!--  default dependencies....remove  -->
	<dependency type="requires" name="" version=""/>
	<dependency version="" name="" type="requires"/>
	<dependency type="requires" name="SLES.OS" version="12.0.1.123" minVersion="12.0.1.0"/>

</ucp:component>
