For context, I've been trying to write some code to mass-replace data sources. However, Pro's only way to do this, updateConnectionProperties(), requires you to know not just the file path, but what type of file and workspace it belongs to. *
This would be fine except there's no documentation for acceptable values, nor is there an easy way to find out, short of loading all of your files and checking their connection properties yourself.
What I am looking for is an exhaustive list of possible values for the workspace_factory parameter.
At the end of all of this, I still don't have any idea of what my possible options are.
Improved documentation would be a lifesaver, considering updateConnectionProperties() already asks you do a lot of the thinking that it should be doing for you (Meaning it should be able to figure out if you’re feeding it a shapefile or not without you telling it).
5. Layer properties—ArcGIS Pro | Documentation I checked dataElementType and dataType. Neither are formatted correctly, so I would need to build a dictionary to match to the (missing) comprehensive list.
I thought I might be able to make a list by just describing every file in a directory, then returning the set, but surprise: any coverages will crash both Pro and ArcMap (To be clear, I'm not planning on using coverages, but we do have some and they're getting in the way of trying to get this list).
This will crash Pro and ArcMap/Catalog when it reaches a coverage. Changing to arcpy.da.Describe() for Pro doesn’t help.
This list is not exhaustive; shapefiles and rasters would not return anything useful, despite having an entry in connectionProperties. Also, this list is not formatted in the way I need for use in updateConnectionProperties().
10. replaceDataSource() (Arcmap) has a potentially useful list, although not formatted in a helpful way.
ACCESS_WORKSPACE — A personal geodatabase or Access workspace
ARCINFO_WORKSPACE — An ArcInfo coverage workspace
CAD_WORKSPACE —A CAD file workspace
EXCEL_WORKSPACE —An Excel file workspace
FILEGDB_WORKSPACE —A file geodatabase workspace
NONE —Used to skip the parameter
OLEDB_WORKSPACE —An OLE database workspace
PCCOVERAGE_WORKSPACE —A PC ARC/INFO Coverage workspace
RASTER_WORKSPACE —A raster workspace
SDE_WORKSPACE —An SDE geodatabase workspace
SHAPEFILE_WORKSPACE —A shapefile workspace
TEXT_WORKSPACE —A text file workspace
TIN_WORKSPACE —A TIN workspace
VPF_WORKSPACE —A VPF workspace
11. I checked _mp, arcobjects (every file), anything to do with toolboxes. Nothing.
*To be clear, depending on your use case, you may need less. In my case, where I'm frequently changing not just the GDB or folder, but also changing to a file with a different name, I do need this information. See "Changing a layer's dataset" here.
There are a few new things in the 3.1 Updating Data Sources help that might help with this.
1.) In the first batch of samples, look at sample #6. New at 3.1, you dont need to know anything about the source of the existing layer. You can supply None in the first parameter. E.g.
2.) Check out the sub sections entitled Updating data sources via the CIM and Changing a layer's dataset. Changing a layer's dataset via the CIM might be easier than using the ConnectionProperties dictionary in your case. Those aforementioned sections might be more in line with what you are trying to accomplish. There is a trail of breadcrumbs that will lead you to a list of the workspace factory values. (But I admit that it's not the easiest thing to find. I will investigate a way to make this easier in the future.) If you follow the link to the Python CIM Access topic, then to the CIM Spec, they are listed in the CIM spec here. Search for WorkspaceFactory on that page.
To your first point, it doesn't matter at all what the existing source is, all that matters is what you're trying to replace it with. (As an aside: really, UpdateConnectionProperties() should be able to just figure this stuff out. If Pro can do it when you go through GUI, it should be able to do it through Python)
I gave the CIM properties a shot, and ultimately, they haven't worked out. 1) They still require you to know what kind of file it is that you're replacing with and 2) I can change the layer source just fine by updating CIM, but if I save and come back, it's broken and the source is now the name of the project folder plus the source I tried changing it to. I would say this is user error except for it works fine in the session so ¯\_ (ツ)_/¯.
(Also this set up will crash Pro if you try to manually replace the sources and it looks like this.)
More importantly, the list that you give (which is comprehensive and great for CIM stuff) is formatted differently from the acceptable values in updateConnectionProperties(). For example, acceptable values there are "Shape File" and "File Geodatabase", not "Shapefile" and "FileGDB". Using either of the latter values doesn't do anything. Like, not even an error. It just skips by.
Below is my CIM code. I've just been dropping it into the Python window to test. (I'm stuck in 2.9 for now)
For testing, I'm using a blank shapefile (No records, nothing) and a similarly blank file geodatabase feature class, trying to switch the layer's reference between them. I have the full range of acceptable values in wkspfactList, but this error behaviour also occurs if that list of values is just ["FileGDB", "Shapefile"].
Again, it works great as long as the Project is open and falls apart once you exit.
aprx = arcpy.mp.ArcGISProject('CURRENT')
mp = aprx.activeMap
lays = mp.listLayers()
sourceDict = {r"W:\Downloads\testmdb\test.gdb\ex1gdb": r"W:\Downloads\testmdb\example1.shp",
r"W:\Downloads\testmdb\example1.shp": r"W:\Downloads\testmdb\test.gdb\ex1gdb"}
''' Update CIM workflow'''
wkspfactList = ["SDE", "FileGDB", "Raster", "Shapefile", "OLEDB",
"Access", "DelimitedTextFile", "Custom", "Sql",
"Tin", "TrackingServer", "NetCDF", "LASDataset",
"SQLite", "FeatureService", "ArcInfo", "Cad",
"Excel", "WFS", "StreamService", "BIMFile",
"InMemoryDB", "NoSQL", "BigDataConnection",
"KnowledgeGraph", "NITF"]
for lay in lays:
if lay.isGroupLayer:
continue
# If anyone can tell me why sometimes layers support
# dataSource and sometimes they don't; that'd be awesome.
# Ditto for catalogPath.
if lay.supports("dataSource"):
layPath = lay.dataSource
else:
layPath= arcpy.da.Describe(lay)["catalogPath"]
if layPath in sourceDict:
descR= arcpy.da.Describe(sourceDict[layPath])
for wkspc in wkspfactList:
# Get the layer's CIM definition
layCIM = lay.getDefinition('V2')
# Create a new CIM data connection
dc = arcpy.cim.CreateCIMObjectFromClassName('CIMStandardDataConnection', 'V2')
# Specify the geodatabase
dc.workspaceConnectionString = f"DATABASE= {descR['path']}"
# Specify the workspace type
dc.workspaceFactory = wkspc
# Specify the dataset name
dc.dataset = descR['name']
# Set the new data connection to the layer's CIM featureTable
layCIM.featureTable.dataConnection = dc
# Set the layer's CIM definition
lay.setDefinition(layCIM)
# Stop if you have something that works.
if lay.isBroken:
continue
else:
break
For updateConnectionProperties: This works great except for I don't know the acceptable values nor how to guess them.
aprx = arcpy.mp.ArcGISProject('CURRENT')
mp = aprx.activeMap
lays = mp.listLayers()
sourceDict = {r"W:\Downloads\testmdb\test.gdb\ex1gdb": r"W:\Downloads\testmdb\example1.shp",
r"W:\Downloads\testmdb\example1.shp": r"W:\Downloads\testmdb\test.gdb\ex1gdb"}
''' updateConnectionProperties workflow'''
wkspfactDict = {"DEFeatureClass": "File Geodatabase",
"DEShapeFile": "Shape File"}
for lay in lays:
if lay.isGroupLayer:
continue
# If anyone can tell me why some layers don't support dataSource
# that'd be great.
if lay.supports("dataSource"):
layPath = lay.dataSource
else:
layPath= arcpy.da.Describe(lay)["catalogPath"]
if layPath in sourceDict:
descR= arcpy.da.Describe(sourceDict[layPath])
layCP = lay.connectionProperties
fCP = {'dataset': descR["name"],
'workspace_factory': wkspfactDict[descR["dataElementType"]],
'connection_info':
{'database': descR["path"]}
}
lay.updateConnectionProperties(layCP, fCP )
print("done")
I hate to say it, but this entire thing was a lot easier in ArcMap; you made a list, looped until something didn't break, and there you go. Having to make an educated guess is a lot more trouble, especially since Pro apparently will just change stuff to whatever you say instead of breaking if it doesn't work.
def replaceDS27(sourcemap, sourcedict):
sourcemap = arcpy.mapping.MapDocument(sourcemap)
#for lay in arcpy.mapping.ListBrokenDataSources(sourcemap):
for lay in arcpy.mapping.ListLayers(sourcemap):
layDS= lay.dataSource
if layDS in sourcedict:
layD= sourcedict[layDS]
dirN= os.path.dirname(layD)
baseN= os.path.splitext(os.path.basename(layD))[0]
wkspcType = ['ACCESS_WORKSPACE',
'ARCINFO_WORKSPACE',
'CAD_WORKSPACE',
'EXCEL_WORKSPACE',
'FILEGDB_WORKSPACE',
'NONE',
'OLEDB_WORKSPACE',
'PCCOVERAGE_WORKSPACE',
'RASTER_WORKSPACE',
'SDE_WORKSPACE',
'SHAPEFILE_WORKSPACE',
'TEXT_WORKSPACE',
'TIN_WORKSPACE',
'VPF_WORKSPACE'
]
# Attempt to replace the source by guessing the wkspc type.
# Really we're just brute-forcing it rather than making
# an educated guess.
for wkspc in wkspcType:
try:
lay.replaceDataSource(dirN, wkspc, baseN)
break
except:
continue
sourcemap.save()
I think in addition to a proper list of acceptable types of workspace factory; some sort of documentation showing how to programmatically find what types you have would be nice, to avoid the "Throw against the wall and see what sticks" operation I've been running.* What I did for ArcMap works great but is pretty inefficient.
I've made an attempt to do this in the updateConnectionProperties() example by checking the dataElementType, but I'm not sure how viable that is outside of shapefiles and file gdb feature classes.
* The obvious question is "Why don't you know what types of data you have?" and the answer is I'm trying to do this for thousands of files, and it's easier to have the computer figure it out than it is for me.
I tried the CIM workflow you posted, changing only the necessary values (and the CIM version, since I'm in 2.9 for the foreseeable future.) The same thing happened with the new data source, and a colleague tested the same code with the same result.
I think I'm going to have to submit a support ticket for this specific issue.
That being said, I do want to reiterate the need for a comprehensive list of acceptable values for updateConnectionProperties(), as well as a way to programmatically determine which of those values is appropriate for your data.
Nope, all out in the open. The shapefiles I've been testing with are in the same folder (testmdb) as well. I tested converting between the two gdb feature classes and converting between the two shapefiles, using version 2.9.5
I also need a comprehensive list of the workspace connection properties. I need to loop through folders containing lyrx files that are sourced from all different types of data. I need to print out the location of the data (ie if map service I need to print a URL, if raster I need to print the SDE properties, if shapefile I need to print folder and dataset name) A comprehensive list of workspace connection properties could speed up my process infinitely.
';
}
}
}
catch(e){
}
}
}
if (newSub.getAttribute("slang").toLowerCase() != code_l.toLowerCase()) {
if (trLabelsHtml != "") {
var labelSname = "";
if(labelEle[i].querySelector("ul li:nth-child(1)").getAttribute("aria-hidden")){
labelSname = labelEle[i].querySelector("ul li:nth-child(1)").outerHTML;
}
labelEle[i].innerHTML = "";
labelEle[i].innerHTML = labelSname + trLabelsHtml;
}
}
}
}
}
catch(e){
}
}
}
/* V 2.0:3 = Store not translated reply id */
if(lingoRSXML.snapshotLength == 0){
if($scope.falseReplyID == "") {
$scope.falseReplyID = value;
}
}
/* Get translated Body of Replies/Comments */
var lingoRBXML = doc.evaluate(lingoRBExp, doc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for(var i=0;i 0) {
var attachDiv = rootElement.querySelector('div.lia-quilt-row-main').querySelector('div.custom-attachments');
if (attachDiv) {
attachDiv = attachDiv.outerHTML;
}
else if(rootElement.querySelector('div.lia-quilt-row-main').querySelectorAll('#attachments').length > 0){
if ("IdeaPage" == "BlogArticlePage") {
attachDiv = rootElement.querySelector('div.lia-quilt-row-main .lia-message-body-content').querySelector('#attachments');
if (attachDiv) {
attachDiv = attachDiv.outerHTML;
}
else{
attachDiv = "";
}
}else{
attachDiv = rootElement.querySelector('div.lia-quilt-row-main').querySelector('#attachments').outerHTML;
}
}
else {
attachDiv = "";
}
/* Feedback Div */
var feedbackDiv = "";
var feedbackDivs = rootElement.querySelector('div.lia-quilt-row-main').querySelectorAll('div.lia-panel-feedback-banner-safe');
if (feedbackDivs.length > 0) {
for (var k = 0; k < feedbackDivs.length; k++) {
feedbackDiv = feedbackDiv + feedbackDivs[k].outerHTML;
}
}
}
else {
var attachDiv = rootElement.querySelector('div.lia-message-body-content').querySelector('div.Attachments.preview-attachments');
if (attachDiv) {
attachDiv = attachDiv.outerHTML;
} else {
attachDiv = "";
}
/* Everyone tags links */
if (document.querySelectorAll("div.TagList").length > 0){
var everyoneTagslink = document.querySelector('div.lia-quilt-row-main').querySelector(".MessageTagsTaplet .TagList");
if ((everyoneTagslink != null)||(everyoneTagslink != undefined)){
everyoneTagslink = everyoneTagslink.outerHTML;
}
else{
everyoneTagslink = "";
}
}
/* Feedback Div */
var feedbackDiv = "";
var feedbackDivs = rootElement.querySelector('div.lia-message-body-content').querySelectorAll('div.lia-panel-feedback-banner-safe');
if (feedbackDivs.length > 0) {
for (var m = 0; m < feedbackDivs.length; m++) {
feedbackDiv = feedbackDiv + feedbackDivs[m].outerHTML;
}
}
}
}
} catch (e) {
}
if (body_L == "") {
/* V 2.0:7 Replacing translated video data with source video data */
var newBodyVideoData = newBody.querySelectorAll('div[class*="video-embed"]');
angular.forEach($scope.videoData[value], function (sourceVideoElement, index) {
if (index <= (newBodyVideoData.length - 1)) {
newBodyVideoData[index].outerHTML = sourceVideoElement.outerHTML
}
});
/* V 2.0:7 = Replacing translated image data with source data */
var newBodyImageData = newBody.querySelectorAll('[class*="lia-image"]');
angular.forEach($scope.imageData[value], function (sourceImgElement, index) {
if (index <= (newBodyImageData.length - 1)) {
newBodyImageData[index].outerHTML = sourceImgElement.outerHTML;
}
});
/* V 2.0:7 = Replacing translated pre tag data with source data */
var newBodyPreTagData = newBody.querySelectorAll('pre');
angular.forEach($scope.preTagData[value], function (sourcePreTagElement, index) {
if (index <= (newBodyPreTagData.length - 1)) {
newBodyPreTagData[index].outerHTML = sourcePreTagElement.outerHTML;
}
});
}
var copyBodySubject = false;
if (body_L == "") {
copyBodySubject = true;
body_L = newBody.innerHTML;
}
/* This code is written as part of video fix by iTalent */
/* try{
var iframeHTMLText = body_L;
var searchIframeText = "<IFRAME";
var foundiFrameTag;
if (iframeHTMLText.indexOf(searchIframeText) > -1) {
foundiFrameTag = decodeHTMLEntities(iframeHTMLText);
foundiFrameTag = foundiFrameTag.split('src="')[1];
body_L = foundiFrameTag;
}
}
catch(e){
} */
/* This code is placed to remove the extra meta tag adding in the UI*/
try{
body_L = body_L.replace('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />','');
}
catch(e){
}
/** We should not replace the source content if user profile language and selected target language matches with source language **/
if(showTrContent) {
var compiled = false;
rootElement.querySelectorAll('div.lia-message-body-content')[0].innerHTML = null
if("IdeaPage"=="IdeaPage"){
// var customAttachDiv = '';
rootElement.querySelectorAll('div.lia-message-body-content')[0].innerHTML = body_L + feedbackDiv ;
$compile(rootElement.querySelectorAll('div.lia-message-body-content')[0])($scope);
compiled = true;
/* Attach atttach div */
// document.querySelector("div.translation-attachments-"+value).innerHTML = attachDiv;
rootElement.querySelectorAll('div.lia-message-body-content')[0].insertAdjacentHTML('afterend',attachDiv);
if(rootElement.querySelectorAll('div.lia-quilt-idea-message .lia-message-body .lia-attachments-message').length > 1){
rootElement.querySelectorAll('div.lia-quilt-idea-message .lia-message-body .lia-attachments-message')[1].remove();
}
} else {
if("IdeaPage"=="TkbArticlePage"){
rootElement.querySelectorAll('div.lia-message-body-content')[0].innerHTML = body_L + feedbackDiv ;
}else{
rootElement.querySelectorAll('div.lia-message-body-content')[0].innerHTML = body_L + feedbackDiv + attachDiv;
compiled = true;
}
}
/* Destroy and recreate OOyala player videos to restore the videos in target languages which is written by iTalent as part of iTrack LILICON-79 */ /* Destroy and recreate OOyala player videos */
try{
// $scope.videoData[value][0].querySelector("div").getAttribute("id");
for(var vidIndex=0; vidIndex<$scope.videoData[value].length; vidIndex++){
if( $scope.videoData[value][vidIndex].querySelector("div") != null){
var containerId = LITHIUM.OOYALA.players[$scope.videoData[value][vidIndex].querySelector("div").getAttribute("id")].containerId;
videoId = LITHIUM.OOYALA.players[$scope.videoData[value][vidIndex].querySelector("div").getAttribute("id")].videoId;
/** Get the Video object */
vid = OO.Player.create(containerId,videoId);
/** Destroy the video **/
vid.destroy();
/** recreate in the same position */
var vid = OO.Player.create(containerId,videoId);
}
}
}
catch(e){
}
try{
for(var vidIndex=0; vidIndex<($scope.videoData[value].length); vidIndex++){
if($scope.videoData[value][vidIndex].querySelector('video-js') != null){
var data_id = $scope.videoData[value][vidIndex].querySelector('video-js').getAttribute('data-video-id');
var data_account = $scope.videoData[value][vidIndex].querySelector('video-js').getAttribute('data-account');
var data_palyer = $scope.videoData[value][vidIndex].querySelector('video-js').getAttribute('data-player');
var div = document.createElement('div');
div.id = "brightcove";
div.class = "brightcove-player";
div.innerHTML =
'(view in my videos)'
var data = div.getElementsByClassName("video-js");
var script = document.createElement('script');
script.src = "https://players.brightcove.net/" + data_account + "/" + data_palyer + "_default/index.min.js";
for(var i=0;i< data.length;i++){
videodata.push(data[i]);
}
}
}
for(var i=0;i< videodata.length;i++){
document.getElementsByClassName('lia-vid-container')[i].innerHTML = videodata[i].outerHTML;
document.body.appendChild(script);
}
}
catch(e){
}
if(!compiled){
/* Re compile html */
$compile(rootElement.querySelectorAll('div.lia-message-body-content')[0])($scope);
}
}
if (code_l.toLowerCase() != newBody.getAttribute("slang").toLowerCase()) {
/* Adding Translation flag */
var tr_obj = $filter('filter')($scope.sourceLangList, function (obj_l) {
return obj_l.code.toLowerCase() === newBody.getAttribute("slang").toLowerCase()
});
if (tr_obj.length > 0) {
tr_text = "Esri may utilize third parties to translate your data and/or imagery to facilitate communication across different languages.".replace(/lilicon-trans-text/g, tr_obj[0].title);
try {
if ($scope.wootMessages[$rootScope.profLang] != undefined) {
tr_text = $scope.wootMessages[$rootScope.profLang].replace(/lilicon-trans-text/g, tr_obj[0].title);
}
} catch (e) {
}
} else {
//tr_text = "This message was translated for your convenience!";
tr_text = "Esri may utilize third parties to translate your data and/or imagery to facilitate communication across different languages.";
}
try {
if (!document.getElementById("tr-msz-" + value)) {
var tr_para = document.createElement("P");
tr_para.setAttribute("id", "tr-msz-" + value);
tr_para.setAttribute("class", "tr-msz");
tr_para.style.textAlign = 'justify';
var tr_fTag = document.createElement("IMG");
tr_fTag.setAttribute("class", "tFlag");
tr_fTag.setAttribute("src", "/html/assets/langTrFlag.PNG");
tr_fTag.style.marginRight = "5px";
tr_fTag.style.height = "14px";
tr_para.appendChild(tr_fTag);
var tr_textNode = document.createTextNode(tr_text);
tr_para.appendChild(tr_textNode);
/* Woot message only for multi source */
if(rootElement.querySelector(".lia-quilt-forum-message")){
rootElement.querySelector(".lia-quilt-forum-message").appendChild(tr_para);
} else if(rootElement.querySelector(".lia-message-view-blog-topic-message")) {
rootElement.querySelector(".lia-message-view-blog-topic-message").appendChild(tr_para);
} else if(rootElement.querySelector(".lia-quilt-blog-reply-message")){
rootElement.querySelector(".lia-quilt-blog-reply-message").appendChild(tr_para);
} else if(rootElement.querySelector(".lia-quilt-tkb-message")){
rootElement.querySelector(".lia-quilt-tkb-message").appendChild(tr_para);
} else if(rootElement.querySelector(".lia-quilt-tkb-reply-message")){
rootElement.querySelector(".lia-quilt-tkb-reply-message").insertBefore(tr_para,rootElement.querySelector(".lia-quilt-row.lia-quilt-row-footer"));
} else if(rootElement.querySelector(".lia-quilt-idea-message")){
rootElement.querySelector(".lia-quilt-idea-message").appendChild(tr_para);
} else if(rootElement.querySelector('.lia-quilt-occasion-message')){
rootElement.querySelector('.lia-quilt-occasion-message').appendChild(tr_para);
}
else {
if (rootElement.querySelectorAll('div.lia-quilt-row-footer').length > 0) {
rootElement.querySelectorAll('div.lia-quilt-row-footer')[0].appendChild(tr_para);
} else {
rootElement.querySelectorAll('div.lia-quilt-column-message-footer')[0].appendChild(tr_para);
}
}
}
} catch (e) {
}
}
} else {
/* Do not display button for same language */
// syncList.remove(value);
var index = $scope.syncList.indexOf(value);
if (index > -1) {
$scope.syncList.splice(index, 1);
}
}
}
}
});
});
/* V 1.1:2 = Reply Sync button for multi source translation */
} catch(e){
console.log(e);
}
};
if((rContent != undefined) && (rContent != "")) {
drawCanvas(decodeURIComponent(rContent));
/** Update variable with selected language code **/
$scope.previousSelCode = code_l;
}
};
/**
* @function manageTranslation
* @description Managess the translation of given language for the thread
* @param {string} langCode - Language Code
* @param {string} tid - Thread ID
*/
$scope.manageTranslation = function (langCode, tid) {
//debugger;
$scope.showTrText = false;
/* V 2.0:5 = actualStatus variable introduced to indicate detailed connector status on UI. This variable holds the actual translation percentage */
$scope.transPercent = "";
$scope.actualStatus = "";
if (tid != "") {
var bulkTranslation = lithiumPlugin.bulkTranslation(langCode, tid);
bulkTranslation.then(function (trContent) {
if(trContent.body != "") {
$scope.showPreview(trContent.body, $scope.mszList, langCode);
if(langCode != "en-US") {
$scope.showTrText = true;
}
}
if((trContent.status != "NA") && trContent.status != null) {
// $scope.transPercent = String(trContent.status);
$scope.actualStatus = String(trContent.status);
} else {
// $rootScope.errorMsg = "Translation is in progress. Please check again a few minutes."
$rootScope.errorMsg = "Translation is in progress. Please retry in a few minutes."
}
$scope.workbench = trContent.wb;
/* V 2.0:4 = Trigger uncalled or delayed callbacks (documnet uploaded/translation completed from lithium).*/
if(trContent.callback == 'true') {
var trCompletCallback = lithiumPlugin.trCompletCallback(langCode, trContent.docID);
trCompletCallback.then(function (callback){
// $rootScope.errorMsg = "Downloading Translated content in " + langCode + " now. Please check again in a few minutes."
$rootScope.errorMsg = "Uploading content to translate. Please check again in a few minutes."
});
} else if (trContent.callback == 'upload') {
var trCompletUpload = lithiumPlugin.trCompletUpload(langCode, trContent.docID);
trCompletUpload.then(function (callback) {
//$rootScope.errorMsg = "Uploading content to translate. Please check again in a few minutes."
$rootScope.errorMsg = "Uploading content to translate. Please check again in a few minutes."
});
} else if ("many" == "one") {
$scope.updateOOS();
} else if("SmartConx" == "SmartConx"){
if ("many" == "many"){
$scope.updateOOS();
}
}else if ((trContent.status != null) && trContent.status.includes("100")) {
/* If everything fine then only check Out of Sync status */
$scope.updateOOS();
} else {
/* If translation perccent is less than 100 then show the percentage on UI */
$scope.transPercent = $scope.actualStatus;
}
});
}
}
/**
* @function selectThisLang
* @description Called on select dropdown.
* @param {string} lang - Language code
*
*/
$scope.selectThisLang = function (lang, anonymousFlag) {
/* 1.4:3 Update Analytics on language selection */
try {
setTimeout(()=>{
lingoThreadLangSelected(lang, '1271494');
console.log("Language",lang);
},5000)
} catch (e) {
console.log(e);
}
/** Display Translated content **/
var getTranslation = lithiumPlugin.getTranslation(lang, "1271494");
getTranslation.then(function (trContent) {
if (trContent.body != "") {
$scope.showPreview(trContent.body, $scope.mszList, lang);
} else {
//$rootScope.errorMsg = "Translation is in progress. Please check again in a few minutes."
$rootScope.errorMsg = "Translation is in progress. Please retry in a few minutes."
}
});
};
var decodeEntities = (function() {
// this prevents any overhead from creating the object each time
var element = document.createElement('div');
function decodeHTMLEntities (str) {
if(str && typeof str === 'string') {
// strip script/html tags
str = str.replace(/