public static Artifact GetOrCreateArtifact(IList<Artifact> artifacts, string id)
        {
            foreach (Artifact a in artifacts)
            {
                if (a.Id == id)
                {
                    return a;
                }
            }

            Artifact art = new Artifact(GENERIC_GROUP, id);
            artifacts.Add(art);
            return art;
        }
        public static ItemVersion GetOrCreateVersion(Artifact artifact, string version)
        {
            foreach (ItemVersion iv in artifact.Versions)
            {
                if (iv.Id == version)
                {
                    return iv;
                }
            }

            ItemVersion ver = new ItemVersion(version, artifact);
            artifact.Versions.Add(ver);
            return ver;
        }
        public IList<ItemVersion> GetVersions(string groupId, Artifact artifact)
        {
            string url = getVersionsUrl(groupId, artifact.Id);
            string versionsString = _client.DownloadString(url);
            VersionsListing vl = _serializer.Deserialize<VersionsListing>(versionsString);
            IList<ItemVersion> versions = new List<ItemVersion>();

            foreach (VersionsDoc doc in vl.response.docs)
            {
                ItemVersion iv = new ItemVersion(doc.v, artifact);
                iv.Items = getItems(iv, doc.ec);
                if (iv.Items.Count > 0)
                    versions.Add(iv);
            }
            return versions;
        }
        public IList<Artifact> GetArtifacts(string groupId)
        {
            string url = getArtifactsUrl(groupId);
            string artifactsString = _client.DownloadString(url);
            ArtifactsListing al = _serializer.Deserialize<ArtifactsListing>(artifactsString);

            IList<Artifact> artifacts = new List<Artifact>();
            foreach (ArtifactsDoc doc in al.response.docs)
            {
                Artifact artifact = new Artifact(groupId, doc.a);
                IList<ItemVersion> versions = GetVersions(groupId, artifact);
                artifact.Versions = versions;
                if(versions.Count > 0)
                    artifacts.Add(artifact);
            }
            return artifacts;
        }
 public ItemVersion NextVersion(Artifact artifact)
 {
     return new ItemVersion("Version: " + _nextVersion++, artifact);
 }
 public UIArtifact(Artifact artifact)
 {
     ArtifactModel = artifact;
     Versions = new List<UIItemVersion>();
 }
 public ItemVersion(string id, Artifact artifact)
 {
     Id = id;
     Items = new List<Item>();
     ParentArtifact = artifact;
 }