/*-
 * ~~~~~~licensing~~~~~~
 * object-producing-management
 * ==========
 * Copyright (C) 2020 - 2025 EmDev LLC
 * ==========
 * You may not use this file except in accordance with the License Terms of the Copyright
 * Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
 * rights to the Software and any copies are the property of the Copyright Holder. Unless
 * it is explicitly allowed the Copyright Holder, the User is prohibited from using the
 * Software for commercial purposes to provide services to third parties.
 * 
 * The Copyright Holder hereby declares that the Software is provided on an "AS IS".
 * Under no circumstances does the Copyright Holder guarantee or promise that the
 * Software provided by him will be suitable or not suitable for the specific purposes
 * of the User, that the Software will meet all commercial and personal subjective
 * expectations of the User, that the Software will work properly, without technical
 * errors, quickly and uninterruptedly.
 * 
 * Under no circumstances shall the Copyright Holder or its Affiliates is not liable
 * to the User for any direct or indirect losses of the User, his expenses or actual
 * damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
 * or damage to data, property, etc.
 * ~~~~~~/licensing~~~~~~
 */
package ru.entaxy.platform.core.producer.management;

import java.util.Map;

import javax.management.openmbean.OpenDataException;
import javax.management.openmbean.TabularData;

import ru.entaxy.esb.platform.base.management.core.Qualifier;
import ru.entaxy.esb.platform.base.management.core.api.Attribute;
import ru.entaxy.esb.platform.base.management.core.api.MBeanAnnotated;
import ru.entaxy.esb.platform.base.management.core.api.MBeanExportPolicy;
import ru.entaxy.esb.platform.base.management.core.api.Operation;
import ru.entaxy.esb.platform.base.management.core.api.Parameter;
import ru.entaxy.platform.base.objects.factory.EntaxyFactoryException;

@MBeanAnnotated(policy = MBeanExportPolicy.ANNOTATED_ONLY)
public interface FactoryMBean {

	public static final String FACTORY_KEY = "factoryId";
	public static final String CATEGORY_KEY = "category";
	
	public static Qualifier getQualifier(String factoryId, String factoryType) {
		return ProducerMBean.getQualifier(factoryType).attribute(FACTORY_KEY, factoryId);
	}

	@Attribute
	boolean isAbstract();

	@Attribute
	boolean isInternal();
	@Attribute
	boolean isDeprecated();
	@Attribute
	String getId();
	@Attribute
	String getType();
	@Attribute
	String getParent();
	@Attribute
	String getShortName();
	@Attribute
	String getDisplayName();
	@Attribute
	String getDescription();
	@Attribute
	String getCategory();
	@Attribute
	String getLabel();
	
	@Attribute
	Map<String, Object> getTypeInfo();
	
	@Operation(desc = "Creates and installs a new object")
	public TabularData createObject(
		@Parameter(name = "objectId", desc = "ObjectId for new object, can be omitted in some cases")	
		String objectId,
		@Parameter(name = "scope", desc = "Scope of the new object, 'public' by default")
		String scope,
		@Parameter(name = "properties", desc = "Properties of the new object in JSON format")
		Map<String, Object> properties
			) throws EntaxyFactoryException, OpenDataException;
	
	@Operation(desc = "Creates and installs a new object")
	public TabularData createObjectByInstructions(
		@Parameter(name = "objectId", desc = "ObjectId for new object, can be omitted in some cases")	
		String objectId,
		@Parameter(name = "scope", desc = "Scope of the new object, 'public' by default")
		String scope,
		@Parameter(name = "instructions", desc = "Build instructions in JSON format, {\"install\":{}, \"store\":{}} by default")
		Map<String, Object> instructions,
		@Parameter(name = "properties", desc = "Properties of the new object in JSON format")
		Map<String, Object> properties
			) throws EntaxyFactoryException, OpenDataException;

	@Operation(desc = "Get fields for creating a new object")
	public String getFields(@Parameter(name = "outputType", desc = "Type of output") String outputType);
}
