Code Monkey home page Code Monkey logo

example-data's Introduction

An example data generator for Java and TypeScript

To build the package, run

npm install
node createFrontend.js
rm src/main/resources/META-INF/frontend/example-data-bundle.*
cat src/main/resources/META-INF/resources/frontend/data-generator.ts|sed "s/example-data-bundle/example-data-bundle.esm/" > src/main/resources/META-INF/resources/frontend/data-generator.esm.ts
rollup -c rollup.config.cjs.js
rollup -c rollup.config.esm.js
mvn clean install

example-data's People

Contributors

anssit avatar artur- avatar dependabot[bot] avatar mstahv avatar tarekoraby avatar zhesun88 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

example-data's Issues

Un-deprecate constructor

Consider un-deprecating the constructor public ExampleDataGenerator(Class<T> type).

This is deprecated in favor of public ExampleDataGenerator(Class<T> type, LocalDateTime referenceTime). However, the former is simpler to use if one doesn't want to generate date-time data, or if one doesn't care about the reference time used.

NodeScriptInterface eats up disk space

The initialization logic in NodeScriptInterface class leads to the creation of multiple replicas of a temporary file. These replicas are only deleted on JVM termination. Generating a few thousand sample objects eats up gigabytes of disk space.

Add Java docs

The project is completely missing Java code documentation. It would be nice to add those, especially for the ExampleDataGenerator class.

javadoc and documentation missing

the project looks great and there is a dzone article covering the basics. but its a pity there is no javadoc or documentation.
if you want to know of all features or want to write your own generator there is no help unfortunately :(

and theres nowhere to find, you need to have node installed on the system where you want to use it with the java-lib :D

ExampleDataGenerator random provider doesn't use seed

Hello,
I was browsing through the code after creating a custom data type for my project and I noticed that the assignValue method in ExampleDataGenerator uses the attribute private Random random = new Random(); to provide randomness instead of a new Random(seed).
Is that a deliberate choice ?

Generator fails silently

OS: Windows 10 Pro
JDK 11.0.5

        <dependency>
            <groupId>org.vaadin.artur.exampledata</groupId>
            <artifactId>exampledata</artifactId>
            <version>3.2.0</version>
        </dependency>

Running a project downloaded from https://start.stg.vaadin.com/?preset=fusion-crm-tutorial&dl

The project contains the following class:

@SpringComponent
public class DataGenerator {

    @Bean
    public CommandLineRunner loadData(ContactRepository contactRepository, CompanyRepository companyRepository,
            StatusRepository statusRepository) {

        return args -> {
            Logger logger = LoggerFactory.getLogger(getClass());
            if (contactRepository.count() != 0L) {
                logger.info("Using existing database");
                return;
            }
            int seed = 123;

            logger.info("Generating demo data");
            var companyGenerator = new ExampleDataGenerator<>(Company.class, LocalDateTime.now());
            companyGenerator.setData(Company::setName, DataType.COMPANY_NAME);
            var companies = companyRepository.saveAll(companyGenerator.create(5, seed));

            var statuses = statusRepository
                    .saveAll(Stream.of("Imported lead", "Not contacted", "Contacted", "Customer", "Closed (lost)")
                            .map(Status::new).collect(Collectors.toList()));

            logger.info("... generating 50 Contact entities...");
            var contactGenerator = new ExampleDataGenerator<>(Contact.class, LocalDateTime.now());
            contactGenerator.setData(Contact::setFirstName, DataType.FIRST_NAME);
            contactGenerator.setData(Contact::setLastName, DataType.LAST_NAME);
            contactGenerator.setData(Contact::setEmail, DataType.EMAIL);

            Random r = new Random(seed);
            var contacts = contactGenerator.create(50, seed).stream().map(contact -> {
                contact.setCompany(companies.get(r.nextInt(companies.size())));
                contact.setStatus(statuses.get(r.nextInt(statuses.size())));
                return contact;
            }).collect(Collectors.toList());

            contactRepository.saveAll(contacts);
            
            logger.info("Generated demo data");
        };
    }

When running the project from the VScode's built-in Terminal with Powershell using mvn, the first "Generating demo data" line is logged, but none of the following log lines appear. The contactRepository.saveAll method is never called, so the repository remains empty.

PiT 24.0: the library is calling a method from flow that does not exist

Description

When migrating an app generated time ago in start.vaadin.com that included exampledata dependency to v24, it fails with the error:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    com.vaadin.exampledata.NodeUtil.runScript(NodeUtil.java:32)

The following method did not exist:

    'void com.vaadin.flow.server.frontend.FrontendTools.<init>(java.lang.String, java.util.function.Supplier)'

The calling method's class, com.vaadin.exampledata.NodeUtil, was loaded from the following location:

    jar:file:/Users/manolo/.m2/repository/com/vaadin/exampledata/6.1.0/exampledata-6.1.0.jar!/com/vaadin/exampledata/NodeUtil.class

How to reproduce

For instance by checking out the k8s-demo-app that was generated some time ago

# clone the project
git clone https://github.com/vaadin/k8s-demo-app.git
cd k8s-demo-app
# update dependencies to latest
mvn -B -q versions:set-property -Dproperty=vaadin.version -DnewVersion=24.0-SNAPSHOT
mvn -q versions:update-parent -DparentVersion=3.0.2
mvn -B -q versions:set-property -Dproperty=java.version -DnewVersion=17
mvn -q versions:use-dep-version -Dincludes=com.vaadin.k8s:vaadin-cluster-support -DdepVersion=2.0-SNAPSHOT -DforceVersion=true
mvn -q versions:use-dep-version -Dincludes=com.vaadin:exampledata -DdepVersion=6.1.0 -DforceVersion=true
# replace javax with jakarta
find src/main/java -name "*.java" | xargs perl -pi -e 's/javax\.(persistence|validation|annotation|transaction|inject|servlet)/jakarta.$1/g'
# deprecated method
find src/main/java -name "*.java" | xargs perl -pi -e 's/\.antMatchers\(/.requestMatchers(/g'
mvn 

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.