<commit_before>/*
 * Copyright 2003 - 2011 The eFaps Team
 *
 * 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.
 *
 * Revision:        $Rev$
 * Last Changed:    $Date$
 * Last Changed By: $Author$
 */

package org.efaps.importer;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import org.efaps.db.Insert;
import org.efaps.util.EFapsException;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * This Class represents a simplified an specialized version of an InsertObject.
 * In this case the Object represents the Root and therefore can't be a child.
 * The Root means in this case the &lt;import&gt;&lt;/import&gt; of the
 * XML-File.
 *
 * @author The eFaps Team
 * @version $Id$
 */
public class RootObject
    extends AbstractObject
{
    /**
     * Logger for this class.
     */
    private static final Logger LOG = LoggerFactory.getLogger(RootObject.class);

    /**
     * Mapping for odered objects.
     */
    private static final Map<String, OrderObject> ORDER = new HashMap<String, OrderObject>();

    /**
     * Format for Date values.
     * default is yyyy-MM-dd'T'HH:mm:ss.SSSZZ
     */
    private static String DATEFORMAT;

    /**
     * Children for this rootobject.
     */
    private final List<AbstractObject> childs = new ArrayList<AbstractObject>();


    /**
     * Setter method for the variable {@link #${RootObject.DATEFORMAT}}.
     *
     * @param  _dateFormat value for variable {@link #${RootObject.DATEFORMAT}}
     */
    protected static void setDateFormat(final String _dateFormat)
    {
        RootObject.DATEFORMAT = _dateFormat;
    }

    /**
     * Getter method for the variable {@link #${RootObject.DATEFORMAT}}.
     *
     * @return value of variable {@link #${RootObject.DATEFORMAT}}
     */
    protected static String getDateFormat()
    {
        return RootObject.DATEFORMAT;
    }

    /**
     * @param _order add to the order
     */
    protected static void addOrder(final OrderObject _order)
    {
        RootObject.ORDER.put(_order.getType(), _order);
    }

    /**
     * @param _type tyep the order is wanted for
     * @return order
     */
    protected static OrderObject getOrder(final String _type)
    {
        return RootObject.ORDER.get(_type);
    }

    /**
     * @param _object add a child
     */
    protected void addChild(final AbstractObject _object)
    {
        this.childs.add(_object);
    }

    @Override
    public void dbAddChilds()
    {
        for (final AbstractObject object : this.childs) {
            try {
                if (RootObject.LOG.isInfoEnabled()) {
                    RootObject.LOG.info("Inserting the Base-Objects '"
                            + object.getType() + "' to the Database");<commit_msg>- bugFix: method must be public to be used by digester<commit_after>/*
 * Copyright 2003 - 2011 The eFaps Team
 *
 * 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.
 *
 * Revision:        $Rev$
 * Last Changed:    $Date$
 * Last Changed By: $Author$
 */

package org.efaps.importer;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import org.efaps.db.Insert;
import org.efaps.util.EFapsException;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * This Class represents a simplified an specialized version of an InsertObject.
 * In this case the Object represents the Root and therefore can't be a child.
 * The Root means in this case the &lt;import&gt;&lt;/import&gt; of the
 * XML-File.
 *
 * @author The eFaps Team
 * @version $Id$
 */
public class RootObject
    extends AbstractObject
{
    /**
     * Logger for this class.
     */
    private static final Logger LOG = LoggerFactory.getLogger(RootObject.class);

    /**
     * Mapping for odered objects.
     */
    private static final Map<String, OrderObject> ORDER = new HashMap<String, OrderObject>();

    /**
     * Format for Date values.
     * default is yyyy-MM-dd'T'HH:mm:ss.SSSZZ
     */
    private static String DATEFORMAT;

    /**
     * Children for this rootobject.
     */
    private final List<AbstractObject> childs = new ArrayList<AbstractObject>();


    /**
     * Setter method for the variable {@link #${RootObject.DATEFORMAT}}.
     *
     * @param  _dateFormat value for variable {@link #${RootObject.DATEFORMAT}}
     */
    protected static void setDateFormat(final String _dateFormat)
    {
        RootObject.DATEFORMAT = _dateFormat;
    }

    /**
     * Getter method for the variable {@link #${RootObject.DATEFORMAT}}.
     *
     * @return value of variable {@link #${RootObject.DATEFORMAT}}
     */
    protected static String getDateFormat()
    {
        return RootObject.DATEFORMAT;
    }

    /**
     * @param _order add to the order
     */
    protected static void addOrder(final OrderObject _order)
    {
        RootObject.ORDER.put(_order.getType(), _order);
    }

    /**
     * @param _type tyep the order is wanted for
     * @return order
     */
    protected static OrderObject getOrder(final String _type)
    {
        return RootObject.ORDER.get(_type);
    }

    /**
     * @param _object add a child
     */
    public void addChild(final AbstractObject _object)
    {
        this.childs.add(_object);
    }

    @Override
    public void dbAddChilds()
    {
        for (final AbstractObject object : this.childs) {
            try {
                if (RootObject.LOG.isInfoEnabled()) {
                    RootObject.LOG.info("Inserting the Base-Objects '"
                            + object.getType() + "' to the Database");
{'fraction_non_alphanumeric': 0.10153482880755609, 'fraction_numerical': 0.004132231404958678, 'mean_word_length': 2.6514008620689653, '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': '4146124', 'n_tokens_mistral': 1952, 'n_tokens_neox': 1904, 'n_words': 633}