<commit_before>/*
Copyright 2016 IBM

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.

Licensed Materials - Property of IBM
© Copyright IBM Corp. 2016
*/

/*
Viktor: Identity Management Test
*/

package main

import (
	"encoding/json"
	"errors"
	"fmt"
	"strconv"
	"time"
    "strings"

	"github.com/hyperledger/fabric/core/chaincode/shim"
)

var cpPrefix      = "cp:"
var accountPrefix = "acct:"
var accountsKey   = "accounts"
/******* ID-Man *********************/
var personPrefix  = "pers:" 
var personKeysID  = "PersKeys"
var companyPrefix  = "comp:"
var companyKeysID  = "CompKeys"
/******* ID-Man *********************/

var recentLeapYear = 2016

// SimpleChaincode example simple Chaincode implementation
type SimpleChaincode struct {
}

func generateCUSIPSuffix(issueDate string, days int) (string, error) {

	t, err := msToTime(issueDate)
	if err != nil {
		return "", err
	}

	maturityDate := t.AddDate(0, 0, days)
	month := int(maturityDate.Month())
	day := maturityDate.Day()

	suffix := seventhDigit[month] + eigthDigit[day]
	return suffix, nil

}

const (
	millisPerSecond     = int64(time.Second / time.Millisecond)
	nanosPerMillisecond = int64(time.Millisecond / time.Nanosecond)
)

func msToTime(ms string) (time.Time, error) {
	msInt, err := strconv.ParseInt(ms, 10, 64)
	if err != nil {
		return time.Time{}, err
	}

	return time.Unix(msInt/millisPerSecond,
		(msInt%millisPerSecond)*nanosPerMillisecond), nil
}

/************* ID-Man **************************/
type UrlLink struct {
    Url         string   `json:"url"`
    UrlType     string   `json:"urlType"`
}

type Person struct {
	ID				string  `json:"id"`
	FirstName		string 	`json:"firstName"`
	LastName		string 	`json:"lastName"`
	Email			string 	`json:"email"`
	BirthDate		string 	`json:"birthDate"`
	Gender			string 	`json:"gender"`
	DrivingLicence	string 	`json:"drivingLicence"`
	TFN 			string 	`json:"tfn"`
	Address   		string  `json:"address"`
	City     		string  `json:"city"`
	Postcode 		string  `json:"postcode"`
	State    		string  `json:"state"`
	UrlLinks      []UrlLink `json:"urlLinks"`
	Registrator    	string  `json:"registrator"`
	RegisterDate 	string  `json:"registerDate"`
}

type Company struct {
	ID				string  `json:"id"`
	Name			string 	`json:"name"`<commit_msg>dataPhoto attribute added to Person object<commit_after>/*
Copyright 2016 IBM

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.

Licensed Materials - Property of IBM
© Copyright IBM Corp. 2016
*/

/*
Viktor: Identity Management Test
*/

package main

import (
	"encoding/json"
	"errors"
	"fmt"
	"strconv"
	"time"
    "strings"

	"github.com/hyperledger/fabric/core/chaincode/shim"
)

var cpPrefix      = "cp:"
var accountPrefix = "acct:"
var accountsKey   = "accounts"
/******* ID-Man *********************/
var personPrefix  = "pers:" 
var personKeysID  = "PersKeys"
var companyPrefix  = "comp:"
var companyKeysID  = "CompKeys"
/******* ID-Man *********************/

var recentLeapYear = 2016

// SimpleChaincode example simple Chaincode implementation
type SimpleChaincode struct {
}

func generateCUSIPSuffix(issueDate string, days int) (string, error) {

	t, err := msToTime(issueDate)
	if err != nil {
		return "", err
	}

	maturityDate := t.AddDate(0, 0, days)
	month := int(maturityDate.Month())
	day := maturityDate.Day()

	suffix := seventhDigit[month] + eigthDigit[day]
	return suffix, nil

}

const (
	millisPerSecond     = int64(time.Second / time.Millisecond)
	nanosPerMillisecond = int64(time.Millisecond / time.Nanosecond)
)

func msToTime(ms string) (time.Time, error) {
	msInt, err := strconv.ParseInt(ms, 10, 64)
	if err != nil {
		return time.Time{}, err
	}

	return time.Unix(msInt/millisPerSecond,
		(msInt%millisPerSecond)*nanosPerMillisecond), nil
}

/************* ID-Man **************************/
type UrlLink struct {
    Url         string   `json:"url"`
    UrlType     string   `json:"urlType"`
}

type Person struct {
	ID				string  `json:"id"`
	FirstName		string 	`json:"firstName"`
	LastName		string 	`json:"lastName"`
	Email			string 	`json:"email"`
	BirthDate		string 	`json:"birthDate"`
	Gender			string 	`json:"gender"`
	DrivingLicence	string 	`json:"drivingLicence"`
	TFN 			string 	`json:"tfn"`
	Address   		string  `json:"address"`
	City     		string  `json:"city"`
	Postcode 		string  `json:"postcode"`
	State    		string  `json:"state"`
	UrlLinks      []UrlLink `json:"urlLinks"`
	DataPhoto		string  `json:"dataPhoto"`
	Registrator    	string  `json:"registrator"`
	RegisterDate 	string  `json:"registerDate"`
}

type Company struct {
	ID				string  `json:"id"`
	Name			string 	`json:"name"`
{'fraction_non_alphanumeric': 0.14216216216216215, 'fraction_numerical': 0.009369369369369369, 'mean_word_length': 4.102022058823529, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '727376', 'n_tokens_mistral': 1939, 'n_tokens_neox': 1822, 'n_words': 533}