Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5b44a56
Minor version bump due required due to system models
jt-nti May 30, 2017
98e76c5
Work in progress
jt-nti May 30, 2017
4bc3ed6
merges
mbwhite Jun 9, 2017
700d4da
merges
mbwhite Jun 9, 2017
7c6abfb
Merge branch 'master' of github.com:hyperledger/composer into feature…
mbwhite Jun 12, 2017
3d33c9a
updates
mbwhite Jun 13, 2017
ccfcaba
merged in the 0.8.0 release
mbwhite Jun 16, 2017
c4acecc
first pass
mbwhite Jun 16, 2017
05bca9d
Merge branch 'master' of github.com:hyperledger/composer into feature…
mbwhite Jun 19, 2017
81c572e
Add Various Tests (#1311)
cazfletch Jun 19, 2017
7a6b0cc
Grammar, parser and model for queries (#1305)
dselman Jun 19, 2017
5d8d976
fixes to the decorate
mbwhite Jun 19, 2017
b6759c1
merges
mbwhite Jun 19, 2017
4c3ec77
fix tests
mbwhite Jun 19, 2017
f5cef98
test fixes
mbwhite Jun 19, 2017
1f81cc9
merges
mbwhite Jun 19, 2017
5c305ff
model fixes
mbwhite Jun 19, 2017
854c0b4
add auto scroll to selected item in list (#1307)
nklincoln Jun 19, 2017
4950b27
updates to tests
mbwhite Jun 19, 2017
9ec9bb8
Refactor and code tidy as part of #796 (#1296)
Jun 19, 2017
19e949a
drop in the detection script for live testing (#1286)
mbwhite Jun 20, 2017
3a418ac
remove rm from the insatgller (#1310)
mbwhite Jun 20, 2017
3a43770
Expose the select statement for a query (#1333)
Jun 20, 2017
8931b3b
Defect 1334 (#1335)
mbwhite Jun 20, 2017
2455422
Feature docs only (#1336)
mbwhite Jun 20, 2017
e2cc783
merges
mbwhite Jun 20, 2017
1235361
retrofitting unit tests
mbwhite Jun 20, 2017
ac095df
Merge branch 'master' of github.com:hyperledger/composer into feature…
mbwhite Jun 20, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 45 additions & 2 deletions .travis/before-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ sudo rm /usr/local/bin/docker-compose
curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
chmod +x docker-compose
sudo mv docker-compose /usr/local/bin
echo "Docker-compose version: "
echo "Docker-compose version: "
docker-compose --version

# Update docker
Expand All @@ -22,7 +22,7 @@ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce
echo "Docker version: "
echo "Docker version: "
docker --version

# Grab the parent (root) directory.
Expand Down Expand Up @@ -51,6 +51,49 @@ echo "->- Build cfg being used"
cat ${DIR}/build.cfg
echo "-<-"


######
# checking the changes that are in this file
echo "Travis commit range $TRAVIS_COMMIT_RANGE"
echo "Travis commit $TRAVIS_COMMIT"
echo "Travis event type $TRAVIS_EVENT_TYPE"


if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo -e "Build Pull Request #$TRAVIS_PULL_REQUEST => Branch [$TRAVIS_BRANCH]"
elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" == "" ]; then
echo -e 'Build Branch with Snapshot => Branch ['$TRAVIS_BRANCH']'
elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" != "" ]; then
echo -e 'Build Branch for Release => Branch ['$TRAVIS_BRANCH'] Tag ['$TRAVIS_TAG']'
else
echo -e 'WARN: Should not be here => Branch ['$TRAVIS_BRANCH'] Tag ['$TRAVIS_TAG'] Pull Request ['$TRAVIS_PULL_REQUEST']'
fi


cd $TRAVIS_BUILD_DIR
git diff --name-only $(echo $TRAVIS_COMMIT_RANGE | sed 's/\.//')

if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
git show --pretty=format: --name-only "$TRAVIS_COMMIT_RANGE"|sort|uniq > changedfiles.log
elif [ -n "$TRAVIS_PULL_REQUEST" ]; then
git diff --name-only "$TRAVIS_COMMIT" "$TRAVIS_BRANCH" > changedfiles.log
fi

RESULT=$(cat changedfiles | sed '/^\s*$/d' | awk '!/composer-website/ { print "MORE" }')
if [ "${RESULT}" == "" ];
then
echo "Only docs changes"
else
echo "More than docs changes"
fi
rm changedfiles.log

cd - > /dev/null
######




# Check of the task current executing
if [ "${FC_TASK}" = "docs" ]; then
echo Doing Docs - no requirement for installations of other software
Expand Down
1 change: 1 addition & 0 deletions packages/composer-common/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ out
# Build generated files should be ignored by git, but not by npm.
lib/acl/parser.js
lib/introspect/parser.js
lib/query/parser.js
index.d.ts
1 change: 1 addition & 0 deletions packages/composer-common/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ out
# Build generated files should be ignored by git, but not by npm.
# lib/acl/parser.js
# lib/introspect/parser.js
# lib/query/parser.js
# index.d.ts
12 changes: 8 additions & 4 deletions packages/composer-common/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class BusinessNetworkMetadata {
class Factory {
+ void constructor(ModelManager)
+ Resource newInstance(string,string,string,Object,boolean,string) throws ModelException
+ Resource newResource(string,string,string,Object,boolean,string) throws ModelException
+ Resource newConcept(string,string,Object,boolean,string) throws ModelException
+ Relationship newRelationship(string,string,string) throws ModelException
+ Resource newResource(string,string,string,Object,boolean,string) throws TypeNotFoundException
+ Resource newConcept(string,string,Object,boolean,string) throws TypeNotFoundException
+ Relationship newRelationship(string,string,string) throws TypeNotFoundException
+ Resource newTransaction(string,string,string,Object,string)
+ Resource newEvent(string,string,string,Object,string)
+ Object toJSON()
Expand All @@ -45,7 +45,7 @@ class FileWallet extends Wallet {
+ Promise remove(string)
}
class IllegalModelException extends BaseException {
+ void constructor(string,string,string)
+ void constructor(String,ModelFile,Object,String,String,String,String)
+ string getModelFile()
+ string getFileLocation()
}
Expand Down Expand Up @@ -117,6 +117,10 @@ class Serializer {
class ValidationException extends BaseException {
+ void constructor(string)
}
class TypeNotFoundException extends BaseException {
+ void constructor(String,String)
+ string getTypeName()
}
class Wallet {
+ Wallet getWallet()
+ void setWallet(Wallet)
Expand Down
5 changes: 5 additions & 0 deletions packages/composer-common/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
# Note that the latest public API is documented using JSDocs and is available in api.txt.
#

Version 0.7.6 {1dbfded54f54b7861b8eadb64d95f82a} 2017-06-14
- Added TypeNotFoundException
- Corrected JSDoc for IllegalModelException.constructor
- Corrected JSDoc for Factory.newRelationship

Version 0.7.5 {b2c1c30d370b04c153426500a03c3061} 2017-06-07
- Added optional JSZip options parameter to toArchive

Expand Down
8 changes: 7 additions & 1 deletion packages/composer-common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module.exports.AssetDeclaration = require('./lib/introspect/assetdeclaration');
module.exports.BaseException = require('./lib/baseexception');
module.exports.BusinessNetworkDefinition = require('./lib/businessnetworkdefinition');
module.exports.ClassDeclaration = require('./lib/introspect/classdeclaration');
module.exports.CodeGen = require('./lib/codegen/codegen.js');
module.exports.ComboConnectionProfileStore = require('./lib/comboconnectionprofilestore');
module.exports.Concept = require('./lib/model/concept');
module.exports.ConceptDeclaration = require('./lib/introspect/conceptdeclaration');
Expand All @@ -74,8 +75,11 @@ module.exports.Logger = require('./lib/log/logger');
module.exports.LoopbackVisitor = require('./lib/codegen/fromcto/loopback/loopbackvisitor');
module.exports.ModelFile = require('./lib/introspect/modelfile');
module.exports.ModelManager = require('./lib/modelmanager');
module.exports.OrderBy = require('./lib/query/orderby');
module.exports.ParticipantDeclaration = require('./lib/introspect/participantdeclaration');
module.exports.Property = require('./lib/introspect/property');
module.exports.Query = require('./lib/query/query');
module.exports.QueryFile = require('./lib/query/queryfile');
module.exports.Relationship = require('./lib/model/relationship');
module.exports.RelationshipDeclaration = require('./lib/introspect/relationshipdeclaration');
module.exports.Resource = require('./lib/model/resource');
Expand All @@ -84,11 +88,13 @@ module.exports.Script = require('./lib/introspect/script');
module.exports.ScriptManager = require('./lib/scriptmanager');
module.exports.SecurityContext = require('./lib/securitycontext');
module.exports.SecurityException = require('./lib/securityexception');
module.exports.Select = require('./lib/query/select');
module.exports.Serializer = require('./lib/serializer');
module.exports.Sort = require('./lib/query/sort');
module.exports.TransactionDeclaration = require('./lib/introspect/transactiondeclaration');
module.exports.TypescriptVisitor = require('./lib/codegen/fromcto/typescript/typescriptvisitor');
module.exports.Util = require('./lib/util');
module.exports.Wallet = require('./lib/wallet');
module.exports.CodeGen = require('./lib/codegen/codegen.js');
module.exports.Where = require('./lib/query/where');
module.exports.Writer = require('./lib/codegen/writer.js');
module.exports.version = require('./package.json');
70 changes: 13 additions & 57 deletions packages/composer-common/lib/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
const debug = require('debug')('ibm-concerto');
const Globalize = require('./globalize');

const ModelUtil = require('./modelutil');

const InstanceGenerator = require('./serializer/instancegenerator');
const ValueGeneratorFactory = require('./serializer/valuegenerator');
const ResourceValidator = require('./serializer/resourcevalidator');
Expand Down Expand Up @@ -86,7 +88,7 @@ class Factory {
* <dt>sample</dt><dd>return a resource instance with generated sample data.</dd>
* <dt>empty</dt><dd>return a resource instance with empty property values.</dd></dl>
* @return {Resource} the new instance
* @throws {ModelException} if the type is not registered with the ModelManager
* @throws {TypeNotFoundException} if the type is not registered with the ModelManager
*/
newResource(ns, type, id, options) {
if(!id || typeof(id) !== 'string') {
Expand All @@ -105,24 +107,9 @@ class Factory {
}));
}

let modelFile = this.modelManager.getModelFile(ns);
if(!modelFile) {
let formatter = Globalize.messageFormatter('factory-newinstance-notregisteredwithmm');
throw new Error(formatter({
namespace: ns
}));
}

if(!modelFile.isDefined(type)) {
let formatter = Globalize.messageFormatter('factory-newinstance-typenotdeclaredinns');

throw new Error(formatter({
namespace: ns,
type: type
}));
}
const qualifiedName = ModelUtil.getFullyQualifiedName(ns, type);
const classDecl = this.modelManager.getType(qualifiedName);

let classDecl = modelFile.getType(type);
if(classDecl.isAbstract()) {
let formatter = Globalize.messageFormatter('factory-newinstance-abstracttype');
throw new Error(formatter({
Expand Down Expand Up @@ -176,27 +163,11 @@ class Factory {
* <dt>sample</dt><dd>return a resource instance with generated sample data.</dd>
* <dt>empty</dt><dd>return a resource instance with empty property values.</dd></dl>
* @return {Resource} the new instance
* @throws {ModelException} if the type is not registered with the ModelManager
* @throws {TypeNotFoundException} if the type is not registered with the ModelManager
*/
newConcept(ns, type, options) {
let modelFile = this.modelManager.getModelFile(ns);
if(!modelFile) {
let formatter = Globalize.messageFormatter('factory-newinstance-notregisteredwithmm');
throw new Error(formatter({
namespace: ns
}));
}

if(!modelFile.isDefined(type)) {
let formatter = Globalize.messageFormatter('factory-newinstance-typenotdeclaredinns');

throw new Error(formatter({
namespace: ns,
type: type
}));
}

let classDecl = modelFile.getType(type);
const qualifiedName = ModelUtil.getFullyQualifiedName(ns, type);
const classDecl = this.modelManager.getType(qualifiedName);

if(classDecl.isAbstract()) {
let formatter = Globalize.messageFormatter('factory-newinstance-abstracttype');
Expand Down Expand Up @@ -247,29 +218,14 @@ class Factory {
* @param {string} type - the type of the Resource
* @param {string} id - the identifier
* @return {Relationship} - the new relationship instance
* @throws {ModelException} if the type is not registered with the ModelManager
* @throws {TypeNotFoundException} if the type is not registered with the ModelManager
*/
newRelationship(ns, type, id) {
let modelFile = this.modelManager.getModelFile(ns);
if(!modelFile) {
let formatter = Globalize.messageFormatter('factory-newrelationship-notregisteredwithmm');

throw new Error(formatter({
namespace: ns
}));
}

if(!modelFile.isDefined(type)) {
let formatter = Globalize.messageFormatter('factory-newinstance-typenotdeclaredinns');

throw new Error(formatter({
namespace: ns,
type: type
}));
}
// Load the type declaration to force an error if it doesn't exist
const fqn = ModelUtil.getFullyQualifiedName(ns, type);
this.modelManager.getType(fqn);

let relationship = new Relationship(this.modelManager,ns,type,id);
return relationship;
return new Relationship(this.modelManager, ns, type, id);
}

/**
Expand Down
10 changes: 2 additions & 8 deletions packages/composer-common/lib/globalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,8 @@ const messages = require('../messages/en.json');
function messageFormatter(message) {
return function (inserts) {
let result = messages.en[message];
if (Array.isArray(inserts)) {
for (let i = 0; i < inserts.length; i++) {
result = result.replace(new RegExp(`{${i}}`), inserts[i]);
}
} else {
for (let key in inserts) {
result = result.replace(new RegExp(`{${key}}`, 'g'), inserts[key]);
}
for (let key in inserts) {
result = result.replace(new RegExp(`\\{${key}\\}`, 'g'), inserts[key]);
}
return result;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

const TransactionDeclaration = require('./transactiondeclaration');
const IllegalModelException = require('./illegalmodelexception');
const ModelUtil = require('../modelutil');
//const Globalize = require('../globalize');

/**
Expand Down Expand Up @@ -145,9 +146,9 @@ class FunctionDeclaration {
throw new IllegalModelException('Transaction processing function ' + this.name + ' must have 1 function argument of type transaction.' );
}
const transactionClassName = this.parameterTypes[0];
const classDecl = this.modelManager.getType(transactionClassName);

if(!(classDecl instanceof TransactionDeclaration)) {
if (ModelUtil.isPrimitiveType(transactionClassName) ||
!(this.modelManager.getType(transactionClassName) instanceof TransactionDeclaration)) {
throw new IllegalModelException('Function ' + this.getName() + ' processes ' + transactionClassName + ' which is not a transaction.');
}
}
Expand Down
12 changes: 8 additions & 4 deletions packages/composer-common/lib/introspect/illegalmodelexception.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ const BaseException = require('../baseexception');
class IllegalModelException extends BaseException {

/**
* Create an IllegalModelException
* @param {string} message - the message for the exception
* @param {string} modelFile - the optional modelfile associated with the exception
* @param {string} fileLocation - the optional file location associated with the exception
* Create an IllegalModelException.
* @param {String} message - the message for the exception
* @param {ModelFile} [modelFile] - the optional modelfile associated with the exception
* @param {Object} [fileLocation] - location details of the error within the model file.
* @param {String} fileLocation.start.line - start line of the error location.
* @param {String} fileLocation.start.column - start column of the error location.
* @param {String} fileLocation.end.line - end line of the error location.
* @param {String} fileLocation.end.column - end column of the error location.
*/
constructor(message, modelFile, fileLocation) {

Expand Down
Loading