hyperledger-composer操场中的预期资源或概念

时间:2019-04-07 06:44:33

标签: hyperledger-composer

我在游乐场hyperledger-composer中说“预期资源或概念”时出错 两名参加者 1.学校 2.公司

两项资产 1.成绩单 2. Transcript_status

一个交易更新状态: •将学生的笔录状态从“未读”更新为“不感兴趣”或“不感兴趣”

参加学校,学生,公司 资产笔录,Transcript_status 交易更新状态

  1. 学校创建一所参与学校
  2. 公司创建参与公司
  3. 学校创建资产记录本
  4. 公司创建资产transcript_status

工作流程:创建学生的资产(成绩单)后,学校可以将记录上传到其网站上,公司可以查看第一个资产成绩单。之后,公司可以提交事务Transcript_status并标记为已读。然后,资产Transcript_status将从未读更新为已读。

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Definition of a Bond, based on the FpML schema:
 * http://www.fpml.org/spec/fpml-5-3-2-wd-2/html/reporting/schemaDocumentation/schemas/fpml-asset-5-3_xsd/elements/bond.html
 *
 */
namespace org.school.education

participant School identified by Schoolid {
  o String Schoolid
  o String name
}

participant Company identified by Companytid {
  o String Companytid
  o String name
}

participant Student identified by Studentid {
  o String Studentid
  o String studentName
  o String ClassofYear
}

asset Transcript identified by tId{
  o String tId
  o String name
  o String ClassofYear
  o String gpa
  o String major
  o String jobexp optional
  o String nationality
  o Boolean readStatus default=false
  --> School school
}

asset TranscriptStatus identified by tsId{
  o String tsId
  o String name
  o String status
  o String ReviewedCompany
  --> Company company
}

transaction UpdateTranscript_status {
  o String studentName
  o Boolean readStatus default=false
  --> School school
}

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* global getAssetRegistry */

'use strict';
/**
 * Process a property that is held for sale
 * @param {org.school.education.UpdateTranscript_status} updateTranscript the transcript to be updated
 * @transaction
 */
async function transcriptForUpdated(TforUpdated) {   // eslint-disable-line no-unused-vars
    console.log('### transcriptForUpdated ' + TforUpdated.toString());
    TforUpdated.readStatus = true;

    const registry = await getAssetRegistry('org.school.education.Transcript');
    await registry.update(TforUpdated.readStatus);
}

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Sample access control list.
 */
rule EverybodyCanReadEverything {
    description: "Allow all participants read access to all resources"
    participant: "org.school.education.School"
    operation: READ
    resource: "org.school.education.*"
    action: ALLOW
}

rule EverybodyCanSubmitTransactions {
    description: "Allow all participants to submit transactions"
    participant: "org.school.education.School"
    operation: CREATE
    resource: "org.schoo;.education.UpdateTranscript_status"
    action: ALLOW
}

rule OwnerHasFullAccessToTheirAssets {
    description: "Allow all participants full access to their assets"
    participant(p): "org.school.education.School"
    operation: ALL
    resource(r): "org.school.education.Transcript"
    condition: (r.owner.getIdentifier() === p.getIdentifier())
    action: ALLOW
}



rule SystemACL {
    description: "System ACL to permit all access"
    participant: "org.hyperledger.composer.system.Participant"
    operation: ALL
    resource: "org.hyperledger.composer.system.**"
    action: ALLOW
}

rule NetworkAdminUser {
    description: "Grant business network administrators full access to user resources"
    participant: "org.hyperledger.composer.system.NetworkAdmin"
    operation: ALL
    resource: "**"
    action: ALLOW
}

rule NetworkAdminSystem {
    description: "Grant business network administrators full access to system resources"
    participant: "org.hyperledger.composer.system.NetworkAdmin"
    operation: ALL
    resource: "org.hyperledger.composer.system.**"
    action: ALLOW
}

1 个答案:

答案 0 :(得分:0)

根据我的理解,我运行您的代码。我已经解决了一些问题。在您的代码中,您可以在readStatus transcript下更新asset。如果您在资产更新一个值,则需要将该资产的对象放入更新函数。

1。模型文件更改:

transaction UpdateTranscript_status {
  o Boolean readStatus default=false
  --> Transcript transcript
}

2。 logic.js的更改:

async function transcriptForUpdated(TforUpdated) { 
  // eslint-disable-line no-unused-vars
    TforUpdated.readStatus = true;

  TforUpdated.transcript.readStatus = TforUpdated.readStatus;


    const registry = await getAssetRegistry('org.school.education.Transcript');
    await registry.update(TforUpdated.transcript);
}

运行此事务后,它将在Transcript asset下更新一个readStatus( true false 值更新)。

希望它将解决您的问题:)