The URI's for air transportation now makes sense (we're not using the auto-gen URI's any longer). Makes it easier for users to identify which regions/systems air transport edges are connected to

git-svn-id: http://dev.eclipse.org/svnroot/technology/org.eclipse.stem/trunk/data@2291 92a21009-5b66-0410-b83a-dc787c41c6e9
diff --git a/geography/org.eclipse.stem.internal.data.geography.infrastructure.transportation/src/org/eclipse/stem/internal/data/geography/infrastructure/transportation/specifications/AirTransportationGeographicRelationshipPropertyFileSpecification.java b/geography/org.eclipse.stem.internal.data.geography.infrastructure.transportation/src/org/eclipse/stem/internal/data/geography/infrastructure/transportation/specifications/AirTransportationGeographicRelationshipPropertyFileSpecification.java
index 5a83852..b267a5e 100644
--- a/geography/org.eclipse.stem.internal.data.geography.infrastructure.transportation/src/org/eclipse/stem/internal/data/geography/infrastructure/transportation/specifications/AirTransportationGeographicRelationshipPropertyFileSpecification.java
+++ b/geography/org.eclipse.stem.internal.data.geography.infrastructure.transportation/src/org/eclipse/stem/internal/data/geography/infrastructure/transportation/specifications/AirTransportationGeographicRelationshipPropertyFileSpecification.java
@@ -39,6 +39,7 @@
 import org.eclipse.stem.definitions.transport.PipeTransportEdgeLabelValue;

 import org.eclipse.stem.definitions.transport.TransportFactory;

 import org.eclipse.stem.internal.data.geography.infrastructure.transportation.propertydata.AirTransportGeographicRelationshipPropertyData;

+import org.eclipse.stem.internal.data.geography.propertydata.GeographicRelationshipPropertyData;

 import org.eclipse.stem.internal.data.propertydata.PropertyData;

 import org.eclipse.stem.internal.data.propertydata.RelationshipPropertyData;

 

@@ -49,6 +50,9 @@
 public class AirTransportationGeographicRelationshipPropertyFileSpecification

 		extends TransportationGeographicRelationshipPropertyFileSpecification {

 

+	

+	public final static String AIR_TRANSPORT_PATTERN = "transport/pipe";

+	public final static String AIR_TRANSPORT_SYSTEM = "(S)";

 	/**

 	 * This is the name used to identify "air" edges.

 	 */

@@ -127,7 +131,7 @@
 		final TransportRelationshipLabel retValue = LabelsFactory.eINSTANCE

 				.createTransportRelationshipLabel();

 

-		// retValue.setURI(null);

+		retValue.setURI(createRelationshipEdgeLabelURI(relationshipGraphData));

 		final TransportRelationshipLabelValue currentValue = LabelsFactory.eINSTANCE

 				.createTransportRelationshipLabelValue();

 		currentValue.setAvailableDepartureCapacityProportion(airData.getArrivalRate()); // TODo, what is this?

@@ -144,6 +148,7 @@
 		return AIR_TRANSPORTATION_EDGE_NAME;

 	}

 

