public Asset(Oid oid) { if(oid.IsNull) { throw new ArgumentOutOfRangeException("oid", oid, "Cannot initialize Asset with NULL Oid"); } this.oid = oid; assetType = oid.AssetType; }
public void WriteOid(Oid oid) { writer.WriteStartElement("Asset"); if(!oid.IsNull) { writer.WriteAttributeString("id", oid.Token); } writer.WriteEndElement(); }
protected void ExecuteOperationInV1(string Operation, Oid AssetOID) { try { IOperation operation = _metaAPI.GetOperation(Operation); Oid oid = _dataAPI.ExecuteOperation(operation, AssetOID); } catch (APIException ex) { return; } }
public Query(Oid oid, bool historical) { Find = null; if(oid.IsNull) { throw new ApplicationException("Invalid Query OID Parameter"); } if(oid.HasMoment && historical) { throw new NotSupportedException("Historical Query with Momented OID not supported"); } isHistorical = historical; assetType = oid.AssetType; this.oid = oid; }
public Query(IAssetType assetType, bool historical, IAttributeDefinition parentRelation) { Find = null; this.assetType = assetType; isHistorical = historical; oid = Oid.Null; this.parentRelation = parentRelation; if (this.parentRelation != null) { if(this.parentRelation.AttributeType != AttributeType.Relation) { throw new ApplicationException("Parent Relation must be a Relation Attribute Type"); } if(this.parentRelation.IsMultiValue) { throw new ApplicationException("Parent Relation cannot be multi-value"); } } }
public Oid ExecuteOperation(IOperation op, Oid oid) { var doc = new XmlDocument(); try { var path = "Data/" + oid.AssetType.Token + "/" + oid.Key + "?op=" + op.Name; using(var stream = connector.SendData(path, string.Empty)) { doc.Load(stream); } var asset = ParseAssetNode(doc.DocumentElement); return asset.Oid; } catch (WebException ex) { using(var stream = ex.Response.GetResponseStream()) { doc.Load(stream); } var message = doc.DocumentElement.SelectSingleNode("Message").InnerText; throw new APIException(message, oid.Token, ex); } catch (Exception ex) { throw new APIException("Failed to execute", oid.Token, ex); } }
public Asset New(IAssetType assetType, Oid context) { var doc = new XmlDocument(); var path = "New/" + assetType.Token; if(context != null && !context.IsNull) { path += "?ctx=" + context.Token; } try { using(var stream = connector.GetData(path)) { doc.Load(stream); } return ParseNewAssetNode(doc.DocumentElement, assetType); } catch (Exception ex) { throw new APIException("Failed to get new asset!", assetType.Token, ex); } }
public Asset New(IAssetType assetType, Oid context) { return _wrapped.New(assetType, context); }
protected internal ValueId(Oid oid, string name) { Oid = oid.Momentless; this.name = name; }
private Oid FindTimebox(Oid scheduleOid) { if((scheduleOid == null) || (scheduleOid.IsNull)) { return Oid.Null; } var timebox = (Oid)timeboxes[scheduleOid]; if(timebox == null) { timebox = Oid.Null; var q = new Query(TimeboxType); var scheduleTerm = new FilterTerm(TimeboxType.GetAttributeDefinition("Schedule")); scheduleTerm.Equal(scheduleOid); var assetStateTerm = new FilterTerm(TimeboxType.GetAttributeDefinition("AssetState")); assetStateTerm.Equal(AssetState.Active); q.Filter = new AndFilterTerm(scheduleTerm, assetStateTerm); q.OrderBy.MajorSort(TimeboxType.GetAttributeDefinition("EndDate"), OrderBy.Order.Ascending); q.Paging = new Paging(0, 1); var r = Services.Retrieve(q); if(r.Assets.Count != 0) { timebox = r.Assets[0].Oid; } timeboxes[scheduleOid] = timebox; } return timebox; }
public Oid ExecuteOperation(IOperation op, Oid oid) { return _wrapped.ExecuteOperation(op, oid); }
protected Asset CreateDefect(string name, string description, Oid scopeOid, Oid featureGroupOid, Oid teamOid, Oid sprintOid) { var defectNameDef = MetaModel.GetAttributeDefinition("Defect.Name"); var defectScopeDef = MetaModel.GetAttributeDefinition("Defect.Scope"); var defectDescDef = MetaModel.GetAttributeDefinition("Defect.Description"); var defectParentDef = MetaModel.GetAttributeDefinition("Defect.Parent"); var defectTeamDef = MetaModel.GetAttributeDefinition("Defect.Team"); var defectTimeBoxDef = MetaModel.GetAttributeDefinition("Defect.Timebox"); var assetDefect = new Asset(MetaModel.GetAssetType("Defect")); assetDefect.SetAttributeValue(defectNameDef, name); assetDefect.SetAttributeValue(defectScopeDef, scopeOid); assetDefect.SetAttributeValue(defectDescDef, description); if (featureGroupOid != null) { assetDefect.SetAttributeValue(defectParentDef, featureGroupOid.Momentless.Token); } if (teamOid != null) { assetDefect.SetAttributeValue(defectTeamDef, teamOid.Momentless.Token); } if (sprintOid != null) { assetDefect.SetAttributeValue(defectTimeBoxDef, sprintOid.Momentless.Token); } Services.Save(assetDefect); return assetDefect; }
private void UpdateOpenTest(Oid newStatus, Asset test) { var statusAttribute = test.GetAttribute(TestStatusDef); var statusOid = (Oid)statusAttribute.Value; if(newStatus != statusOid) { test.SetAttributeValue(TestStatusDef, newStatus); Services.Save(test, changeComment); Logger.Log(string.Format("Updating status of Acceptance Test \"{0}\".", test.Oid.Token)); } }
internal ValueId(Oid oid, string name, bool inactive) { Oid = oid.Momentless; this.name = name; this.inactive = inactive; }
public Query(Oid oid) : this(oid, false) {}
protected Asset CreateStory(string name, string description, Oid scopeOid, Oid featureGroupOid, Oid teamOid, Oid sprintOid) { var storyNameDef = MetaModel.GetAttributeDefinition("Story.Name"); var storyScopeDef = MetaModel.GetAttributeDefinition("Story.Scope"); var storyDescDef = MetaModel.GetAttributeDefinition("Story.Description"); var storyParentDef = MetaModel.GetAttributeDefinition("Story.Parent"); var storyTeamDef = MetaModel.GetAttributeDefinition("Story.Team"); var storyTimeBoxDef = MetaModel.GetAttributeDefinition("Story.Timebox"); var assetStory = new Asset(MetaModel.GetAssetType("Story")); assetStory.SetAttributeValue(storyNameDef, name); assetStory.SetAttributeValue(storyScopeDef, scopeOid); assetStory.SetAttributeValue(storyDescDef, description); if (featureGroupOid != null) { assetStory.SetAttributeValue(storyParentDef, featureGroupOid.Momentless.Token); } if (teamOid != null) { assetStory.SetAttributeValue(storyTeamDef, teamOid.Momentless.Token); } if (sprintOid != null) { assetStory.SetAttributeValue(storyTimeBoxDef, sprintOid.Momentless.Token); } Services.Save(assetStory); return assetStory; }
protected Asset LoadAsset(Oid oid, string assetTypeName, params string[] attribs) { var assetType = MetaModel.GetAssetType(assetTypeName); var query = new Query(oid); foreach(var attrib in attribs) { query.Selection.Add(assetType.GetAttributeDefinition(attrib)); } return Services.Retrieve(query).Assets[0]; }
protected Asset CreateSprint(string name, Oid scheduleOid) { var timeboxNameDef = MetaModel.GetAttributeDefinition("Timebox.Name"); var timeboxEndDateDef = MetaModel.GetAttributeDefinition("Timebox.EndDate"); var timeboxBeginDateDef = MetaModel.GetAttributeDefinition("Timebox.BeginDate"); var timeboxStateDef = MetaModel.GetAttributeDefinition("Timebox.State"); var timeboxScheduleDef = MetaModel.GetAttributeDefinition("Timebox.Schedule"); var assetTimeBox = new Asset(MetaModel.GetAssetType("Timebox")); assetTimeBox.SetAttributeValue(timeboxNameDef, name); assetTimeBox.SetAttributeValue(timeboxEndDateDef, DateTime.Now.AddDays(5)); assetTimeBox.SetAttributeValue(timeboxBeginDateDef, DateTime.Now); assetTimeBox.SetAttributeValue(timeboxStateDef, Oid.FromToken("State:100", MetaModel)); assetTimeBox.SetAttributeValue(timeboxScheduleDef, scheduleOid.Momentless.Token); Services.Save(assetTimeBox); return assetTimeBox; }
protected Asset CreateProject(string scopeName, Oid scheduleOid, string parentProjectToken) { var scopeNameDef = MetaModel.GetAttributeDefinition("Scope.Name"); var scopeParentIdDef = MetaModel.GetAttributeDefinition("Scope.Parent"); var scopeBeginDateDef = MetaModel.GetAttributeDefinition("Scope.BeginDate"); var scopeScheduleDef = MetaModel.GetAttributeDefinition("Scope.Schedule"); var assetScope = new Asset(MetaModel.GetAssetType("Scope")); assetScope.SetAttributeValue(scopeNameDef, scopeName); assetScope.SetAttributeValue(scopeParentIdDef, Oid.FromToken(parentProjectToken, MetaModel)); assetScope.SetAttributeValue(scopeBeginDateDef, DateTime.Now); if (scheduleOid != null) { assetScope.SetAttributeValue(scopeScheduleDef, scheduleOid.Momentless.Token); } Services.Save(assetScope); return assetScope; }
protected Asset CreateFeatureGroup(string name, Oid scopeOid, Oid parentFGroup) { var themeNameDef = MetaModel.GetAttributeDefinition("Theme.Name"); var themeScopeDef = MetaModel.GetAttributeDefinition("Theme.Scope"); var themeParentDef = MetaModel.GetAttributeDefinition("Theme.Parent"); var assetFGroup = new Asset(MetaModel.GetAssetType("Theme")); assetFGroup.SetAttributeValue(themeNameDef, name); assetFGroup.SetAttributeValue(themeScopeDef, scopeOid); if (parentFGroup != null) { assetFGroup.SetAttributeValue(themeParentDef, parentFGroup.Momentless.Token); } Services.Save(assetFGroup); return assetFGroup; }
public Oid GetOid(string token) { return(Oid.FromToken(token, metaModel)); }
private List<Asset> GetAssetLinks(Oid assetOid, IFilter filter) { var fullFilter = GroupFilter.And(filter, Filter.Equal(AssetAttribute, assetOid.Momentless)); return queryBuilder.Query(LinkType, fullFilter); }
private TestValueId(Oid oid, string name) : base(oid, name) { }
public Oid GetOid(string token) => Oid.FromToken(token, _meta);
public Query(Oid oid) : this(oid, false) { }
private void LoadOid(TestRun.TestRunState state, XmlElement config, Oid def) { var configkey = state.ToString() + "Oid"; var oidconfig = config[configkey]; var oidtoken = oidconfig != null ? oidconfig.InnerText : null; var oid = def; try { oid = Services.GetOid(oidtoken); } catch(OidException) { } //the oid is null-null or its not oid-null and we can't find it in the V1 system. (Oid.Null is ok!) if(oid == null) { throw new InvalidOperationException(string.Format("Invalid Oid Token for {0}: {1}", configkey, oidtoken)); } if(oid != Oid.Null) { if(oid.AssetType != TestStatusType) { throw new InvalidOperationException(string.Format("Oid for {0} is not a TestStatus Type: {1}", configkey, oidtoken)); } var q = new Query(oid.AssetType); var term = new FilterTerm(oid.AssetType.GetAttributeDefinition("Key")); term.Equal(oid.Key); q.Filter = term; var assetlist = Services.Retrieve(q).Assets; if(assetlist.Count == 0) { throw new InvalidOperationException(string.Format("TestStatus for {0} does not exist: {1}", configkey, oidtoken)); } } states.Add(state, oid); }