/*******************************************************************************
 * Mission Control Technologies, Copyright (c) 2009-2012, United States Government
 * as represented by the Administrator of the National Aeronautics and Space 
 * Administration. All rights reserved.
 *
 * The MCT platform is 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.
 *
 * MCT includes source code licensed under additional open source licenses. See 
 * the MCT Open Source Licenses file included with this distribution or the About 
 * MCT Licenses dialog available at runtime from the MCT Help menu for additional 
 * information. 
 *******************************************************************************/
package gov.nasa.arc.mct.scenario.component;

import gov.nasa.arc.mct.components.AbstractComponent;
import gov.nasa.arc.mct.components.Bootstrap;

import java.util.Collection;

/**
 * Abstract superclass for components which serve as canonical 
 * repositories for objects of other types. (e.g. User Tags, 
 * Mission Activity Types, et cetera...)
 */
public abstract class RepositoryComponent extends AbstractComponent implements RepositoryCapability, Bootstrap {

	@Override
	protected void addDelegateComponentsCallback(
			Collection<AbstractComponent> childComponents) {
		super.addDelegateComponentsCallback(childComponents);
		
		new RepositoryMoveHandler(this, childComponents).handle();
	}

	@Override
	public <T> T handleGetCapability(Class<T> capabilityClass) {	
		return
			capabilityClass.isAssignableFrom(getClass()) ? 
					capabilityClass.cast(this) :
			super.handleGetCapability(capabilityClass);
	}

	// TODO: Use this to support the Group capability
	@Override
	public String getUserScope() {
		return getCreator(); //model.get().scope;
	}
	
	@Override
	public boolean isGlobal() {
		return getCreator().equals("*");
	}

	@Override
	public boolean isSandbox() {
		return false;
	}

	@Override
	public int categoryIndex() {
		// Categorize by package - "somewhere in the middle",
		// but grouped with other components from the same package.
		return getClass().getPackage().getName().hashCode() & 0xFFFF;
	}

	@Override
	public int componentIndex() {
		return (getClass().getName().hashCode() << 1) + (isGlobal() ? 0 : 1);
	}
}

@@ -1306,54 +1306,8 @@
 ent;
-%0Aimport gov.nasa.arc.mct.components.Bootstrap;
 %0A%0Aim
@@ -1612,20 +1612,8 @@
 lity
-, Bootstrap 
 %7B%0A%0A%09
@@ -2154,24 +2154,24 @@
 erScope() %7B%0A
+
 %09%09return get
@@ -2209,492 +2209,6 @@
 %0A%09%7D%0A
-%09%0A%09@Override%0A%09public boolean isGlobal() %7B%0A%09%09return getCreator().equals(%22*%22);%0A%09%7D%0A%0A%09@Override%0A%09public boolean isSandbox() %7B%0A%09%09return false;%0A%09%7D%0A%0A%09@Override%0A%09public int categoryIndex() %7B%0A%09%09// Categorize by package - %22somewhere in the middle%22,%0A%09%09// but grouped with other components from the same package.%0A%09%09return getClass().getPackage().getName().hashCode() & 0xFFFF;%0A%09%7D%0A%0A%09@Override%0A%09public int componentIndex() %7B%0A%09%09return (getClass().getName().hashCode() %3C%3C 1) + (isGlobal() ? 0 : 1);%0A%09%7D%0A
 %7D%0A

Remove bootstrap capability from Repository