package core;

/**
 * Created by nwilson on 2/19/15.
 */

import sun.reflect.generics.reflectiveObjects.NotImplementedException;

import java.io.File;
import java.util.*;

/**
 * Represents a completed pipeline with all of it's artifacts
 *
 * TODO make this an abstract class with two subclasses (baselines and real pipe)?
 */
public class Pipe {

    // an inversion of the artifact->aid mapping that's in the artifact itself
    private final Map<Artifact_ID, Artifact> mpaid_artifact;

    private Pipe(Iterable<Artifact> artifacts) {
        this.mpaid_artifact = new HashMap<Artifact_ID, Artifact>();

        for (Artifact artifact : artifacts) {
            mpaid_artifact.put(artifact.aid, artifact);
        }
    }

    /**
     * Creates a pipe by recursively scanning the artifact metadata in the directory rooted at the directory argument.
     *
     * @param directory: root of the file hierarchy
     * @return a Pipe
     */
    public static Pipe FromDirectory(File directory) {
        // TODO implement
        throw new NotImplementedException();
    }
}

@@ -491,233 +491,1433 @@
     
-private Pipe(Iterable%3CArtifact%3E artifacts) %7B%0A        this.mpaid_artifact = new HashMap%3CArtifact_ID, Artifact%3E();%0A%0A        for (Artifact artifact : artifacts) %7B%0A            mpaid_artifact.put(artifact.aid, artifact);%0A        %7D
+// name -%3E aid lookup%0A    private final Map%3CString, Artifact_ID%3E mpname_artifactID;%0A    private static final Artifact_ID aidAmbiguous = new Artifact_ID(null, null, null);%0A%0A    private final Map%3CUUID, Artifact_ID%3E mpuuid_artifactID;%0A%0A    private Pipe(Iterable%3CArtifact%3E artifacts) %7B%0A        this.mpaid_artifact = new HashMap%3CArtifact_ID, Artifact%3E();%0A        this.mpname_artifactID = new HashMap%3CString, Artifact_ID%3E();%0A        this.mpuuid_artifactID = new HashMap%3CUUID, Artifact_ID%3E();%0A%0A        for (Artifact artifact : artifacts) %7B%0A            mpaid_artifact.put(artifact.aid, artifact);%0A            if (mpname_artifactID.containsKey(artifact.aid.name)) %7B%0A                mpname_artifactID.put(artifact.aid.name, aidAmbiguous);%0A            %7D%0A            else %7B%0A                mpname_artifactID.put(artifact.aid.name, artifact.aid);%0A            %7D%0A            // TODO check for duplicates and throw if there are any%0A            mpuuid_artifactID.put(artifact.aid.uuid, artifact.aid);%0A        %7D%0A    %7D%0A%0A    public Artifact_ID ArtifactIDFromName(String name) %7B%0A        Artifact_ID aid = mpname_artifactID.get(name);%0A        if (aid == aidAmbiguous) %7B%0A            System.err.println(%22Artifact name %22 + name + %22 is ambiguous. Please refer to artifact by UUID instead%22);%0A            return null;%0A        %7D%0A        return aid;%0A    %7D%0A%0A    public Artifact_ID ArtifactIDFromUUID(UUID uuid) %7B%0A        return mpuuid_artifactID.get(uuid);
 %0A   

Add some more inversions to pipe