QualifiedPath to regular tag path

For a historical tag, how can I convert a QualifiedPath like this
histprov:Sample_SQLite_Database:/drv:ignition-2023lt-c3faby3-:sample_tags:/tag:realistic/realistic0

to a regular tag path:
[Sample_SQLite_Database]realistic/realistic0

QualifiedPath's are just a set of properties strung together. In your case, histprov, drv, and tag are your property names, and Sample_SQLite_Database, ignition-2023lt-c3faby3-:sample_tags, and realistic/realistic0 are their respective property values. If it were in a json format, it might look like this*:

{
	"histprov": "Sample_SQLite_Database",
	"drv": "ignition-2023lt-c3faby3-:sample_tags",
	"tag": "realistic/realistic0"
}

*I'm not sure if :sample_tags means something special here or not, but it shouldn't matter for our purposes.

The general format I've found is this:
key1:value1:/key2:value2 ...

But, after looking at the docs, it looks like all we need to do is use the QualifiedPathUtils class:

Specifically, the function I think you're looking for already exists:

import com.inductiveautomation.ignition.common.QualifiedPathUtils;
import com.inductiveautomation.ignition.common.QualifiedPath;

public class HistoricalTagPathExample {

	public static void main(String[] args) {
		// Assuming myQualifiedPath is already defined as a QualifiedPath object
		QualifiedPath myQualifiedPath = ...; // Initialize this with an appropriate value

		// Convert the QualifiedPath to a String for a historical path
		String myHistoricalTagPath = QualifiedPathUtils.toStringFromHistoricalPath(myQualifiedPath);

		// Print the result
		System.out.println("Historical Tag Path: " + myHistoricalTagPath);
	}
}

Throw this in your bookmark folder. You're going to want to use it a lot: Overview

1 Like

Thank you! I tried looking for a pre-existing function in the docs to help me with this, but I could not find it. Could you suggest a strategy I can use to help me find stuff like this faster in the future?

Our SDK docs are very inadequate - mostly because the subject matter experts are too busy making Ignition to contribute the necessary time to the docs and/or disseminate knowledge among the technical writing staff.

We're hoping to do a better job with 8.3.0, at least setting a standard for new functionality documentation that we can then expand over time to the rest of Ignition, or at least the more commonly exercised portions.

This forum is your best resource for SDK questions, by far.

1 Like

Did you try putting "QualifiedPath" in the javadocs' search field?

That search field is where I start with any class name I encounter anywhere else. Then follow linked javadocs that look potentially helpful.