<commit_before>/*
 * Copyright (c) 2012 Haulmont Technology Ltd. All Rights Reserved.
 * Haulmont Technology proprietary and confidential.
 * Use is subject to license terms.
 */

package com.haulmont.cuba.gui.app.core.showinfo;

import com.haulmont.chile.core.model.MetaClass;
import com.haulmont.cuba.core.entity.*;
import com.haulmont.cuba.core.global.KeyValueEntity;
import com.haulmont.cuba.core.global.MessageProvider;
import com.haulmont.cuba.gui.data.DataService;
import com.haulmont.cuba.gui.data.DsContext;
import com.haulmont.cuba.gui.data.impl.CollectionDatasourceImpl;

import java.text.SimpleDateFormat;
import java.util.Map;
import java.util.UUID;

/**
 * @author artamonov
 * @version $Id$
 */
public class EntityParamsDatasource extends CollectionDatasourceImpl<KeyValueEntity, UUID> {

    private Entity instance;
    private MetaClass instanceMetaClass;

    public EntityParamsDatasource(DsContext context, DataService dataservice, String id, MetaClass metaClass, String viewName) {
        super(context, dataservice, id, metaClass, viewName);
    }

    @Override
    protected void loadData(Map<String, Object> params) {
        if ((instance != null) && (metaClass != null)) {
            compileInfo();
        }
    }

    private void compileInfo() {
        Class<?> javaClass = metaClass.getJavaClass();
        includeParam("table.showInfoAction.entityName", metaClass.getName());
        includeParam("table.showInfoAction.entityClass", javaClass.getName());

        javax.persistence.Table annotation = javaClass.getAnnotation(javax.persistence.Table.class);
        if (annotation != null)
            includeParam("table.showInfoAction.entityTable", annotation.name());

        if (instance != null) {
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            includeParam("table.showInfoAction.id", instance.getId().toString());
            if (instance instanceof Versioned && ((Versioned) instance).getVersion() != null) {
                Integer version = ((Versioned) instance).getVersion();
                includeParam("table.showInfoAction.version", version.toString());<commit_msg>Fix SystemInfoWindow ugly table margin in columns<commit_after>/*
 * Copyright (c) 2012 Haulmont Technology Ltd. All Rights Reserved.
 * Haulmont Technology proprietary and confidential.
 * Use is subject to license terms.
 */

package com.haulmont.cuba.gui.app.core.showinfo;

import com.haulmont.chile.core.model.MetaClass;
import com.haulmont.cuba.core.entity.*;
import com.haulmont.cuba.core.global.KeyValueEntity;
import com.haulmont.cuba.core.global.MessageProvider;
import com.haulmont.cuba.gui.data.DataService;
import com.haulmont.cuba.gui.data.DsContext;
import com.haulmont.cuba.gui.data.impl.CollectionDatasourceImpl;

import java.text.SimpleDateFormat;
import java.util.Map;
import java.util.UUID;

/**
 * @author artamonov
 * @version $Id$
 */
public class EntityParamsDatasource extends CollectionDatasourceImpl<KeyValueEntity, UUID> {

    private Entity instance;
    private MetaClass instanceMetaClass;

    public EntityParamsDatasource(DsContext context, DataService dataservice, String id, MetaClass metaClass, String viewName) {
        super(context, dataservice, id, metaClass, viewName);
    }

    @Override
    protected void loadData(Map<String, Object> params) {
        if ((instance != null) && (instanceMetaClass != null)) {
            compileInfo();
        }
    }

    private void compileInfo() {
        Class<?> javaClass = instanceMetaClass.getJavaClass();
        includeParam("table.showInfoAction.entityName", instanceMetaClass.getName());
        includeParam("table.showInfoAction.entityClass", javaClass.getName());

        javax.persistence.Table annotation = javaClass.getAnnotation(javax.persistence.Table.class);
        if (annotation != null)
            includeParam("table.showInfoAction.entityTable", annotation.name());

        if (instance != null) {
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            includeParam("table.showInfoAction.id", instance.getId().toString());
            if (instance instanceof Versioned && ((Versioned) instance).getVersion() != null) {
                Integer version = ((Versioned) instance).getVersion();
                includeParam("table.showInfoAction.version", version.toString());
{'fraction_non_alphanumeric': 0.11592879963486992, 'fraction_numerical': 0.0018256503879507074, 'mean_word_length': 3.80065717415115, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4631013', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1195, 'n_words': 261}