Giter VIP home page Giter VIP logo

nebula's Introduction

Build status

Nebula

Nebula is a generation tool written in java. Nebula provides simple tools for easy data generation.

The central element in Nebula is the model. The model consists on

  • Entities that describes data structure and the generation behaviours for properties.

  • Generation rules that describe how generated data will be format and write

Getting started

package com.nebula.examples.csv;

import com.nebula.core.Model;
import com.nebula.Nebula;
import com.nebula.core.Entity;
import com.nebula.core.types.NebulaTypes;
import com.nebula.core.generators.NebulaGenerators;
import com.nebula.core.formatter.NebulaFormatters;
import com.nebula.core.generationconstraint.NebulaConstraints;
import com.nebula.core.output.NebulaOutputs;
import org.joda.time.DateTime;

import static com.nebula.Nebula.*;

public class CsvUsers {

    private static DateTime MIN_BIRTH_DATE = new DateTime(1950, 1, 1, 0, 0);
    private static DateTime MAX_BIRTH_DATE = new DateTime(2000, 1, 1, 0, 0);

    public static void main(String[] args) {

        System.out.println("Generate 10 Users");

        Model model = Nebula.newModel();
        model.setSeed("a seed");
        model.setDateFormat("dd/MM/yyyy");

        Entity users = newEntity("users", Long.MAX_VALUE);
        users.addProperty("firstName", NebulaGenerators.random(), NebulaGenerationTypes.string().withPattern("[A-Z]{1}[a-z]{3,25}"));
        users.addProperty("lastName", NebulaGenerators.random(), NebulaGenerationTypes.string().withPattern("[A-Z]{1}[a-z]{3,25}"));
        users.addProperty("dayOfBirth", NebulaGenerators.random(), NebulaGenerationTypes.dateTime().range().withMin(MIN_BIRTH_DATE).withMax(MAX_BIRTH_DATE));
        model.addEntity(users);

        model.addGenerationRule(Nebula.newGenerationRule()
                .withEntity(users)
                .withFormatter(NebulaFormatters.csv().withSeparator(";").withColumns("lastName", "firstName", "dayOfBirth"))
                .addOutput(NebulaOutputs.stdout())
                .addGenerationConstraint(NebulaConstraints.amount(10)));

        model.generate();

        System.out.println("Done");
    }
}

Concept

The concept behind Nebula is data generation based on two elements :

  • a seed

  • an index

The most important thing is when an entity is declared, Nubula works like an array which all items is a generated object that match entity declaration. All object can be accessible with an index (from 0 to 9223372036854775807). All objects are generated on demand when access via index is perform.

Seed concept is very important. For a same seed nebula will generate the same dataset.

Vocabulary

  • Model : a model contains the data structure to generate (entities) and all generation behavior for data generation.

  • Entity : represent a hierarchical data structure. An entity consist on a set of properties that describe name, type and generation rule for a property.

  • Formatter : a formatter transform entities to String for outputs

  • Output : Example : file, http, stdout, jdbc, …​

Model settings

Model settings are apply on all operations that use these setting in the model.

Parameter Usage Description Default Value

seed

model.setSeed(<Long>) or model.setSeed(<String>)

Sepcify the seed to use for all random operations in the model. If you sepecify a String, the seed will be a hash value of this string.

A random Long

date format

model.setDateFormat(<String>)

Specify the date format to use for all date format operations in the model. See java formats for all possibls formats

"MM/dd/yyyy"

decimal separator

model.setNumberDecimalSeparator(<char>)

Specify the decimal separator for number format

"."

thousand separator

model.setNumberThousandSeparator(<char>)

Specify the thousand separator for number format

","

Types

Types are accessible in NebulaTypes class

Type

Description

Default behavior

amongItems()

Provide a list of items and pick one of these

bool()

Generate a boolean (true or false)

constant()

Always generate the same thing

custom()

A custom type implementation can be specify with this type

datetime()

Generate a date time according rule

entity()

Generate an another entity

list()

Generate à list

number()

Generate a number

string()

Generate a string

Generators

All generators are accessible in NebulaGenerators

Generator

Description

Default behavior

custom()

A custom implementation can be specify with this generator

random()

Generate a random type

randomUnique()

Generate a random type uniquely. After all types are generated, the generator cycle again

sequence()

Generate sequentially the type

By default, the sequence cycle if reach the maximum

Formats

Note

TODO

Output

Note

TODO

Generation rule

Note

TODO

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.