The content you are looking for has been archived. View related content below.
The Community has a new sign in method! Instead of using a password, sign in with the verification code emailed to you from My JMP. Learn more
Practice JMP using these webinar videos and resources. We hold live Mastering JMP Zoom webinars with Q&A most Fridays at 2 pm US Eastern Time.See the list and register. Local-language live Zoom webinars occur in the UK, Western Europe and Asia. See your country jmp.com/mastering site.
Created:
May 2, 2022 02:12 PM
| Last Modified: Oct 24, 2023 03:20 PM
Repairable Systems Simulation - Auto.jsl
20230428 - Mastering Reliability for Repairable Systems.jrn
See how to:
Understand the kinds of problems addressed by reliability tools for repairable systems
Problems where a product (or process) breaks and will be fixed
Problems where we are Interested in how often something breaks or how much will we spend (over period of time or product life) to fix it
Understand types of analysies people might try to use for repairable systems (like comuputer board failures)
Life Distribution ilooks at time between repairs, but his could overestimate the failure rate of the computer late in life by measuring time to fail of the boards, not of the computer.
Use Recurrence Analysis to understand systems that are repaired and placed back into service.
Examine mean time between failures for serial failures, to examine mean time between failures or whether one system is more reliable than another (eg., car engine repairs)
Uses mean Cumulative Failure curve to give info on the System repair rate.
Understand that time between failures can be misleading if failures are not stable around the man
Analyze recurring problems, like a disease (e.g. tumors) reoccurring after patient treatments for the disease
Use Reliability Growth to understand how reliability changes over time on a single repairable system, perhaps as improvements are incorporated into its design, and whether changes made improve reliability
Determine if changes made actually improve reliability
Use model options Crow AMSAA, Crow AMSAA with Modified MLE, Fixed Parameter Crow AMSAA, Piecewise Weibull NHPP, Reinitialized Weibull NHPP and Piecewise Weibull NHPP Change Point Detection
Understand the types of problems addressed by Reliability Forecast
Major, month-to-month changes in a product's reliability
Portion of my production expected to fail within the first x months of its life
Time monthly warranty claims will peak
Cumulative cost of warranty claims for a product
Can a repair team keep up with returns or if more staff are needed
Build reliability flow using Reliability Block Diagrams (JMP Pro) using Analyze/Reliability&Survival/Reliability Block Diagrams
See an example of the final product
Model and interpret Repairable Systems Simulation (JMP Pro)
Build your model using Analyze/Reliability&Survival/Repairable Systems Simulation
See an example of the final product
Reliability Growth
Reliability Forecast
Questions answered by Don McCormack @DonMcCormack and Jerry fish @JerryFish at the live webinar or previous live webinars on this topic.
Q: Can you use $ amounts in the Cost column?
A: Yes, A cost for the event (the cost of the repair, replacement, or adjustment). When costs are specified, the MCF is a mean cumulative cost per unit as a function of age and the markers in the Event Plot are sized by the cost values. Note: Cost indicators for Recurrence Analysis are the reverse of censor indicators seen in Life Distribution or Survival Analysis. For the cost variable, the value of 1 indicates an event, such as repair; the value of 0 indicates that the unit is no longer in service. For the censor variable, the value of 1 indicates censored values, and the value of 0 indicates the event or failure of the unit (non-censored value).
Q: Are reliability measures typically done at the product or individual part level?
A: It could be either. Often, you need the component measures to get to the system level.
Q: Are reliabliity measures typically done at the product or individual part level?
A: It could be either. Often, you need the component measures to get to the system level.
Q: Would these techniques be applicable to repairable systems that are in a standby condition?
A: It depends on what the most reasonable measure of usage is. In some cases, an idle state would not be considered part of usage. Some situations, it may be considered in use.
Q: How do you reconsile the difference between noon-repairable analysis component based and ‘system’ repair analysis?
A: The component life times would be modeled using the techniques we talked about for Non-Repairable Systems (e.g., Life Distribution). To get at the system reliability from the components, you could use a tool like the Reliability Block Diagram (JMP Pro).
Q: Can recurrance analysis be expressed as Discrete Time Survival analysis? The "censor" variable would be treated as dependent variable in DTS. Does JMP have DTS capability/feature?
A: Not sure what you mean by DTS. In the sense that censored data is grouped for the purpose of modeing the cumulative distribution (e.g., interval censoring) it may be considered discrete.
Q: Can we calculate/plot the rate of occurrence of failures within the recurrence platform?
A: We have been showing the non-parametric approach. There is also the option of using a parametric model in Recurrance.
Q: Would these techniques be applicable to repairable systems that are in a standby condition (not functioning) but are expected to function when needed?
A: Ultimately it gets down to what the most reasonable measure of usage is. In some cases, an idle state would not be considered part of usage. In other situations, it may be considered in use.
Q: How do you reconcile the difference between non-repairable analysis ‘component-based’ and ‘system’ repair analysis?
A: The component lifetimes would be modeled using the techniques we talked about last week (e.g., Life Distribution). To get at the system reliability from the components, you could use a tool like the Reliability Block Diagram (JMP Pro).
Q: Re: Using Life Distribution, if we assume that this is the only failure mode of the system, should Life Distribution and Recurrence Analysis methods be the same?
A: Non repairable systems only fail once and have a time span starting at 0. In repairable system reliability, you more than likely need to consider the previous failure time, since the probably of failing (the next time) will be a function of how long the system has been operating.
Q: Will you please review the details on the Reliability Growth example?
Q: Can we calculate/plot the rate of occurrence of failures within the recurrence platform?
A: Yes. Jerry has been showing the non-parametric approach. There is also the option of using a parametric model in Recurrence Analysis.
Q: Can I use Recurrence Analysis for a group of components that are repairable, but not in a system, e.g., a traction motor on multiple trains or a coolant pump in a power plant?
A: Yes. Assuming that they are from the same population.
Q: Are the failures the same type for the Reliability Growth example or just any failure?
A: Any failure.
Q: If there are delayed fixes or fixes which are planned in next version (Improved or final) how can I accommodate those in Reliability Growth?
A: The phases in Reliability Growth assume that some change was made making the entity in the previous phase different than the one in the current phase.
Q: Can Reliability Forecast be done for repairable devices?
A: It is more often used for non-repairable devices. However, it can be used when you assume the failure is either the first failure of the system or that after the system is repaired, it is repaired as good as new. Typically, the distributions and assumptions are different for non-repairable and repairable devices. In his example, Jerry did include cost of repair of first failure.
A Comparison of Maximum Likelihood and Median-Rank Regression for Weibull Estimation, Quality Engineering,Ulrike Genschel & William Q. Meeker (2010) 22:4, 236-255.
this question came up during the session. If you don't have the 3 fails for Weibull on the repairable systems platform, how would you proceed? Also, are other fail distributions available for the repairable system distributions (i.e., lognormal/degradation)? Russ, @russ_r_mcdonald Don McCormak @DonMcCormack said he would look into this with our developer team @peng_liu to see if Wei-Bayes is available for repairable systems.
In JMP, the following platforms are related to repairable systems: (1) Recurrence Analysis, (2) Reliability Growth, (3) Repairable Systems Simulation.
I guess that we are talking about (1) and (2).
In this context, we use the word "process" not distribution. So both platforms can model a so-called Weibull Process, a.k.a. Power Law NHPP (Recurrence Analysis calls it Power NHPP).
The number of failures in the data may pose challenges to analysis. In Reliability Growth, if the platform complains about "cannot start", lack of data might be a reason.
There are no other "distributions", but other "processes". In Recurrence Analyses, there are 4 processes: Fit Model in Recurrence Analysis. In Reliability Growth, there is Crow-AMSAA (aka Weibull Process, aka Power Law NHPP) and its variations.
Recommended Articles
'
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 = "This post originally written in lilicon-trans-text has been computer translated for you. When you reply, it will also be translated back to lilicon-trans-text.".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!";
}
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/lingoTrFlag.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 .lia-quilt-row:nth-child(3)").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.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) {
}
}
/* $( "div.message-uid-"+value ).find( "div.lia-message-body-content" ).append(body_L); */
} 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 2.0:2 = Reply Sync button for multi source translation */
} catch(e){console.log(e)}
};
if ((rContent != undefined) && (rContent != "")) {
drawCanvas(decodeURIComponent(rContent));
$window.connectorStatus.prop = "completed";
/** 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) {
/* 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 ((trContent.status != "NA") && trContent.status != null) {
// $scope.transPercent = String(trContent.status);
$scope.actualStatus = String(trContent.status);
} else {
$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 = "Downloading Translated content. Please refresh after some time.";
});
} 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."
});
} else if ("many" == "one") {
$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;
}
}).catch(function (error) {
console.error("Manage translation Error:"+error);
});
}
}
/**
* @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 {
lingoThreadLangSelected(lang, '483465');
} catch (e) {
}
/* var obj = $filter('filter')($scope.sourceLangList, function (obj) {return obj.code === lang});
if(obj.length > 0) {
if((anonymousFlag == undefined) && ("" != obj[0].id)) {
$window.location.href = "?profile.language="+obj[0].id;
return "";
}
} */
/** Display Translated content **/
var getTranslation = lithiumPlugin.getTranslation(lang, "483465");
getTranslation.then(function (trContent) {
if (trContent.body != "") {
$scope.showPreview(trContent.body, $scope.mszList, lang);
} else {
$rootScope.errorMsg = "Translation is in progress. Please retry in a few minutes."
}
});
};
/**
* @function openWorkbench
* @description Opens the workbench link of the selected code
*
*/
$scope.openWorkbench = function (wbLink) {
/* Open workbench link in new tab */
$window.open(decodeURIComponent(wbLink), '_blank');
};
/**
* @function detectBrowserLanguage
* @description detects the browser language and displays the UI to request translation for browser language
*
*/
$scope.detectBrowserLanguage = function () {
/* Get cookie value of the user choice regarding browser language translation */
var brTChoice = cookieService.getBrTChoice()
if (brTChoice != undefined && brTChoice == "true") {
/* Do nothing if user dont want option for browser language translation */
} else {
/* Get user browser language */
var brLangCode = window.navigator.userLanguage || window.navigator.language;
brLang = "";
/* Get right language code of the browser language. Get the first value in the matching list */
if (brLangCode.indexOf("-") >= 0) {
var obj = $filter('filter')($scope.languages, function (obj) {
return obj.code === brLangCode
});
if (obj.length > 0) {
brLang = obj[0];
}
} else {
var obj = $filter('filter')($scope.languages, function (obj) {
return obj.code.split("-")[0] === brLangCode
});
if (obj.length > 0) {
brLang = obj[0];
}
}
/* If browser language is valid one then provide UI to request browser language translation */
if (brLang != "") {
var defaultLang = "";
if (('en-US'.indexOf(brLang.code) == -1) && (brLang.code.indexOf('en-US') == -1) && (defaultLang.indexOf(brLang.code) == -1) && (brLang.code.indexOf(defaultLang) == -1)) {
$scope.brLang = brLang;
$scope.brTransMsg = "brTransMsg.html";
} else {
$scope.brTransMsg = "";
}
}
}
}
/**
* @function neverDisplayBrTransMsg
* @description sets cookie if user never want browser language translation choice
*
*/
$scope.neverDisplayBrTransMsg = function () {
cookieService.putBrTChoice()
$scope.brTransMsg = "";
}
/**
* @function trnaslateToBrowserLang
* @param {isTranslate} isTranslate - true/false
* @description Requests for browser translation based on user choice
*
*/
$scope.trnaslateToBrowserLang = function (isTranslate) {
if (isTranslate) {
/* Point language dropdown to browser language */
$scope.selLang = $scope.brLang.code;
/* Initiate preview process for browser language */
$scope.selectThisLang($scope.selLang);
/* Remove browser language translation UI */
$scope.brTransMsg = "";
} else {
$scope.brTransMsg = "";
}
}
/* V1.4 */
/**
* @function translateThisThread
* @description Triggers the translation on button click
* @param {mode} manual click or auto - click/null
*/
$scope.translateThisThread = function (mode) {
if (mode != undefined && mode == 'click') {
/* Cheking author decision on validation */
if ((document.querySelectorAll(".lingo-TrFlag").length == 0) && ("8239" != "-1")) {
if (!confirm("This thread is not selected for translation by the Author. Do you want to translate this thread?")) {
return false;
}
}
}
$scope.showTransLation = true;
/* If language exists in selected languages then initiate or manage translation */
if ("false" == "true") {
$scope.selLang = "";
/* 1.4 Update Analytics on language selected */
try {
lingoThreadLangSelected('', '483465');
} catch (e) {
}
if (angular.element(document.querySelector("#trABody"))) {
console.log(angular.element(document.querySelector("trABody")));
$scope.showPreview(angular.element(document.querySelector("#trABody")).innerHTML, $scope.mszList, "");
}
$scope.manageTranslation("", "483465");
} else {
if ("false" == "true") {
alert("Requested languages not present in the selected languages list");
}
}
/* Detecting Browser language */
$scope.detectBrowserLanguage();
}
$rootScope.profLang = "";
/* If language exists in selected languages then initiate or manage translation */
/* Get Cookie */
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
var lang_code = "";
if ("false" == "true") { /* Language from Parameter */
var lang_code = "";
} else if (anonLang = getCookie('lia.anon.profile.language')) { /* Language from cookie */
/* Get code from source list */
var srObj = $filter('filter')($scope.sourceLangList, function (obj) {
return obj.id === anonLang
});
if (srObj.length > 0) {
/* check code in selected languages */
var selObj = $filter('filter')($scope.languages, function (obj) {
return obj.code === srObj[0].code
});
if (selObj.length > 0) {
lang_code = srObj[0].code;
}
}
} else if (brLangCode = window.navigator.userLanguage || window.navigator.language) { /* Browser Language */
/* Get right language code of the browser language. Get the first value in the matching list */
if (brLangCode.indexOf("-") >= 0) {
var obj = $filter('filter')($scope.languages, function (obj) {
return obj.code === brLangCode
});
if (obj.length > 0) {
lang_code = obj[0].code;
}
} else {
var obj = $filter('filter')($scope.languages, function (obj) {
return obj.code.split("-")[0] === brLangCode
});
if (obj.length > 0) {
lang_code = obj[0].code;
}
}
} else {
}
$rootScope.profLang = lang_code;
if (lang_code == "") {
lang_code = "en-US";
}
$scope.selLang = lang_code;
if (angular.element(document.querySelector("#trABody"))) {
console.log(angular.element(document.querySelector("#trABody")).innerHTML);
$scope.showPreview(angular.element(document.querySelector("#trABody")).innerHTML, $scope.mszList, $scope.selLang);
}
$scope.showTransLation = true;
$scope.selectThisLang($scope.selLang, "1");
if ("true" == "true") {
try {
lingoThreadLangSelected($scope.selLang, '483465');
} catch (e) {
}
$scope.manageTranslation($scope.selLang, "483465");
}
/* V1.4 Loading dashbaord (converted into script to remove glitch) */
$scope.dashboard = "dashboard.html";
/**
* @function triggerRefresh
* @description Managess the translation of given language for the thread
* @param {string} langCode - Language Code
* @param {string} tid - Thread ID
*/
$scope.triggerRefresh = function (langCode, tid) {
if (confirm("Are you sure you want to manually resubmit the translation?")) {
$scope.transPercent = "";
var manualTriggerTrans = lithiumPlugin.manualTriggerTrans(langCode, tid);
manualTriggerTrans.then(function (status) {
if (status == "refresh") {
var resetTranslation = lithiumPlugin.resetTranslation(tid);
resetTranslation.then(function (error) {
if (error) {
$rootScope.errorMsg = error.$;
} else {
var bulkTranslation = lithiumPlugin.bulkTranslation(langCode, tid);
bulkTranslation.then(function (data) {
$rootScope.errorMsg = "Translation has been refreshed. Please refresh page after some time.";
});
}
});
} else {
$rootScope.errorMsg = status;
}
});
}
}
/* V 2.0: 2 = this function called on click reply sync button */
/**
* @function manualOOS
* @description Sends the Out of sync check request.
*
*/
$scope.manualTriggerOSS = function (replyID) {
if ($scope.transPercent != "") {
var manualOSS = lithiumPlugin.manualOSS("483465", replyID);
manualOSS.then(function (value) {
if (!value.includes("false")) {
$scope.transPercent = "";
$rootScope.errorMsg = "Message requested for re-translation. Please refresh the page in a few minutes.";
} else {
$rootScope.errorMsg = "Auto translation of message failed. Please refresh the page and retry.";
}
});
} else {
$rootScope.errorMsg = "Translation is in progress. Please retry in a few minutes.";
}
}
})
.factory('httpInterceptor', ['$q', '$rootScope',
function ($q, $rootScope) { /* httpInterceptor intercepts the http calls */
return {
request: function (config) {
if (config.url.indexOf("lingotek") >= 0) {
/* Start Loader */
$rootScope.isLoading = true;
$rootScope.errorMsg = "";
}
return config || $q.when(config);
},
requestError: function (request) {
if ((request.config != undefined) && (request.config.url.indexOf("lingotek") >= 0)) {
/* Stop Loader */
$rootScope.isLoading = false;
/* Display error message */
$rootScope.errorMsg = "Error while processing the request. Please refresh the page and retry.";
}
return $q.reject(request);
},
response: function (response) {
if (response.config.url.indexOf("lingotek") >= 0) {
/* Stop Loader */
$rootScope.isLoading = false;
}
return response || $q.when(response);
},
responseError: function (response) {
if ((response.config != undefined) && (response.config.url.indexOf("lingotek") >= 0)) {
/* Display error message */
$rootScope.errorMsg = "Error while processing the request. Please refresh the page and retry.";
/* Stop Loader */
$rootScope.isLoading = false;
}
return $q.reject(response);
}
};
}
])
.service('lithiumPlugin', function ($http, $rootScope) { /* Service that connects the dashboard with Lithium endpoints */
/* V 2.0:7 = Converting all POST calls GET calls */
/**
* @function isOutOfSync
* @param {string} sourceID - Thread id
* @description Sends the ot of sync check request
*
*/
var isOutOfSync = function (sourceID) {
return $http.get('/plugins/custom/sasinstitute/sasinstitute2/lingotek_ep_proj_callback?mode=OSS&tid=' + sourceID + '&xslt=json.xsl').then(function (result) {
var apiResponse = result.data;
return apiResponse.result;
},
function (result) {
// debugger;
return {"status": "false"};
});
};
/**
* @function getTrContent
* @param {string} code - Language code
* @param {string} tid - Thread id
* @description Get the translated content from Lithium.
*
*/
var getTranslation = function (code, tid) {
/* var param = {
mode:'trContent',
code:code,
tid:tid,
xslt:'json.xsl'
}; */
return $http.get('/plugins/custom/sasinstitute/sasinstitute2/lingotek_ep_rest_connector?mode=trContent&code=' + code + '&tid=' + tid + '&xslt=json.xsl').then(function (result) {
var apiResponse = result.data;
return apiResponse.result;
}, function (response) {
return {
"id": "",
"body": "",
"subject": "",
"status": "",
"wb": ""
};
});
};
/**
* @function bulkTransStatus
* @param {string} code - Language code
* @param {string} tid - Thread id
* @description Manages translation of given thread
*
*/
var bulkTranslation = function (code, tid) {
/* V1.1: 2*/
/* var param = {
mode:'manageTrContent',
code:code,
tid:tid,
xslt:'json.xsl'
}; */
return $http.get('/plugins/custom/sasinstitute/sasinstitute2/lingotek_ep_rest_connector?mode=manageTrContent&code=' + code + '&tid=' + tid + '&xslt=json.xsl').then(function (result) {
var apiResponse = result.data;
/* V1.4:3 GA code, capturing thread info on post */
if (apiResponse.result.posts != undefined) {
var trPosts = JSON.parse(apiResponse.result.posts);
angular.forEach(trPosts, function (pObj_l) {
try {
lingoUpdateSource(pObj_l.source, pObj_l.tid);
}
catch (error) {
console.log(error);
}
})
}
return apiResponse.result;
}, function (response) {
return {
"id": "",
"body": "",
"status": "",
"wb": ""
};
});
};
/**
* @function setDefaultLang
* @param {string} code - Language code
* @description Changes the user default language to requested language.
*
*/
var setDefaultLang = function (code) {
/* V1.1: 2*/
return $http.get("/plugins/custom/sasinstitute/sasinstitute2/lingotek_ep_settings?mode=langSet&xslt=json.xsl&code=" + code).then(function (result) {
debugger;
return result.data.result.value;
},
function (result) {
return "Error. Please retry in a few minutes";
});
};
/* V 2.0: 1 */
/**
* @function resetTranslation
* @param {string} tid - Thread ID
* @description Calls the endpoint to reset the translation of given thread.
*
*/
var resetTranslation = function (tid) {
return $http.get('/plugins/custom/sasinstitute/sasinstitute2/lingotek_support?mode=refresh&tid=' + tid + '&xslt=json.xsl').then(function (result) {
var apiResponse = result.data;
return apiResponse.logs.error;
},
function (result) {
return "";
});
};
/**
* @function manualTriggerTrans
* @param {string} code - Language code
* @param {string} tid - Thread id
* @description Manages translation of given thread
*
*/
var manualTriggerTrans = function (code, tid) {
/* V 2.0: 3*/
/* var param = {
mode:'mtrigger',
code:code,
tid:tid,
xslt:'json.xsl'
}; */
return $http.get('/plugins/custom/sasinstitute/sasinstitute2/lingotek_ep_proj_callback?mode=mtrigger&code=' + code + '&tid=' + tid + '&xslt=json.xsl').then(function (result) {
var apiResponse = result.data;
return apiResponse.result.status;
}, function (response) {
return "Please retry in a few minutes.";
});
};
/** @function isOutOfSync
* @param {string} sourceID - Thread id
* @description Sends the ot of sync check request
*
*/
var manualOSS = function (sourceID, replyID) {
return $http.get('/plugins/custom/sasinstitute/sasinstitute2/lingotek_ep_proj_callback?mode=manualOSS&tid=' + sourceID + '&reply=' + replyID + '&xslt=json.xsl').then(function (result) {
var apiResponse = result.data;
return apiResponse.result.status;
},
function (result) {
// debugger;
return "false";
});
};
/* V 2.0: 3 */
/**
* @function trCompletCallback
* @param {string} code - Language code
* @param {string} docID - Document id
* @description Triggers the translation completed callback from Lithium
*
*/
var trCompletCallback = function (code, docID) {
return $http.get('/plugins/custom/sasinstitute/sasinstitute2/lingotek_ep_proj_callback?mode=callback&type=target&progress=100&document_id=' + docID + '&locale_code=' + code + '&xslt=json.xsl').then(function (result) {
var apiResponse = result.data;
return apiResponse.result.status;
}, function (response) {
return "Please retry in a few minutes.";
});
};
/* V 2.0: 3 */
/**
* @function trCompletUpload
* @param {string} code - Language code
* @param {string} docID - Document id
* @description Triggers the document upload callback from Lithium
*
*/
var trCompletUpload = function (code, docID) {
return $http.get('/plugins/custom/sasinstitute/sasinstitute2/lingotek_ep_proj_callback?mode=callback&type=document_uploaded_auto&progress=0&document_id=' + docID + '&xslt=json.xsl').then(function (result) {
var apiResponse = result.data;
return apiResponse.result.status;
}, function (response) {
return "Please retry in a few minutes.";
});
};
return {
isOutOfSync: isOutOfSync,
getTranslation: getTranslation,
bulkTranslation: bulkTranslation,
setDefaultLang: setDefaultLang,
resetTranslation: resetTranslation,
manualTriggerTrans: manualTriggerTrans,
manualOSS: manualOSS,
trCompletCallback: trCompletCallback,
trCompletUpload: trCompletUpload
};
})
.service("cookieService", function () { /* Service for cookie storage */
/**
* @function getBrTChoice
* @description Returns the cookie set for browser language translation.
*
*/
var getBrTChoice = function () {
var cname = "it_lang_notify_hide";
var name = cname + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1);
if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
}
return "";
}
/**
* @function getBrTChoice
* @description Sets the cookie for browser language translation.
*
*/
var putBrTChoice = function () {
var cname = "it_lang_notify_hide";
var exdays = 30;
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + "true" + "; " + expires;
}
return {
getBrTChoice: getBrTChoice,
putBrTChoice: putBrTChoice
}
});
})(LITHIUM.angular);
// -->