+   

 	/**

 	 * @see org.eclipse.stem.internal.data.specifications.IdentifiablePropertyFileSpecification#createPropertyDataInstanceFromProperty(java.lang.String,

 	 *      java.lang.String)

@@ -231,13 +236,13 @@
 			// The migration edge from the region to the transportation system

 			PipeTransportEdge fromEdge = createPipeTransportEdge(

 					regionNodeURI, transportSystem.getURI(),

-					fromNodeMaxFlow);

+					fromNodeMaxFlow, pipeTransportData);

 			graph.putEdge(fromEdge);

 			

 			// The migration edge to the region from the transportation system

 			PipeTransportEdge toEdge = createPipeTransportEdge(

 					transportSystem.getURI(), regionNodeURI,

-					toNodeMaxFlow);

+					toNodeMaxFlow, pipeTransportData);

 			graph.putEdge(toEdge);

 			

 			// Now create edges to the lower level transportation system. It might now

@@ -246,12 +251,12 @@
 			final org.eclipse.emf.common.util.URI transportNodeURI = createTransportSystemURI(pipeTransportData.getRegionISOKey());

 			fromEdge = createPipeTransportEdge(

 					transportNodeURI, transportSystem.getURI(),

-					fromNodeMaxFlow);

+					fromNodeMaxFlow, pipeTransportData);

 			graph.putEdge(fromEdge);

 			

 			toEdge = createPipeTransportEdge(

 					transportSystem.getURI(), transportNodeURI,

-					toNodeMaxFlow);

+					toNodeMaxFlow, pipeTransportData);

 			graph.putEdge(toEdge);

 		} // for each data set record

 	} // populateFromNonDataProperties

@@ -316,13 +321,15 @@
 

 	

 	private PipeTransportEdge createPipeTransportEdge(final org.eclipse.emf.common.util.URI fromURI,

-			final org.eclipse.emf.common.util.URI toURI, final double maxFlow) {

+			final org.eclipse.emf.common.util.URI toURI, final double maxFlow, AirTransportGeographicRelationshipPropertyData propertyData) {

 		final PipeTransportEdge edge = TransportFactory.eINSTANCE.createPipeTransportEdge();

 		edge.setNodeAURI(fromURI);

 		edge.setNodeBURI(toURI);

 

+		edge.setURI(createRelationshipEdgeURI(propertyData, fromURI, toURI));

 		PipeTransportEdgeLabel label =  TransportFactory.eINSTANCE.createPipeTransportEdgeLabel();

 		PipeTransportEdgeLabelValue labelval =  TransportFactory.eINSTANCE.createPipeTransportEdgeLabelValue();

+		label.setURI(createRelationshipEdgeLabelURI(propertyData, fromURI, toURI));

 		labelval.setMaxFlow(maxFlow);

 		labelval.setTimePeriod(this.rateTimePeriod);

 		label.setCurrentValue(labelval);

@@ -331,6 +338,36 @@
 		return edge;

 	} // createMigrationEdge

 	

+	private URI createRelationshipURI(String segment,

+			AirTransportGeographicRelationshipPropertyData propertyData,

+			URI fromURI, URI toURI) {

+		final GeographicRelationshipPropertyData geoRelationshipPropertyData = (GeographicRelationshipPropertyData) propertyData;

+		final StringBuilder sb = new StringBuilder(segment);

+		sb.append("/"); //$NON-NLS-1$

+		sb.append("relationship"); //$NON-NLS-1$

+		sb.append("/"); //$NON-NLS-1$

+		sb.append(getRelationshipName());

+		sb.append("/"); //$NON-NLS-1$

+		String first = fromURI.toString().contains(AIR_TRANSPORT_PATTERN) ? AIR_TRANSPORT_SYSTEM+fromURI.lastSegment() : fromURI.lastSegment();

+		sb.append(first);

+		sb.append("_"); //$NON-NLS-1$

+		String second = toURI.toString().contains(AIR_TRANSPORT_PATTERN) ? AIR_TRANSPORT_SYSTEM+toURI.lastSegment() : toURI.lastSegment();

+		sb.append(second);

+		sb.append(getRelationshipSpecifier(propertyData));

+

+		return STEMURI.createURI(sb.toString());

+	}

+

+	private URI createRelationshipEdgeLabelURI(	AirTransportGeographicRelationshipPropertyData propertyData,

+			URI fromURI, URI toURI) {

+		return createRelationshipURI("label", propertyData, fromURI, toURI);

+	}

+	private URI createRelationshipEdgeURI(

+			AirTransportGeographicRelationshipPropertyData propertyData,

+			URI fromURI, URI toURI) {

+		return createRelationshipURI("edge", propertyData, fromURI, toURI);

+	}

+

 	private Edge createContainmentEdge(

 			final AirTransportGeographicRelationshipPropertyData pipeTransportData,

 			final PipeStyleTransportSystem transportSystem) {