<commit_before>package de.taimos.dvalin.interconnect.demo;

/*
 * #%L
 * Dvalin interconnect demo project
 * %%
 * Copyright (C) 2016 Taimos GmbH
 * %%
 * 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.
 * #L%
 */

import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;

import de.taimos.daemon.spring.annotations.ProdComponent;
import de.taimos.dvalin.interconnect.core.spring.DaemonProxyFactory;
import de.taimos.dvalin.interconnect.demo.api.IUserService;
import de.taimos.dvalin.interconnect.demo.api.UserError;
import de.taimos.dvalin.interconnect.demo.model.UserIVO_v1;
import de.taimos.dvalin.interconnect.demo.model.requests.CreateUserIVO_v1;
import de.taimos.dvalin.interconnect.demo.model.requests.FindUserByIdIVO_v1;
import de.taimos.dvalin.interconnect.demo.model.requests.FindUserIVO_v1;
import de.taimos.dvalin.interconnect.model.service.DaemonError;

@ProdComponent
public class Client {

    @Autowired
    private DaemonProxyFactory proxy;

    @Scheduled(initialDelay = 1000, fixedRate = 60000)
    public void init() {
        IUserService svc = proxy.create(IUserService.class);

        try {
            System.out.println("Users:");
            for (UserIVO_v1 user : svc.findUsers(new FindUserIVO_v1.FindUserIVO_v1Builder().build()).getElements()) {
                System.out.println("  - " + user.getId() + " " + user.getName());
            }

            System.out.println();

            for (int i = 0; i < 5; i++) {
                String name = UUID.randomUUID().toString();
                UserIVO_v1.UserIVO_v1Builder b = new UserIVO_v1.UserIVO_v1Builder();
                b.withName(name);
                UserIVO_v1 user = b.build();
                System.out.println("Creating user: " + name);
                UserIVO_v1 cUser = svc.createUser(new CreateUserIVO_v1.CreateUserIVO_v1Builder().withValue(user).build());
                System.out.println("Created user: " + cUser.getName() + " with id " + cUser.getId());
            }

            System.out.println();

            System.out.println("Users:");
            for (UserIVO_v1 user : svc.findUsers(new FindUserIVO_v1.FindUserIVO_v1Builder().build()).getElements()) {
                System.out.println("  - " + user.getId() + " " + user.getName());
            }

            svc.findById(new FindUserByIdIVO_v1.FindUserByIdIVO_v1Builder().withId("1000").build());
        } catch (DaemonError daemonError) {
            if (daemonError.getNumber().equals(UserError.USER_NOT_FOUND)) {
                System.out.println("User does not exist");
            }

            System.out.println(daemonError.getNumber().toString());
            daemonError.printStackTrace();
        }

    }

}<commit_msg>use annotation instead of proxy factory<commit_after>package de.taimos.dvalin.interconnect.demo;

/*
 * #%L
 * Dvalin interconnect demo project
 * %%
 * Copyright (C) 2016 Taimos GmbH
 * %%
 * 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.
 * #L%
 */

import java.util.UUID;

import org.springframework.scheduling.annotation.Scheduled;

import de.taimos.daemon.spring.annotations.ProdComponent;
import de.taimos.dvalin.interconnect.core.daemon.Interconnect;
import de.taimos.dvalin.interconnect.demo.api.IUserService;
import de.taimos.dvalin.interconnect.demo.api.UserError;
import de.taimos.dvalin.interconnect.demo.model.UserIVO_v1;
import de.taimos.dvalin.interconnect.demo.model.requests.CreateUserIVO_v1;
import de.taimos.dvalin.interconnect.demo.model.requests.FindUserIVO_v1;
import de.taimos.dvalin.interconnect.model.service.DaemonError;

@ProdComponent
public class Client {

    @Interconnect
    private IUserService svc;

    @Scheduled(initialDelay = 1000, fixedRate = 60000)
    public void init() {
        try {
            System.out.println("Users:");
            for (UserIVO_v1 user : this.svc.findUsers(new FindUserIVO_v1.FindUserIVO_v1Builder().build()).getElements()) {
                System.out.println("  - " + user.getId() + " " + user.getName());
            }

            System.out.println();

            for (int i = 0; i < 5; i++) {
                String name = UUID.randomUUID().toString();
                UserIVO_v1.UserIVO_v1Builder b = new UserIVO_v1.UserIVO_v1Builder();
                b.withName(name);
                UserIVO_v1 user = b.build();
                System.out.println("Creating user: " + name);
                UserIVO_v1 cUser = this.svc.createUser(new CreateUserIVO_v1.CreateUserIVO_v1Builder().withValue(user).build());
                System.out.println("Created user: " + cUser.getName() + " with id " + cUser.getId());
            }

            System.out.println();

            System.out.println("Users:");
            for (UserIVO_v1 user : this.svc.findUsers(new FindUserIVO_v1.FindUserIVO_v1Builder().build()).getElements()) {
                System.out.println("  - " + user.getId() + " " + user.getName());
            }

//            svc.findById(new FindUserByIdIVO_v1.FindUserByIdIVO_v1Builder().withId("1000").build());
        } catch (DaemonError daemonError) {
            if (daemonError.getNumber().equals(UserError.USER_NOT_FOUND)) {
                System.out.println("User does not exist");
            }

            System.out.println(daemonError.getNumber().toString());
            daemonError.printStackTrace();
        }

    }

}
{'fraction_non_alphanumeric': 0.11897356143079316, 'fraction_numerical': 0.013219284603421462, 'mean_word_length': 2.855515587529976, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4635781', 'n_tokens_mistral': 2024, 'n_tokens_neox': 1945, 'n_words': 394}