<commit_before>/*
// $Id$
// Farrago is an extensible data management system.
// Copyright (C) 2005-2005 The Eigenbase Project
// Copyright (C) 2003-2005 Disruptive Tech
// Copyright (C) 2005-2005 LucidEra, Inc.
// Portions Copyright (C) 2003-2005 <NAME>
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 of the License, or (at your option)
// any later version approved by The Eigenbase Project.
//
// 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
package net.sf.farrago.catalog;

import java.util.*;
import java.util.logging.*;

import javax.jmi.reflect.*;

import net.sf.farrago.*;
import net.sf.farrago.cwm.core.*;
import net.sf.farrago.cwm.relational.*;
import net.sf.farrago.fem.config.*;
import net.sf.farrago.trace.*;
import net.sf.farrago.util.*;

import org.eigenbase.util.SaffronProperties;
import org.eigenbase.util.Util;
import org.eigenbase.jmi.*;

import java.util.logging.Logger;

/**
 * Implementation of {@link FarragoRepos} using a MDR repository.
 *
 * @author <NAME>
 * @version $Id$
 */
public abstract class FarragoReposImpl extends FarragoMetadataFactoryImpl
    implements FarragoRepos
{
    //~ Static fields/initializers --------------------------------------------
    private static final Logger tracer = FarragoTrace.getReposTracer();

    /** TODO:  look this up from repository */
    private static final int maxNameLength = 128;

    //~ Instance fields -------------------------------------------------------

    private boolean isFennelEnabled;

    protected final FarragoCompoundAllocation allocations =
        new FarragoCompoundAllocation();

    private final Map localizedClassNames = new HashMap();

    private final List resourceBundles = new ArrayList();

    private JmiModelGraph modelGraph;

    private JmiModelView modelView;

    //~ Constructors ----------------------------------------------------------

    /**
     * Opens a Farrago repository.
     */
    public FarragoReposImpl(
        FarragoAllocationOwner owner)
    {
        owner.addAllocation(this);
    }

    /**
     * Initializes the model graph. The constructor of a concrete subclass must
     * call this after the repository has been initialized, and
     * {@link #getRootPackage()} is available.
     */
    protected void initGraph()
    {
        isFennelEnabled = !getDefaultConfig().isFennelDisabled();
        modelGraph = new JmiModelGraph(getRootPackage());
        modelView = new JmiModelView(modelGraph);
    }

    //~ Methods ---------------------------------------------------------------

    protected FemFarragoConfig getDefaultConfig()
    {
        // TODO: multiple named configurations.  For now, build should have
        // imported exactly one configuration named Current.
        Collection configs =
            getConfigPackage().getFemFarragoConfig().refAllOfClass();

        assert (configs.size() == 1);
        FemFarragoConfig defaultConfig =
            (FemFarragoConfig) configs.iterator().next();
        assert (defaultConfig.getName().equals("Current"));
        return defaultConfig;
    }

    protected static String getLocalizedClassKey(RefClass refClass)<commit_msg>FARRAGO:  split up repos init even further<commit_after>/*
// $Id$
// Farrago is an extensible data management system.
// Copyright (C) 2005-2005 The Eigenbase Project
// Copyright (C) 2003-2005 Disruptive Tech
// Copyright (C) 2005-2005 LucidEra, Inc.
// Portions Copyright (C) 2003-2005 <NAME>
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 of the License, or (at your option)
// any later version approved by The Eigenbase Project.
//
// 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
package net.sf.farrago.catalog;

import java.util.*;
import java.util.logging.*;

import javax.jmi.reflect.*;

import net.sf.farrago.*;
import net.sf.farrago.cwm.core.*;
import net.sf.farrago.cwm.relational.*;
import net.sf.farrago.fem.config.*;
import net.sf.farrago.trace.*;
import net.sf.farrago.util.*;

import org.eigenbase.util.SaffronProperties;
import org.eigenbase.util.Util;
import org.eigenbase.jmi.*;

import java.util.logging.Logger;

/**
 * Implementation of {@link FarragoRepos} using a MDR repository.
 *
 * @author <NAME>
 * @version $Id$
 */
public abstract class FarragoReposImpl extends FarragoMetadataFactoryImpl
    implements FarragoRepos
{
    //~ Static fields/initializers --------------------------------------------
    private static final Logger tracer = FarragoTrace.getReposTracer();

    /** TODO:  look this up from repository */
    private static final int maxNameLength = 128;

    //~ Instance fields -------------------------------------------------------

    private boolean isFennelEnabled;

    protected final FarragoCompoundAllocation allocations =
        new FarragoCompoundAllocation();

    private final Map localizedClassNames = new HashMap();

    private final List resourceBundles = new ArrayList();

    private JmiModelGraph modelGraph;

    private JmiModelView modelView;

    //~ Constructors ----------------------------------------------------------

    /**
     * Opens a Farrago repository.
     */
    public FarragoReposImpl(
        FarragoAllocationOwner owner)
    {
        owner.addAllocation(this);
    }

    // TODO jvs 30-Nov-2005:  rename these methods; initGraph initializes
    // other stuff besides the model graph

    /**
     * Initializes the model graph. The constructor of a concrete subclass must
     * call this after the repository has been initialized, and
     * {@link #getRootPackage()} is available.
     */
    protected void initGraph()
    {
        isFennelEnabled = !getDefaultConfig().isFennelDisabled();
        initGraphOnly();
    }

    protected void initGraphOnly()
    {
        modelGraph = new JmiModelGraph(getRootPackage());
        modelView = new JmiModelView(modelGraph);
    }

    //~ Methods ---------------------------------------------------------------

    protected FemFarragoConfig getDefaultConfig()
    {
        // TODO: multiple named configurations.  For now, build should have
        // imported exactly one configuration named Current.
        Collection configs =
            getConfigPackage().getFemFarragoConfig().refAllOfClass();

        assert (configs.size() == 1);
        FemFarragoConfig defaultConfig =
            (FemFarragoConfig) configs.iterator().next();
        assert (defaultConfig.getName().equals("Current"));
        return defaultConfig;
    }

    protected static String getLocalizedClassKey(RefClass refClass)
{'fraction_non_alphanumeric': 0.14600840336134455, 'fraction_numerical': 0.014180672268907563, 'mean_word_length': 2.5312934631432547, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4040383', 'n_tokens_mistral': 2101, 'n_tokens_neox': 1961, 'n_words': 679}