NewsCompaniesAboutContact usCreate an AccountLoginGo To
CosFakerCosFaker
Watch
0
Star
0
Category
Developer Environment
Works with
CachéEnsemble
Tags
fakedata
Author
Version
1
Last updated
2019-02-08
Repository
Download
Discuss
Details
Version history
Issues
Generate massive amounts of fake data for Intersystems Caché

cosFaker GitHub issues GitHub license

Generate massive amounts of fake data for Intersystems Caché

The language of data is according to configuration of your Caché (Now works with Pt-Br and En-Us(Default)).

Valid Types

  • Address (Street, Latitude, Longitude, City, State, Capital, Country, Street Suffix, Street Prefix, Postcode, Secondary Address)
  • App (Function name)
  • Coffee (Blend name, Variety, Notes, Origin)
  • Color (Hexadecimal, Name, RGB)
  • Commerce (Price, CNPJ, Color, Product, Product Name, Promotion Code)
  • Company (Profession, Industry)
  • Dates (Forward, Backward)
  • DragonBall (Character)
  • File (Filename, Extension, MimeType)
  • Finance (Amount, Credit Card, Bitcoin Address)
  • Game (Card, Mortal Kombat, Street Fighter)
  • Internet (Username, Email, Protocol, Domain Word, Domain Name, Avatar, Url, Slug, IPV4, IPV6,MAC Address)
  • Job (Title, Skills, Field)
  • Lorem (Words, Sentences, Paragraphs, Lines, Text, Hipster)
  • Name (First name, Last Name, Full Name, Suffix)
  • Person (CPF (Brazilian ID))
  • Phone (Area code, Phone number, Cell phone)
  • Pokemon (Pokemons)
  • StarWars (Character, Droid, Planet, Quote, Specie, Vehicle, Wookie word, Wookie Sentence)
  • UFC (Category, Fighter, Fighter by category, Nickname)

Instalation

To install cosFaker, you just need to import the package cosFaker.vX.X.X.xml file. You can go to Management Portal -> System Explorer -> Classes -> Import and select the XML file or just drag the file over Studio. Also, if you like terminal like me, execute:

Do $system.OBJ.Load("yourpath/cosFaker.vX.X.X.xml","ck")

Usage

On Populate

You can use on Populate event

Method OnPopulate() As %Status [ ServerOnly = 1 ]
{
	Set ..Login = ##class(cosFaker.Internet).UserName("John","Doe")
	Set ..Url = ##class(cosFaker.Internet).DomainWord()
}

Or on a simple Set

Set ..Name = ##class(cosFaker.Name).FullName()

SQL Class

You can generate data directly on a table

Do ##class(cosFaker.SQL).Insert("Sample_Data.Clients","City,Name,Salary","city SC,name 2,price 1000 2000 2 R$",2)
//Same as:
//INSERT INTO Sample_Data.Clients (City,Name,Salary) VALUES ('Celso Ramos','Luiggi Dias Nunes Saraiva','R$1654.30')
//INSERT INTO Sample_Data.Clients (City,Name,Salary) VALUES ('Nova Veneza','Fabiano da Costa','R$1255.13')

JSON Class

You can generate data on JSON string or in an object, only passing a JSON string as shown above.

Examples showing JSON strings populated:

Write ##class(cosFaker.JSON).GetDataJSONFromJSON("{Nome:'name 2',Cidade:'city SC',CPF:'cpf 1',Description:'slug ""person sample example"" ;'}")
// {
//    "CPF":"661.254.048-62",
//    "Cidade":"Brunópolis",
//    "Nome":"Jonathan Ribeiro Ribeiro",
//    "Description":"person;sample;example"
// }
//Suppose you want a person with name, street, phone and his 3 preferred Pokemons
Write ##class(cosFaker.JSON).GetDataJSONFromJSON("{person:['name','street','phone','3 pokemon']}")
// {"person":
//           [
//              "Yango Nogueira",
//              "Viela General Sirineu Nogueira",
//              "(44) 0968-2926",
//              ["Bayleef","Haunter","Golurk"]
//           ]
// }

And example showing Object populated:

Set person = ##class(cosFaker.JSON).GetDataOBJFromJSON("{name:'name 2',birth:'date',profession:'profession',pokemons:'3 pokemon'}",.tSC)

Write person.name
// Flávio Silveira

Set listOfPokemons = person.pokemons
Write listOfPokemons.GetAt(1)
// Diancie

Write listOfPokemons.Count()
// 3