<commit_before>/*******************************************************************************
 * Copyright (C) 2013 The University of Manchester
 *
 *  Modifications to the initial code base are copyright of their
 *  respective authors, or their employers as appropriate.
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public License
 *  as published by the Free Software Foundation; either version 2.1 of
 *  the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 ******************************************************************************/
package uk.org.taverna.platform.report;

import java.nio.file.Path;
import java.util.Map;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;

import uk.org.taverna.scufl2.api.port.Port;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * A single invocation of a workflow, processor or activity.
 *
 * @author <NAME>
 */
public class Invocation implements Comparable<Invocation> {

	private final String name;

	private final int[] index;

	private final Invocation parent;

	private final SortedSet<Invocation> invocations;

	private final StatusReport<?, ?> report;

	private SortedMap<String, Path> inputs, outputs;

	public Invocation(String name, Invocation parent, StatusReport<?, ?> report) {
		this(name, new int[0], parent, report);
	}

	public Invocation(String name, int[] index, Invocation parent, StatusReport<?, ?> report) {
		this.name = name;
		this.index = index;
		this.parent = parent;
		if (parent != null) {
			parent.getInvocations().add(this);
		}
		this.report = report;
		report.addInvocation(this);

		invocations = new TreeSet<>();

		inputs = new TreeMap<>();
		for (Port port : report.getSubject().getInputPorts()) {
			inputs.put(port.getName(), null);
		}

		outputs = new TreeMap<>();
		for (Port port : report.getSubject().getOutputPorts()) {
			outputs.put(port.getName(), null);
		}
	}

	/**
	 * Returns the name for this invocation.
	 *
	 * @return the name for this invocation
	 */
	@JsonProperty("name")
	public String getName() {
		return name;
	}

	/**
	 * Returns the  identifier for this invocation by prepending the identifier of the parent
	 * invocation.
	 *
	 * @return the identifier for this invocation
	 */
	@JsonProperty("id")
	public String getId() {
		if (parent != null) {
			String parentId = parent.getId();
			if (parentId != null && !parentId.isEmpty()) {
				return parent.getId() + "/" + name;
			}
		}
		return "/" + name;
	}
<commit_msg>Removed root '/' from invocation id.<commit_after>/*******************************************************************************
 * Copyright (C) 2013 The University of Manchester
 *
 *  Modifications to the initial code base are copyright of their
 *  respective authors, or their employers as appropriate.
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public License
 *  as published by the Free Software Foundation; either version 2.1 of
 *  the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 ******************************************************************************/
package uk.org.taverna.platform.report;

import java.nio.file.Path;
import java.util.Map;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;

import uk.org.taverna.scufl2.api.port.Port;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * A single invocation of a workflow, processor or activity.
 *
 * @author <NAME>
 */
public class Invocation implements Comparable<Invocation> {

	private final String name;

	private final int[] index;

	private final Invocation parent;

	private final SortedSet<Invocation> invocations;

	private final StatusReport<?, ?> report;

	private SortedMap<String, Path> inputs, outputs;

	public Invocation(String name, Invocation parent, StatusReport<?, ?> report) {
		this(name, new int[0], parent, report);
	}

	public Invocation(String name, int[] index, Invocation parent, StatusReport<?, ?> report) {
		this.name = name;
		this.index = index;
		this.parent = parent;
		if (parent != null) {
			parent.getInvocations().add(this);
		}
		this.report = report;
		report.addInvocation(this);

		invocations = new TreeSet<>();

		inputs = new TreeMap<>();
		for (Port port : report.getSubject().getInputPorts()) {
			inputs.put(port.getName(), null);
		}

		outputs = new TreeMap<>();
		for (Port port : report.getSubject().getOutputPorts()) {
			outputs.put(port.getName(), null);
		}
	}

	/**
	 * Returns the name for this invocation.
	 *
	 * @return the name for this invocation
	 */
	@JsonProperty("name")
	public String getName() {
		return name;
	}

	/**
	 * Returns the  identifier for this invocation by prepending the identifier of the parent
	 * invocation.
	 *
	 * @return the identifier for this invocation
	 */
	@JsonProperty("id")
	public String getId() {
		if (parent != null) {
			String parentId = parent.getId();
			if (parentId != null && !parentId.isEmpty()) {
				return parent.getId() + "/" + name;
			}
		}
		return name;
	}

{'fraction_non_alphanumeric': 0.1522469214776907, 'fraction_numerical': 0.007036622421237806, 'mean_word_length': 4.1053061224489795, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1119400', 'n_tokens_mistral': 1894, 'n_tokens_neox': 1716, 'n_words': 630}