<commit_before>/*
 * Copyright (C) 2012 <NAME>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
package fi.hoski.datastore.repository;

import com.google.appengine.api.blobstore.BlobstoreService;
import com.google.appengine.api.blobstore.BlobstoreServiceFactory;
import com.google.appengine.api.datastore.*;
import fi.hoski.datastore.DSUtils;
import fi.hoski.datastore.Events;
import fi.hoski.datastore.Races;
import fi.hoski.datastore.Repository;
import fi.hoski.util.BankingBarcode;
import fi.hoski.util.Day;
import fi.hoski.util.Time;
import fi.hoski.util.code128.CharNotInCodesetException;
import fi.hoski.util.code128.Code128;
import java.util.*;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author <NAME>
 */
public class KeyInfo
{

    public static final ResourceBundle repositoryBundle = ResourceBundle.getBundle("fi/hoski/datastore/repository/fields");
    private BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
    private DSUtils entities;
    private Events events;
    private Races races;
    private String parameters;
    private Key key;
    private boolean authenticated;
    private String label;
    private String menuLink;
    private String editLink;

    public KeyInfo(
            DSUtils entities,
            Events events,
            Races races,
            String parameters,
            Key key,
            boolean authenticated) throws EntityNotFoundException
    {
        this.entities = entities;
        this.events = events;
        this.races = races;
        this.parameters = parameters;
        this.key = key;
        this.authenticated = authenticated;
        init(key);
    }

    private void init(Key key) throws EntityNotFoundException
    {
        Key prnt = key.getParent();
        if (prnt != null)
        {
            init(prnt);
        }
        label = key.toString(); // safe values
        menuLink = label;
        editLink = label;
        if (Repository.YEAR.equals(key.getKind()))
        {
            label = repositoryBundle.getString(key.getKind()) + " " + key.getId();
        }
        if (Repository.RACESERIES.equals(key.getKind()))
        {
            Entity rsEntity = entities.get(key);
            RaceSeries raceSeries = new RaceSeries(rsEntity);
            String event = (String) raceSeries.get(RaceSeries.EVENT);<commit_msg>Added Result list<commit_after>/*
 * Copyright (C) 2012 <NAME>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
package fi.hoski.datastore.repository;

import com.google.appengine.api.blobstore.BlobstoreService;
import com.google.appengine.api.blobstore.BlobstoreServiceFactory;
import com.google.appengine.api.datastore.*;
import fi.hoski.datastore.DSUtils;
import fi.hoski.datastore.Events;
import fi.hoski.datastore.Races;
import fi.hoski.datastore.Repository;
import fi.hoski.util.BankingBarcode;
import fi.hoski.util.Day;
import fi.hoski.util.Time;
import fi.hoski.util.code128.CharNotInCodesetException;
import fi.hoski.util.code128.Code128;
import java.util.*;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author <NAME>
 */
public class KeyInfo
{

    public static final ResourceBundle repositoryBundle = ResourceBundle.getBundle("fi/hoski/datastore/repository/fields");
    private BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
    private DSUtils entities;
    private Events events;
    private Races races;
    private String parameters;
    private Key key;
    private boolean authenticated;
    private String label;
    private String menuLink;
    private String editLink;

    public KeyInfo(
            DSUtils entities,
            Events events,
            Races races,
            String parameters,
            Key key,
            boolean authenticated) throws EntityNotFoundException
    {
        this.entities = entities;
        this.events = events;
        this.races = races;
        this.parameters = parameters;
        this.key = key;
        this.authenticated = authenticated;
        init(key);
    }

    private void init(Key key) throws EntityNotFoundException
    {
        Key prnt = key.getParent();
        if (prnt != null)
        {
            init(prnt);
        }
        label = key.toString(); // safe values
        menuLink = label;
        editLink = label;
        if (Repository.YEAR.equals(key.getKind()))
        {
            label = repositoryBundle.getString(key.getKind()) + " " + key.getId();
        }
        if (Attachment.KIND.equals(key.getKind()))
        {
            Entity attachment = entities.get(key);
            label = (String) attachment.getProperty(Attachment.TITLE);
            Link link = (Link) attachment.getProperty(Attachment.URL);
            menuLink = "<a href=\""+link.getValue()+"\">"+label+"</a>";
            editLink = menuLink;
        }
        if (Repository.RACESERIES.equals(key.getKind()))
        {
            Entity rsEntity = entities.get(key);
            RaceSeries raceSeries = new RaceSeries(rsEntity);
            String event = (String) raceSeries.get(RaceSeries.EVENT);
{'fraction_non_alphanumeric': 0.09367717881000466, 'fraction_numerical': 0.0043498524157216095, 'mean_word_length': 2.85278276481149, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '4546861', 'n_tokens_mistral': 1790, 'n_tokens_neox': 1770, 'n_words': 520}