public void Constructor() { TaxonRevision taxonRevision; taxonRevision = new TaxonRevision(); Assert.IsNotNull(taxonRevision); }
/// <summary> /// Create revision for taxon revision /// </summary> /// <param name="userContext">Applicaton user context ie Dyntaxa application user</param> /// <param name="revisionTaxon">Taxon that is adressed in this revision.</param> /// <param name="revisionDescription"></param> /// <returns></returns> public ITaxonRevision InitRevision(IUserContext userContext, ITaxon revisionTaxon, string revisionDescription, DateTime startDate, DateTime endDate) { try { ITaxonRevisionState taxonRevisionState = new TaxonRevisionState() { Id = (int)TaxonRevisionStateId.Created, Identifier = TaxonRevisionStateId.Created.ToString() }; List <IReferenceRelation> referenceRelations = new List <IReferenceRelation>(); List <ITaxonRevisionEvent> revisionEvents = new List <ITaxonRevisionEvent>(); ITaxonRevision taxonRevision = new TaxonRevision(); taxonRevision.RootTaxon = revisionTaxon; taxonRevision.State = taxonRevisionState; taxonRevision.ExpectedEndDate = endDate; taxonRevision.ExpectedStartDate = startDate; taxonRevision.SetReferences(referenceRelations); taxonRevision.SetRevisionEvents(revisionEvents); taxonRevision.Description = revisionDescription; return(taxonRevision); } catch (Exception e) { throw new Exception(e.Message, e.InnerException); } }
private TaxonRevision GetRevision(Boolean refresh) { if (_taxonRevision.IsNull() || refresh) { _taxonRevision = new TaxonRevision(); } return(_taxonRevision); }
/// <summary> /// Gets a RevisionEvent for test TODO: for now this event exist in DB /// </summary> /// <returns></returns> public ITaxonRevisionEvent GetReferenceRevisionEvent(IUserContext userContext, int i = 0) { ITaxonRevisionEvent revEvent = new TaxonRevisionEvent(); IUser user = new User(userContext); ITaxonRevision rev = new TaxonRevision(); user.Id = userContext.User.Id; revEvent.CreatedBy = user.Id; revEvent.CreatedDate = DateTime.Now; revEvent.RevisionId = rev.Id; return(revEvent); }
/// <summary> /// Creates a new Revision and make CheckOut /// </summary> /// <param name="taxon">The taxonId</param> /// <returns></returns> public TaxonRevision GetRevisionInOngoingState(IUserContext userContext, ITaxon taxon) { var revision = new TaxonRevision(); revision.RootTaxon = taxon; revision.State = new TaxonRevisionState() { Id = 1, Identifier = TaxonRevisionStateId.Created.ToString() }; revision.ExpectedEndDate = DateTime.Now; revision.ExpectedStartDate = DateTime.Now; revision.CreatedBy = userContext.User.Id; revision.CreatedDate = DateTime.Now; revision.SetReferences(new List <IReferenceRelation>()); revision.SetRevisionEvents(new List <ITaxonRevisionEvent>()); SaveTaxonRevision(userContext, revision); var revisionId = revision.Id; CheckOutTaxonRevision(userContext, revision); return(revision); }
/// <summary> /// Gets a Revision for test /// </summary> /// <returns></returns> public ITaxonRevision GetReferenceRevision(IUserContext userContext, int taxonId, string state) { ITaxonRevisionEvent revEvent = new TaxonRevisionEvent(); IUser user = new User(userContext); ITaxonRevision rev = new TaxonRevision(); user.Id = userContext.User.Id; revEvent.CreatedBy = user.Id; revEvent.CreatedDate = DateTime.Now; if (state.Equals("Created")) { revEvent.Type = new TaxonRevisionEventType() { Description = "", Id = 1, Identifier = "" }; } else if (state.Equals("Ongoing")) { revEvent.Type = new TaxonRevisionEventType() { Description = "", Id = 2, Identifier = "" }; } else { revEvent.Type = new TaxonRevisionEventType() { Description = "", Id = 3, Identifier = "" }; } revEvent.RevisionId = rev.Id; List <ITaxonRevisionEvent> revisionEventList = new List <ITaxonRevisionEvent>(); revisionEventList.Add((TaxonRevisionEvent)revEvent); rev.CreatedBy = user.Id; rev.CreatedDate = DateTime.Now; rev.ExpectedEndDate = new DateTime(2447, 08, 01); rev.ExpectedStartDate = DateTime.Now; if (state.Equals("Created")) { rev.State = new TaxonRevisionState() { Id = 1, Identifier = TaxonRevisionStateId.Created.ToString() }; rev.Guid = DyntaxaTestSettings.Default.TestRevisionGUID; rev.Id = DyntaxaTestSettings.Default.TestRevisionId; rev.Description = "My revision no " + DyntaxaTestSettings.Default.TestRevisionId; } else if (state.Equals("Ongoing")) { rev.State = new TaxonRevisionState() { Id = 2, Identifier = TaxonRevisionStateId.Ongoing.ToString() }; rev.Guid = DyntaxaTestSettings.Default.TestRevisionOngoingGUID; rev.Id = DyntaxaTestSettings.Default.TestRevisionOngoingId; rev.Description = "My revision no " + DyntaxaTestSettings.Default.TestRevisionOngoingId; } else { rev.State = new TaxonRevisionState() { Id = 3, Identifier = TaxonRevisionStateId.Closed.ToString() }; rev.Guid = DyntaxaTestSettings.Default.TestRevisionPublishedGUID; rev.Id = DyntaxaTestSettings.Default.TestRevisionPublishedId; rev.Description = "My revision no " + DyntaxaTestSettings.Default.TestRevisionPublishedId; } rev.SetRevisionEvents(revisionEventList); rev.RootTaxon = GetReferenceTaxon(userContext, taxonId); return(rev); }
public RevisionTest() { _taxonRevision = null; }