Commit a69f5afd authored by Noel Alonso's avatar Noel Alonso
Browse files

Merge branch 'release-0.11.0' into 'master'

Release 0.11.0

See merge request redmic-project/server/library/broker-lib!10
parents e263ef80 3eacec86
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -13,14 +13,14 @@
	<groupId>es.redmic.lib</groupId>
	<artifactId>broker-lib</artifactId>
	<packaging>jar</packaging>
	<version>0.10.0</version>
	<version>0.10.0-feature-atlasMicroservice</version>
	<name>broker-lib</name>

	<properties>
		<!-- REDMIC -->
		<redmic.exceptions.version>0.7.0</redmic.exceptions.version>
		<redmic.jackson-jsonschema.version>0.7.0</redmic.jackson-jsonschema.version>
		<redmic.jts4jackson.version>0.0.1</redmic.jts4jackson.version>
		<redmic.exceptions.version>0.10.0</redmic.exceptions.version>
		<redmic.jackson-jsonschema.version>0.8.0-feature-changeUrlType</redmic.jackson-jsonschema.version>
		<redmic.jts4jackson.version>0.2.0</redmic.jts4jackson.version>
		<!-- OTHERS -->
		<avro.version>1.8.2</avro.version>
		<confluent.version>5.0.1</confluent.version>
+24 −1
Original line number Diff line number Diff line
package es.redmic.brokerlib.avro.common;

import java.util.Arrays;

/*-
 * #%L
 * broker-lib
@@ -50,7 +52,11 @@ public abstract class EventTypes {
		DELETE_CONFIRMED = "DELETE_CONFIRMED",
		DELETED = "DELETED",
		DELETE_FAILED = "DELETE_FAILED",
		DELETE_CANCELLED = "DELETE_CANCELLED";
		DELETE_CANCELLED = "DELETE_CANCELLED",
		//FAIL
		PREPARE_ROLLBACK = "PREPARE_ROLLBACK",
		ROLLBACK = "ROLLBACK",
		ROLLBACK_FAILED = "ROLLBACK_FAILED";
		//@formatter:on

	/**
@@ -94,4 +100,21 @@ public abstract class EventTypes {

		return (isSnapshot(eventType) && !eventType.equals(EventTypes.DELETED.toString()));
	}

	public static String getEventFailedTypeByActionType(String actionType) {

		if (Arrays.asList(CREATE, ENRICH_CREATE, CREATE_ENRICHED, CREATE_ENRICH_FAILED, CREATE_CONFIRMED, CREATE_FAILED)
				.contains(actionType)) {
			return CREATE_FAILED;
		}
		if (Arrays.asList(UPDATE, ENRICH_UPDATE, UPDATE_ENRICHED, UPDATE_ENRICH_FAILED, UPDATE_CONFIRMED, UPDATE_FAILED)
				.contains(actionType)) {
			return UPDATE_FAILED;
		}
		if (Arrays.asList(DELETE, CHECK_DELETE, DELETE_CHECKED, DELETE_CHECK_FAILED, DELETE_CONFIRMED, DELETE_FAILED)
				.contains(actionType)) {
			return DELETE_FAILED;
		}
		return null;
	}
}
+88 −0
Original line number Diff line number Diff line
package es.redmic.brokerlib.avro.data.common;

/*-
 * #%L
 * broker-lib
 * %%
 * Copyright (C) 2019 REDMIC Project / Server
 * %%
 * 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.
 * #L%
 */

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import es.redmic.brokerlib.avro.common.CommonDTO;

public abstract class DomainDTO extends CommonDTO {

	public DomainDTO() {
		super();
	}

	@NotNull
	@Size(min = 1, max = 150)
	protected String name;

	@NotNull
	@Size(min = 1, max = 150)
	private String name_en;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName_en() {
		return this.name_en;
	}

	public void setName_en(String name_en) {
		this.name_en = name_en;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((name_en == null) ? 0 : name_en.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		DomainDTO other = (DomainDTO) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (name_en == null) {
			if (other.name_en != null)
				return false;
		} else if (!name_en.equals(other.name_en))
			return false;
		return true;
	}
}
+40 −0
Original line number Diff line number Diff line
package es.redmic.brokerlib.avro.fail;

/*-
 * #%L
 * broker-lib
 * %%
 * Copyright (C) 2019 REDMIC Project / Server
 * %%
 * 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.
 * #L%
 */

import es.redmic.brokerlib.avro.common.SimpleEvent;

public abstract class BaseRollbackEvent extends SimpleEvent {

	private String failEventType;

	public BaseRollbackEvent(String type) {
		super(type);
	}

	public String getFailEventType() {
		return failEventType;
	}

	public void setFailEventType(String failEventType) {
		this.failEventType = failEventType;
	}
}
+107 −0
Original line number Diff line number Diff line
package es.redmic.brokerlib.avro.fail;

/*-
 * #%L
 * broker-lib
 * %%
 * Copyright (C) 2019 REDMIC Project / Server
 * %%
 * 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.
 * #L%
 */

import org.apache.avro.Schema;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;

import es.redmic.brokerlib.avro.common.EventTypes;

public class PrepareRollbackEvent extends BaseRollbackEvent {

	// @formatter:off

	public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{"
		+ "\"type\":\"record\",\"name\":\"PrepareRollbackEvent\","
				+ "\"namespace\":\"es.redmic.brokerlib.avro.fail\",\"fields\":["
				+ "{\"name\":\"failEventType\",\"type\": \"string\"},"
			+ getEventBaseSchema() + "]}");
	
	// @formatter:on

	static String type = EventTypes.PREPARE_ROLLBACK;

	public PrepareRollbackEvent() {
		super(type);
	}

	@Override
	public Object get(int field$) {
		switch (field$) {
		case 0:
			return getFailEventType();
		case 1:
			return getAggregateId();
		case 2:
			return getVersion();
		case 3:
			return getType();
		case 4:
			return getDate().getMillis();
		case 5:
			return getSessionId();
		case 6:
			return getUserId();
		case 7:
			return getId();
		default:
			throw new org.apache.avro.AvroRuntimeException("Bad index");
		}
	}

	@Override
	public void put(int field$, Object value$) {
		switch (field$) {
		case 0:
			setFailEventType(value$.toString());
			break;
		case 1:
			setAggregateId(value$.toString());
			break;
		case 2:
			setVersion((java.lang.Integer) value$);
			break;
		case 3:
			setType(value$.toString());
			break;
		case 4:
			setDate(new DateTime(value$, DateTimeZone.UTC));
			break;
		case 5:
			setSessionId(value$.toString());
			break;
		case 6:
			setUserId(value$.toString());
			break;
		case 7:
			setId(value$.toString());
			break;
		default:
			throw new org.apache.avro.AvroRuntimeException("Bad index");
		}
	}

	@Override
	public Schema getSchema() {
		return SCHEMA$;
	}
}
Loading