Skip to content

Commit

Permalink
UIDs were promoted to first-class citizens
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcota committed May 6, 2018
1 parent a984dfd commit 4d42bc1
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 22 deletions.
17 changes: 13 additions & 4 deletions Land.Registration/Certification/Certificate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,15 @@ public CertificateType CertificateType {
}

[DataField("CertificateUID", IsOptional = false)]
public string UID {
get;
private set;
private string _certificateUID = String.Empty;

public override string UID {
get {
return _certificateUID;
}
}


[DataField("TransactionId", IsOptional = false)]
public LRSTransaction Transaction {
get;
Expand Down Expand Up @@ -370,11 +374,16 @@ protected override void OnLoadObjectData(System.Data.DataRow row) {
this.ExtensionData = CertificateExtData.Parse((string) row["CertificateExtData"]);
}

protected override void OnBeforeSave() {
if (this.IsNew) {
this._certificateUID = CertificatesData.BuildCertificateUID();
}
}

protected override void OnSave() {
if (this.IsNew) {
this.PostingTime = DateTime.Now;
this.PostedBy = Contact.Parse(ExecutionServer.CurrentUserId);
this.UID = CertificatesData.BuildCertificateUID();
}
if (this.Status != CertificateStatus.Deleted &&
this.Status != CertificateStatus.Canceled) {
Expand Down
17 changes: 13 additions & 4 deletions Land.Registration/RootTypes/RecordingDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,15 @@ public LRSDocumentType Subtype {
}

[DataField("DocumentUID", IsOptional = false)]
public string UID {
get;
private set;
private string _documentUID = String.Empty;

public override string UID {
get {
return _documentUID;
}
}


[DataField("ImagingControlID")]
public string ImagingControlID {
get;
Expand Down Expand Up @@ -538,11 +542,16 @@ protected override void OnLoadObjectData(DataRow row) {
this.ExtensionData = RecordingDocumentExtData.Parse((string) row["DocumentExtData"]);
}

protected override void OnBeforeSave() {
if (this.IsNew) {
this._documentUID = DocumentsData.GenerateDocumentUID();
}
}

protected override void OnSave() {
if (this.IsNew) {
this.PostingTime = DateTime.Now;
this.PostedBy = Contact.Parse(ExecutionServer.CurrentUserId);
this.UID = DocumentsData.GenerateDocumentUID();
}
RecordingBooksData.WriteRecordingDocument(this);
}
Expand Down
17 changes: 10 additions & 7 deletions Land.Registration/RootTypes/Resource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ static public bool IsResourceEditingRole(ResourceRole resourceRole) {
#region Public properties

[DataField("PropertyUID", IsOptional = false)]
public string UID {
get;
private set;
private string _propertyUID = String.Empty;

public override string UID {
get {
return _propertyUID;
}
}

internal protected virtual string Keywords {
Expand Down Expand Up @@ -286,7 +289,7 @@ internal void AssertIsStillAlive(RecordingDocument document) {

abstract protected string GenerateResourceUID();

protected override void OnBeforeSave() {
protected override void OnBeforeSave() {
if (this.IsNew) {
this.AssignUID();
this.PostedBy = Contact.Parse(ExecutionServer.CurrentUserId);
Expand Down Expand Up @@ -322,16 +325,16 @@ internal void TryDelete() {
#region Private methods

private void AssignUID() {
Assertion.Assert(this.UID.Length == 0, "Property has already assigned a UniqueIdentifier.");
Assertion.Assert(this._propertyUID.Length == 0, "Property has already assigned a UniqueIdentifier.");

while (true) {
string temp = this.GenerateResourceUID();
if (!ResourceData.ExistsResourceUID(temp)) {
this.UID = temp;
this._propertyUID = temp;
break;
}
} // while
Assertion.Assert(this.UID.Length != 0, "Property UniqueIdentifier has not been generated.");
Assertion.Assert(this._propertyUID.Length != 0, "Property UniqueIdentifier has not been generated.");
}

private bool HasCompleteInformation() {
Expand Down
18 changes: 12 additions & 6 deletions Land.Registration/Transactions/LRSTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,13 @@ public LRSTransactionType TransactionType {
private set;
}

[DataField("TransactionUID", Default = "Nuevo trámite", IsOptional = false)]
public string UID {
get;
private set;
[DataField("TransactionUID", IsOptional = false)]
private string _transactionUID = "Nuevo trámite";

public override string UID {
get {
return _transactionUID;
}
}

[DataField("DocumentTypeId")]
Expand Down Expand Up @@ -485,10 +488,13 @@ internal void OnRecordingActsUpdated() {
this.UpdateComplexityIndex();
}

protected override void OnSave() {
protected override void OnBeforeSave() {
if (base.IsNew) {
this.UID = TransactionData.GenerateTransactionUID();
this._transactionUID = TransactionData.GenerateTransactionUID();
}
}

protected override void OnSave() {
this.Keywords = EmpiriaString.BuildKeywords(this.UID, this.Document.UID,
this.DocumentDescriptor, this.RequestedBy,
this.Agency.FullName,
Expand Down
2 changes: 1 addition & 1 deletion Land.WebAPI/Citys/CitysHttpEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static public FixedList<CitysHttpEndpoint> GetList() {
#region Properties

/// <summary>Unique ID string for the Http Endpoint.</summary>
public string UID {
public override string UID {
get {
return base.NamedKey;
}
Expand Down

0 comments on commit 4d42bc1

Please sign in to comment.