view src/main/java/org/mpi/openmind/repository/services/utils/EditIntent.java @ 114:70a02006675c

New clean actions to delete lost floruit_dates and empty references.
author Robert Casties <casties@mpiwg-berlin.mpg.de>
date Mon, 26 Aug 2019 16:10:14 +0200
parents 3e4b05a6cb47
children
line wrap: on
line source

package org.mpi.openmind.repository.services.utils;

import java.util.HashSet;
import java.util.Set;

/**
 * Class documenting the parts (attributes, relations) if an Entity that may be
 * edited.
 * 
 * @author casties
 *
 */
public class EditIntent {
	String modifiedEntity;
	Set<String> modifiedAttributes;
	Set<String> modifiedSourceRelations;
	Set<String> modifiedTargetRelations;

	/**
	 * Creates an EditIntent with the given attribute and relation names.
	 * 
	 * @param modifiedEntity
	 * @param modifiedAttributes
	 * @param modifiedSourceRelations
	 * @param modifiedTargetRelations
	 */
	public EditIntent(String modifiedEntity, Set<String> modifiedAttributes, Set<String> modifiedSourceRelations,
			Set<String> modifiedTargetRelations) {
		super();
		this.modifiedEntity = modifiedEntity;
		this.modifiedAttributes = modifiedAttributes;
		this.modifiedSourceRelations = modifiedSourceRelations;
		this.modifiedTargetRelations = modifiedTargetRelations;
	}

	/**
	 * Creates an EditIntent with the given attribute and relation names.
	 * 
	 * @param modifiedEntity
	 * @param modifiedAttributes
	 * @param modifiedSourceRelations
	 * @param modifiedTargetRelations
	 */
	public EditIntent(String modifiedEntity, String[] modifiedAttributes, String[] modifiedSourceRelations, String[] modifiedTargetRelations) {
		super();
		this.modifiedEntity = modifiedEntity;
		this.modifiedAttributes = new HashSet<String>();
		for (String s : modifiedAttributes) {
			this.modifiedAttributes.add(s);
		}
		
		this.modifiedSourceRelations = new HashSet<String>();
		for (String s : modifiedSourceRelations) {
			this.modifiedSourceRelations.add(s);
		}

		this.modifiedTargetRelations = new HashSet<String>();
		for (String s : modifiedTargetRelations) {
			this.modifiedTargetRelations.add(s);
		}
	}
	
	/**
	 * Returns if the modification of the Entity with the given name is intended.
	 * 
	 * @param name
	 * @return
	 */
	public boolean isEntModificationIntended(String name) {
		return modifiedEntity.equals(name);
	}
	
	/**
	 * Returns if the modification of the Attribute with the given name is intended.
	 * 
	 * @param name
	 * @return
	 */
	public boolean isAttModificationIntended(String name) {
		return modifiedAttributes.contains(name);
	}

	/**
	 * Returns if the modification of the Relation with the given name is intended.
	 * 
	 * @param name
	 * @return
	 */
	public boolean isSrcRelModificationIntended(String name) {
		return modifiedSourceRelations.contains(name);
	}

	/**
	 * Returns if the modification of the Relation with the given name is intended.
	 * 
	 * @param name
	 * @return
	 */
	public boolean isTarRelModificationIntended(String name) {
		return modifiedTargetRelations.contains(name);
	}
}