I am trying to create a chain which holds a document.
I have created the asset in the model file as
asset document identified by documentid {
o String documentid
o String formImageBase64 //will use IPFS Later
o String nameOfSignator
o String addressOfSignator
o Integer ageOfSignator
o Boolean isSigned
o DateTime dateTimeOfSigning
}
And there are multiple documents containing information of different people.
If the document is updated(new asset is created), How to show a link between the old document and the updated document.
Update
Changing Title from "Creating Application Form using Hyperledger Composer"
To "Chaining/Connecting updated assets in Hyperledger Composer"
I don't know what type of relation you want to show between the past documents and the new documents but if you want to show the historical information of the transactions then you can use HistorianRecord
On the New Updating document, I added a new string which contains the unique "document of the previous string. Making it kind of a singly linked list.
asset document identified by documentid {
o String documentID
o String previousDocumentID // optional(later) original document "0" for now
o String formImageBase64 //will use IPFS Later
o String nameOfSignator
o String addressOfSignator
o Integer ageOfSignator
o Boolean isSigned
o DateTime dateTimeOfSigning
}
This way I can chain documents together.
Related
I have a code that gets a WI Type [Code Review Response]. When trying to get the Created By field of the WI
field = {[System.CreatedBy, Microsoft.VisualStudio.Services.WebApi.IdentityRef]}
or Reviewed By, or Closed By field of the WI, I am getting the string Microsoft.VisualStudio.Services.WebApi.IdentityRef and not the user name.
It seems there is another, lower level object in it that holds the user data...
How can i get into the user name and details?
For example, when I trying the following code:
WorkItem linked_WI = witClient.GetWorkItemAsync(linked_WI_ID).Result;
//set WI object to the linked WI
string linked_WI_Type = linked_WI.Fields["System.WorkItemType"].ToString();
if (linked_WI_Type == "Code Review Response")
{
string codereview_closed_status = linked_WI.Fields["Microsoft.VSTS.CodeReview.ClosedStatus"].ToString();
string codereview_reviewer = linked_WI.Fields["Microsoft.VSTS.Common.ReviewedBy"].ToString();
}
I am not getting the reviewer name but again the identity reference (Microsoft.VisualStudio.Services.WebApi.IdentityRef) as string.
How can I loop into the Idefntify Ref object and get the user name?
Try DisplayName property of IdentityRef object:
var person = (IdentityRef)linked_WI.Fields["Microsoft.VSTS.Common.ReviewedBy"];
string codereview_reviewer = person.DisplayName;
I am developing a blockchain application using Hyperledger Composer.
This is a part of my model i.e. .cto file:
concept Address{
o String addressId
o String PersonInChargeFullName
o String title
o String address1
o String address2 optional
o String city
o String country
o String zipcode regex=/^\d{5}$/
o String phone regex=/^\s*(?:\+?(\d{1,3}))?[-. (]*(\d{3})[-. )]*(\d{3})[-. ]*(\d{4})(?: *x(\d+))?\s*$/
o String email regex=/^([a-zA-Z0-9_\-\.]+)#([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/
o Boolean isActive default=true
}
abstract participant Company identified by companyId{
o String companyId
o String companyName
o Address defaultAddress
}
participant OEM extends Company {
o Address[] plants
}
From this page, I understand that if we use optional as a field validator, which means that that field is optional, and others are not. Am I right?
Although, I have not made PersonInChargeFullName as optional, when I submit the data (for eg: "PersonInChargeFullName": "",) from composer-rest-server API, the transaction gets processed, without any error.
Please advise.
Here option is little bit of different concept try running your code without PersonInChargeFullName field not as PersonInChargeFullName = "" but don't include it in json input i am pretty sure you will get error.
I have made a query in Hyperledger Composer where in the query tries to search for all invoices of a borrower. The borrower is a participant of the invoice asset:
asset Invoice identified by invoiceId {
o String invoiceId
o String invoiceRef optional
o DateTime dateCreated
o String type
o DateTime invoiceOrPurchaseDate optional
o Double amount
o DateTime invoiceDueDate optional
o String paymentStatus optional
o Boolean overdue
o Double outstandingBalance
--> Participant borrower
--> Participant lender
}
I need a query that will return all invoices of a borrower and I did this in Hyperledger composer by coding below:
query QInvoiceByBorrower {
description: "Select invoice by borrower"
statement:
SELECT org.n.blockchaindemo.Invoice
WHERE (_$borrower == borrower)
}
But when I try to call the query through REST API, I get [] empty result as below:
http://10.10.4.244:3000/api/queries/QInvoiceByBorrower?borrower=resource:org.n.blockchaindemo.User#1381991
May I know how to create a query that will search using a foreign relation in Hyperledger Composer?
In you Invoice definition you need to refer to your specific Participant type i.e. User rather that the system type Participant. So the last part of your Invoice will be:
o Double outstandingBalance
--> User borrower
--> User lender
}
With this change your Query should work. A useful diagnostic method is to create a duplicate query without the where clause and then examine the returned data to help understand the parameters to use for a query.
(By using Participant I think your asset will include the first participant type in your model at the time the asset type was first used - this sounds like it could generate some unexpected behaviours, so specifying the actual participant type makes sense.)
I am using few StoredField and few TextField in my indexing (Lucene 6.2.1)
for every document I have my own unique ID
if I create field as
Field docID = new TextField("docID", docId, Field.Store.YES);
I am able to delet document like following
Field transactionIdField = new TextField("transactionId", transactionId, Field.Store.YES);
Term docIdTerm = new Term("docID", docId);
Analyzer analyzer = new StandardAnalyzer();
IndexWriterConfig iwc = new IndexWriterConfig(analyzer);
iwc.setOpenMode(OpenMode.CREATE_OR_APPEND);
IndexWriter writer = repositoryWriters.getTargetIndexWriter(repositoryUuid);
// 4. remove document with docId
writer.deleteDocuments(docIdTerm);
LOG.log(Level.INFO, "Document removed from Index, docID: {0}", docId);
writer.commit();
But if I create field as
Field docID = new SttoredField("docID", docId);
the document is not deleted
How can I delete a document based on a Stored Field Value?
I want to keep it a StoredField so tat users can not search teh document based on docID
Quoting StoredField documentation,
A field whose value is stored so that IndexSearcher.doc and
IndexReader.document() will return the field and its value.
i.e. it would simply be a stored field for a document and there would be no Terms or Indexing for this field.
Method, IndexWriter.deleteDocuments(Term...terms) wouldn't find that document since there will be no Term for a StoredField.
A TextField on the other hand is indexed and terms generated for it,
A field that is indexed and tokenized, without term vectors. For
example this would be used on a 'body' field, that contains the bulk
of a document's text.
A stored TextField is indexed as well as stored so terms are available and value is stored to re construct the document too.
So in sumamry, you can't delete a document on the basis of only a StoredField , you need an indexed field too - with same name to be able to delete it.
I'm currently working with Sharepoint 2010 and Sharepoint API on creating a document library with some existing document lists.
I have created a WinForm that loops through a given doc lists and then add them to diffrent document libraries depending on 'Type(A metadata field)' of the document. Type is determined by reading the "Metadata fields" for the specific document. Metadata fields are read by creating Hashtable of SPFields
Question
When document metadata field is read to determin the 'Type', I have realised that the Metadatafield 'Type'(Key) actually pulls out as 'Type+TaxHTField0' and value for the Key pulls out as value|GUID
So for example if my Metadata field is called Doc_x0020_Type when it returns from the API it comes out as Doc_x0020_TypeTaxHTField0 the value for this should be just 'products' but it comes out as
products|21EC2020-3AEA-1069-A2DD-08002B30309D
Is there a setting we can set in sharepoint to eleminate adding extra charaters and GUID to both Key and Value for metadata fields?
Below is what I've done to rectify the issue, but wondered if it's a setting we can set in sharepoint
public String GetLibrary(Hashtable itemProperties)
{
String typeMetaField = "Doc_x0020_TypeTaxHTField0";
String sKey = String.Empty;
foreach (DictionaryEntry deEntry in itemProperties)
{
sKey = deEntry.Key.ToString();
if (sKey == typeMetaField){
_type = deEntry.Value.ToString();
string[] value = _type.Split('|');
_type = value[0].Trim();
}
}
return GetDocumentLibrary(_type);
}
This is by design.
If you add a taxonomy field to your own contenttype (for instance named 'MyTaxField') SharePoint will autogenerate a hidden 'Notes' field that contains the label and the guid of the values you select in the UI.
This is quite helpful when using SPSiteDataQuery since it will return empty values for taxonomy fields that allow multiple values (works with single value taxonomy fields though).
The only way to get the taxonomy values is to have a for the hidden field named 'MyTaxFieldTaxHTField0'.
But as you have discovered, this field might not be formatted as youd like :).
I have not tested this, but did you check if your contenttype contains a field called "Doc_x0020_Type" (possible of type TaxonomyFieldValue(Collection))?