public void TestGetIdentifiersForYears_01() { // Test that an artefact for a specific year is returned string[] identifiers = DublinCoreReader.GetIdentifiersForYears(new string[] { "2015" }); Assert.That(identifiers.Length == 1); Assert.That(identifiers[0] == "DeerMan"); }
private void BrowseMode(string browseType) { string[] browseAttributes; switch (browseType) { case "Creator": browseAttributes = DublinCoreReader.GetValuesForCreator(); break; case "Contributor": browseAttributes = DublinCoreReader.GetValuesForContributor(); break; case "Date": browseAttributes = DublinCoreReader.GetAllYears(); break; case "Subject": browseAttributes = DublinCoreReader.GetValuesForSubject(); break; default: browseAttributes = null; break; } Array.Sort(browseAttributes); browseMode = browseType; InstantAttributes(browseAttributes); }
/// <summary> /// Loads data asynchronously. This method is called via LoadData(string artefactIdentifier) to hide the asynchronous /// implementation from the caller as the implementation is not relevant to existing client code. /// /// In many cases, this function will run all-at-once; the function need only yield in the case where data has yet to /// be loaded from disk or over the network /// </summary> /// <param name="artefactIdentifier">The identifier of the artefact to load</param> private IEnumerator LoadDataAsync(string artefactIdentifier) { Debug.Log("ContextPanel_InfoController.LoadDataAsync"); InfoMode.SwitchMode("info"); artefactId = artefactIdentifier; // If the DublinCoreReader has not been populated with data by some preceding operation, populate it now if (!DublinCoreReader.HasXml()) { Debug.Log("Populateding DublinCoreReader"); UnityWebRequest www = UnityWebRequest.Get(Paths.ArtefactMetadata); yield return(www.Send()); if (www.isError) { Debug.Log("There was an error downloading artefact information: " + www.error); } else { DublinCoreReader.LoadXmlFromText(www.downloadHandler.text); } } Dictionary <string, Dictionary <string, string[]> > data = DublinCoreReader.GetArtefactWithIdentifier(artefactIdentifier); ArtefactInfoLoad(data); ContextInfoLoad(data); ObjectInfoLoad(data); MediaInfoLoad(data); MeshInfoLoad(data); }
public void TestGetIdentifiersForYears_04() { // Test that artefacts are returned even if some years are irrelevant string[] identifiers = DublinCoreReader.GetIdentifiersForYears(new string[] { "2015", "1901", "1902" }); Assert.That(identifiers.Length == 1); Assert.That(identifiers[0] == "DeerMan"); }
public void TestGetValuesForCreator() { string[] values = DublinCoreReader.GetValuesForCreator(); Assert.That(values.Length == 2); Assert.That(values [0] == "Ryan Achten"); Assert.That(values [1] == "Some Other Guy"); }
public void TestGetIdentifiersForCreators_02() { string[] values = DublinCoreReader.GetValuesForCreator(); string[] identifiers = DublinCoreReader.GetIdentifiersForCreators(new string[] { values[1] }); Assert.That(identifiers.Length == 1); Assert.That(identifiers [0] == "TestMonk"); }
public void TestGetIdentifiersForContributors_01() { // Test that passing all contributors returns all artefacts string[] values = DublinCoreReader.GetValuesForContributor(); string[] identifiers = DublinCoreReader.GetIdentifiersForContributors(values); Assert.That(identifiers.Length == 2); }
public void TestGetAllYears_Descending() { // Test that all years are a returned in reverse-sorted order string[] years = DublinCoreReader.GetAllYears(); Assert.That(years.Length == 2); Assert.That(years[0] == "2016"); Assert.That(years[1] == "2015"); }
public void TestGetAllYears_Ascending() { // Test that all years are a returned in ascending order string[] years = DublinCoreReader.GetAllYears(true); Assert.That(years.Length == 2); Assert.That(years[0] == "2015"); Assert.That(years[1] == "2016"); }
public void TestGetIdentifiersForCreators_03() { string[] values = DublinCoreReader.GetValuesForCreator(); string[] identifiers = DublinCoreReader.GetIdentifiersForCreators(values); Assert.That(identifiers.Length == 2); Assert.That(identifiers [0] == "DeerMan"); Assert.That(identifiers [1] == "TestMonk"); }
public void TestGetIdentifiersForContributors_02() { // Test set semantics (i.e. values[1] and values[3] are contributors for the same artefact, so should return one result) string[] values = DublinCoreReader.GetValuesForContributor(); string[] identifiers = DublinCoreReader.GetIdentifiersForContributors(new string[] { values [1], values [3] }); Assert.That(identifiers.Length == 1); Assert.That(identifiers[0] == "DeerMan"); }
public void TestGetIdentifiersForYears_02() { // Test that artefacts for many years are returned string[] identifiers = DublinCoreReader.GetIdentifiersForYears(new string[] { "2015", "2016" }); Assert.That(identifiers.Length == 2); Assert.That(identifiers[0] == "DeerMan"); Assert.That(identifiers[1] == "TestMonk"); }
/// <summary> /// Instantiates media prefabs depending on media type /// </summary> /// <param name="identifier">Identifier of artefact.</param> /// <param name="mediaType">Media type of media to be instantiated.</param> private void InstantMedia(string identifier, string mediaType) { Object mediaPrefab = new Object(); if (mediaType == "Image") { mediaPrefab = imagePrefab; } else if (mediaType == "Audio") { mediaPrefab = audioPrefab; } else if (mediaType == "Video") { mediaPrefab = videoPrefab; } try { // Debug.Log("identifier: " + identifier + " mediaType: " + mediaType); Dictionary <string, string>[] media = DublinCoreReader.GetContextualMediaArtefactWithIdentifierAndType(identifier, mediaType); for (int i = 0; i < media.Length; i++) { string mediaName = media[i]["MediaName"]; string mediaLocation = media[i]["MediaLocation"]; // Debug.Log(mediaName); // Debug.Log(mediaLocation); GameObject mediaInstant = Object.Instantiate(mediaPrefab, contentParent) as GameObject; mediaInstant.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1); Text mediaText = mediaInstant.transform.GetChild(1).gameObject.GetComponent <Text>(); //updates the prefab title mediaText.text = mediaName; if (mediaType == "Image") { BrowseImpContextImg imgImpScript = mediaInstant.GetComponentInChildren <BrowseImpContextImg>(); // Debug.Log("mediaLocation: " + mediaLocation); StartCoroutine(imgImpScript.ContextImgImp(mediaLocation)); //TODO this coroutine is not working properly } // else if (mediaType == "Audio") // { // mediaPrefab = audioPrefab; // } // else if (mediaType == "Video") // { // mediaPrefab = videoPrefab; // } } } catch (System.Exception ex) { Debug.Log("No Contextual Media for this artefact"); GameObject mediaInstant = Object.Instantiate(noMediaPrefab, contentParent) as GameObject; mediaInstant.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1); } }
public void TestGetIdentifiersForDateRange_03() { // Test that no artefacts are returned when the date range does not overlap the artefacts DateTime start = DateTime.Parse("1970-01-01"); DateTime end = DateTime.Parse("1971-01-01"); string[] identifiers = DublinCoreReader.GetIdentifiersForDateRange(start, end); Assert.That(identifiers.Length == 0); }
public void DownloadXmlFile() { WWW www = new WWW(url); while (!www.isDone) { } DublinCoreReader.LoadXmlFromText(www.text); }
// TODO this current process isn't ideal the ID is referenced from the TestController script //this could later be a 'Panel Controller', however not sure if this is the best approach //(i.e. relying on a public var too unstable?) /// <summary> /// Detects which user defined toggles are active for viewing media /// </summary> public void LoadMedia() //executed on pressing Media button { #if UNITY_WEBGL StartCoroutine(LoadMediaAsync()); #elif UNITY_STANDALONE DublinCoreReader.LoadXmlFromFile(Paths.ArtefactMetadata); CheckToggles(); #endif }
public void TestGetValuesForContributor() { string[] values = DublinCoreReader.GetValuesForContributor(); Assert.That(values.Length == 4); Assert.That(values [0] == "Another Contributor"); Assert.That(values [1] == "Doprah"); Assert.That(values [2] == "Some Contributor"); Assert.That(values [3] == "Yet Another Contributor"); }
public void TestGetIdentifiersForSubjects_03() { // Test that a Subject appearing in two artefacts returns two identifiers string[] values = DublinCoreReader.GetValuesForSubject(); string[] identifiers = DublinCoreReader.GetIdentifiersForSubjects(new string[] { values [2] }); Assert.That(identifiers.Length == 2); Assert.That(identifiers[0] == "DeerMan"); Assert.That(identifiers[1] == "TestMonk"); }
public void TestGetValuesForSubject() { string[] values = DublinCoreReader.GetValuesForSubject(); Assert.That(values.Length == 4); Assert.That(values [0] == "Album Art"); Assert.That(values [1] == "Music"); Assert.That(values [2] == "Stuff Ryan made"); Assert.That(values [3] == "Testing"); }
public void TestGetIdentifiersForDateRange_02() { // Test that a specific artefact is returned when the date range is sufficient narrow DateTime start = DateTime.Parse("2015-10-02"); DateTime end = DateTime.Parse("2015-10-04"); string[] identifiers = DublinCoreReader.GetIdentifiersForDateRange(start, end); Assert.That(identifiers.Length == 1); Assert.That(identifiers[0] == "DeerMan"); }
public void TestGetIdentifiersForDateRange_04() { // Test that an artefact is returned when the start date and end date are equal, and equal the created date of the artefact DateTime start = DateTime.Parse("2015-10-03"); DateTime end = DateTime.Parse("2015-10-03"); string[] identifiers = DublinCoreReader.GetIdentifiersForDateRange(start, end); Assert.That(identifiers.Length == 1); Assert.That(identifiers[0] == "DeerMan"); }
/// <summary> /// Imports collection artefact's mesh and texture, assigns object info /// </summary> /// <param name="collectionIdentifiers">array of identifiers belonging to collection</param> public void ImportArtefacts(string collectId) { ResetInstances(); #if UNITY_WEBGL StartCoroutine(DownloadArtefactXmlAndImportArtefacts(collectId)); #elif UNITY_STANDALONE DublinCoreReader.LoadXmlFromFile(Paths.ArtefactMetadata); GetIdentifiers(collectId); #endif }
public void TestGetIdentifiersForDateRange_01() { // Test that all artefact are returned when the date range is sufficiently wide DateTime start = DateTime.Parse("2015-10-02"); DateTime end = DateTime.Parse("2016-08-05"); string[] identifiers = DublinCoreReader.GetIdentifiersForDateRange(start, end); Assert.That(identifiers.Length == 2); Assert.That(identifiers[0] == "DeerMan"); Assert.That(identifiers[1] == "TestMonk"); }
public void TestGetContextualMediaOfForArtefactWithIdentifierAndType() { Dictionary <string, string>[] contextualMedia = DublinCoreReader.GetContextualMediaArtefactWithIdentifierAndType("TestMonk", "Image"); Assert.That(contextualMedia [0] ["MediaName"] == "MetaPipe_TestTexs_1000"); Assert.That(contextualMedia [0] ["MediaType"] == "Image"); Assert.That(contextualMedia [0] ["MediaLocation"] == "/VerticeArchive/TEST/TestTexs_1000.jpg"); Assert.That(contextualMedia [1] ["MediaName"] == "MetaPipe_TestTexs_2000W"); Assert.That(contextualMedia [1] ["MediaType"] == "Image"); Assert.That(contextualMedia [1] ["MediaLocation"] == "/VerticeArchive/TEST/TestTexs_2000W.jpg"); }
private string browseMode; //user defined browse mode /// <summary> /// Gets all attributes related to a user browse query type. Executes DCReader function. /// </summary> /// <param name="browseType">Type of browse user wants to view</param> public void GetAttributes(string browseType) { // Debug.Log("GetAttr: " + browseType); #if UNITY_WEBGL StartCoroutine(GetAttributesAsync(browseType)); #elif UNITY_STANDALONE // Debug.Log ("Populating DublinCoreReader"); DublinCoreReader.LoadXmlFromFile(Paths.ArtefactMetadata); BrowseMode(browseType); #endif }
private void GetIdentifiers(string collectId) { collectionId = collectId; string[] collectionIdentifiers = CollectionReader.GetIdentifiersForArtefactsInCollectionWithIdentifier(collectId); importedObjects = new GameObject[collectionIdentifiers.Length]; progressBar.SetActive(true); ProgressBarCont.SetMaxVal(collectionIdentifiers.Length * 2); for (int i = 0; i < collectionIdentifiers.Length; i++) { string meshLocation = Paths.PathToFile(DublinCoreReader.GetMeshLocationForArtefactWithIdentifier(collectionIdentifiers [i])); string texLocation = Paths.PathToFile(DublinCoreReader.GetTextureLocationForArtefactWithIdentifier(collectionIdentifiers [i])); StartCoroutine(ImportModel(i, collectionIdentifiers[i], meshLocation, texLocation)); } }
/// <summary> /// Imports browse artefact's mesh and texture, assigns object info /// </summary> /// <param name="browseIdentifiers">array of identifiers to browse</param> public void ImportArtefacts(string[] browseIdentifiers) { ResetInstances(); importedObjects = new GameObject[browseIdentifiers.Length]; progressBar.SetActive(true); ProgressBarCont.SetMaxVal(browseIdentifiers.Length * 2); for (int i = 0; i < browseIdentifiers.Length; i++) { string meshLocation = Paths.PathToFile(DublinCoreReader.GetMeshLocationForArtefactWithIdentifier(browseIdentifiers [i])); string texLocation = Paths.PathToFile(DublinCoreReader.GetTextureLocationForArtefactWithIdentifier(browseIdentifiers [i])); StartCoroutine(ImportModel(i, browseIdentifiers[i], meshLocation, texLocation)); } }
/// <summary> /// Executed once user has finished their selection of relevant attributes /// </summary> public void DoneAttributeSelect() { List <string> activeAttributes = new List <string> (); for (int i = 0; i < attributeParent.childCount; i++) { Toggle curToggle = attributeParent.GetChild(i).GetComponent <Toggle>(); if (curToggle.isOn) { activeAttributes.Add(attributeParent.GetChild(i).GetComponentInChildren <Text>().text); } } string[] activeAttrArray = activeAttributes.ToArray(); //need to convert to array to account for DCReader, need list cause don't know how many attrs will be active string[] attributeIdentifiers; switch (browseMode) { case "Creator": attributeIdentifiers = DublinCoreReader.GetIdentifiersForCreators(activeAttrArray); break; case "Contributor": attributeIdentifiers = DublinCoreReader.GetIdentifiersForContributors(activeAttrArray); break; case "Date": attributeIdentifiers = DublinCoreReader.GetIdentifiersForYears(activeAttrArray); break; case "Subject": attributeIdentifiers = DublinCoreReader.GetIdentifiersForSubjects(activeAttrArray); break; default: attributeIdentifiers = null; break; } if (attributeIdentifiers.Length > 0) { BrowseCont.ImportArtefacts(attributeIdentifiers); } gameObject.SetActive(false); //turns panel off once query has been committed }
/// <summary> /// Asynchronous, private implementation for the public-facing ImportArtefacts(...) method. Allows the caller to /// ignore any implementation details (i.e. they do not need to call StartCoroutine, etc. /// /// Checks to see if the DublinCoreReader has data available, otherwise it downloads it in a non-blocking fashion. /// /// When data is present, it is used to import meshes, textures, and metadata, and instantiate objects /// </summary> /// <param name="collectId">Collection identifier.</param> IEnumerator DownloadArtefactXmlAndImportArtefacts(string collectId) { if (!DublinCoreReader.HasXml()) { UnityWebRequest www = UnityWebRequest.Get(Paths.ArtefactMetadata); //Paths.Remote + "/Metadata/Vertice_ArtefactInformation.xml" yield return(www.Send()); if (www.isError) { // TODO: Echo the error condition to the user Debug.Log("Couldn't download XML file" + www.error); } else { DublinCoreReader.LoadXmlFromText(www.downloadHandler.text); Debug.Log("Downloaded some XML"); } } GetIdentifiers(collectId); }
/// <summary> /// Provides a backing for GetAttributes(string browseType) that can load data in to the DublinCoreReader asynchronously in the case /// where the DCReader has yet to be populated with data /// </summary> /// <param name="browseType">The field to browse on</param> private IEnumerator GetAttributesAsync(string browseType) { // If the DublinCoreReader has not been populated with data by some preceding operation, populate it now if (!DublinCoreReader.HasXml()) { Debug.Log("Populating DublinCoreReader"); UnityWebRequest www = UnityWebRequest.Get(Paths.ArtefactMetadata); //Paths.Remote + "/Metadata/Vertice_ArtefactInformation.xml" yield return(www.Send()); if (www.isError) { Debug.Log("There was an error downloading artefact information: " + www.error); } else { DublinCoreReader.LoadXmlFromText(www.downloadHandler.text); } } BrowseMode(browseType); }