/**
 * Copyright (C) 2013 – 2015 SLUB Dresden & Avantgarde Labs GmbH (<code@dswarm.org>)
 *
 * 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.
 */
package org.dswarm.controller.eventbus;

import org.dswarm.persistence.model.resource.DataModel;

public class SchemaEvent extends DataModelEvent {

	public static enum SchemaType {
		CSV, XML, XSD;

		public static SchemaType fromString(final String type) {
			if ("schema".equals(type)) {
				return XSD;
			}
			if ("csv".equals(type)) {
				return CSV;
			}
			if ("xml".equals(type)) {
				return XSD;
			}
			if ("mabxml".equals(type)) {
				return XSD;
			}
			if ("marc21".equals(type)) {
				return XSD;
			}
			if ("pnx".equals(type)) {
				return XSD;
			}
			throw new IllegalArgumentException("No schema type for [" + type + "]");
		}
	}

	private final SchemaType	schemaType;

	public SchemaEvent(final DataModel dataModel, final SchemaType schemaType) {

		super(dataModel);

		this.schemaType = schemaType;
	}

	public SchemaType getSchemaType() {
		return schemaType;
	}
}

/**
 * Copyright (C) 2013 – 2015 SLUB Dresden & Avantgarde Labs GmbH (<code@dswarm.org>)
 *
 * 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.
 */
package org.dswarm.controller.eventbus;

import org.dswarm.persistence.model.resource.DataModel;
import org.dswarm.persistence.model.resource.utils.ConfigurationStatics;

public class SchemaEvent extends DataModelEvent {

	public static enum SchemaType {
		CSV, XML, XSD;

		public static SchemaType fromString(final String type) {

			if (type == null) {

				throw new IllegalArgumentException("couldn't determine schema type, because it is null");
			}

			switch (type) {

				case ConfigurationStatics.SCHEMA_STORAGE_TYPE:
				case ConfigurationStatics.XML_STORAGE_TYPE:
				case ConfigurationStatics.MABXML_STORAGE_TYPE:
				case ConfigurationStatics.MARCXML_STORAGE_TYPE:
				case ConfigurationStatics.PNX_STORAGE_TYPE:
				case ConfigurationStatics.OAI_PMH_DC_ELEMENTS_STORAGE_TYPE:
				case ConfigurationStatics.OAIPMH_DC_TERMS_STORAGE_TYPE:
				case ConfigurationStatics.OAIPMH_MARCXML_STORAGE_TYPE:

					return XSD;
				case ConfigurationStatics.CSV_STORAGE_TYPE:

					return CSV;
				default:

					throw new IllegalArgumentException("No schema type for [" + type + "]");
			}
		}
	}

	private final SchemaType schemaType;

	public SchemaEvent(final DataModel dataModel, final SchemaType schemaType) {

		super(dataModel);

		this.schemaType = schemaType;
	}

	public SchemaType getSchemaType() {
		return schemaType;
	}
}

fix for SchemaEvent determination