| 1 |
/* |
| 2 |
* Copyright (C) 2013-2015, 2019 by the Konclude Developer Team. |
| 3 |
* |
| 4 |
* This file is part of the reasoning system Konclude. |
| 5 |
* For details and support, see <http://konclude.com/>. |
| 6 |
* |
| 7 |
* Konclude is free software: you can redistribute it and/or modify |
| 8 |
* it under the terms of version 3 of the GNU Lesser General Public |
| 9 |
* License (LGPLv3) as published by the Free Software Foundation. |
| 10 |
* |
| 11 |
* Konclude is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU (Lesser) General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU (Lesser) General Public |
| 17 |
* License along with Konclude. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
* |
| 19 |
*/ |
| 20 |
|
| 21 |
#include "COWLLinkServerComandLinePreparationTranslator.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Control { |
| 27 |
|
| 28 |
namespace Interface { |
| 29 |
|
| 30 |
namespace CommandLine { |
| 31 |
|
| 32 |
|
| 33 |
COWLLinkServerComandLinePreparationTranslator::COWLLinkServerComandLinePreparationTranslator(CLoaderFactory *loaderFactory) : CCommandLinePreparationTranslator(loaderFactory) { |
| 34 |
mInterfaceTypeString = QString("OWLlink"); |
| 35 |
mMinNecessaryArguments = true; |
| 36 |
mFirstArgumentTranslation = false; |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
COWLLinkServerComandLinePreparationTranslator::~COWLLinkServerComandLinePreparationTranslator() { |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
bool COWLLinkServerComandLinePreparationTranslator::translate(const QString& argumentText, QStringList& remainingArgList) { |
| 45 |
|
| 46 |
bool argumentTranslated = false; |
| 47 |
|
| 48 |
|
| 49 |
QString modArgText = argumentText.trimmed(); |
| 50 |
if (!mSkipTranslation) { |
| 51 |
if (CCommandLinePreparationTranslator::translate(argumentText,remainingArgList)) { |
| 52 |
argumentTranslated = true; |
| 53 |
} else { |
| 54 |
if (modArgText.indexOf("-") == 0) { |
| 55 |
while (modArgText.startsWith("-")) { |
| 56 |
modArgText.remove(0,1); |
| 57 |
modArgText = modArgText.trimmed(); |
| 58 |
} |
| 59 |
|
| 60 |
if (modArgText.indexOf("p") == 0 || modArgText.indexOf("P") == 0) { |
| 61 |
argumentTranslated = true; |
| 62 |
QString portVal = ""; |
| 63 |
if (remainingArgList.count() > 0) { |
| 64 |
portVal = remainingArgList.takeFirst(); |
| 65 |
} |
| 66 |
mRequestConfList.append(QString("+Konclude.OWLlink.Server.Port=%2").arg(portVal.trimmed())); |
| 67 |
|
| 68 |
} |
| 69 |
|
| 70 |
} else if (modArgText == "owllinkserver" || modArgText == "server") { |
| 71 |
argumentTranslated = true; |
| 72 |
mFirstArgumentTranslation = true; |
| 73 |
} |
| 74 |
} |
| 75 |
} |
| 76 |
return argumentTranslated; |
| 77 |
} |
| 78 |
|
| 79 |
bool COWLLinkServerComandLinePreparationTranslator::canTranslate(const QString& string) { |
| 80 |
if (QString::compare(string,"owllinkserver",Qt::CaseInsensitive) == 0 || QString::compare(string,"server",Qt::CaseInsensitive) == 0) { |
| 81 |
return true; |
| 82 |
} |
| 83 |
return false; |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
QStringList COWLLinkServerComandLinePreparationTranslator::combineTranslatedArguments() { |
| 88 |
QStringList translatedArgList; |
| 89 |
|
| 90 |
if (!mFirstArgumentTranslation) { |
| 91 |
mMinNecessaryArguments = false; |
| 92 |
} |
| 93 |
|
| 94 |
if (!mMinNecessaryArguments) { |
| 95 |
LOG(ERROR,getLogDomain(),logTr("Execution with inadequate command line arguments."),this); |
| 96 |
mHelpRequested = true; |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
if (!mHelpRequested) { |
| 101 |
if (mLogConfList.isEmpty()) { |
| 102 |
mLogConfList.append(QString("-ConfigurableCoutLogObserverLoader -LoggerConfigurationLoader")); |
| 103 |
} |
| 104 |
translatedArgList += mLogConfList; |
| 105 |
translatedArgList += mGeneralConfList; |
| 106 |
|
| 107 |
translatedArgList += QString("-DefaultReasonerLoader "); |
| 108 |
translatedArgList += mReasonerConfList; |
| 109 |
translatedArgList += mGeneralConfList; |
| 110 |
|
| 111 |
if (!mConfigConfList.isEmpty()) { |
| 112 |
translatedArgList += QString("-%1BatchFileLoader +=Konclude.%1.CloseAfterProcessedRequest=false +=Konclude.%1.BlockUntilProcessedRequest=true").arg(mInterfaceTypeString); |
| 113 |
translatedArgList += mConfigConfList; |
| 114 |
} |
| 115 |
|
| 116 |
translatedArgList += QString("-OWLlinkHttpServerLoader"); |
| 117 |
translatedArgList += mRequestConfList; |
| 118 |
|
| 119 |
translatedArgList += mMiscellaneousList; |
| 120 |
} else { |
| 121 |
translatedArgList += QString("-ConfigurableCoutLogObserverLoader -CommandLineTranlatorHelpLoader"); |
| 122 |
} |
| 123 |
return translatedArgList; |
| 124 |
} |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
}; // end namespace CommandLine |
| 131 |
|
| 132 |
}; // end namespace Interface |
| 133 |
|
| 134 |
}; // end namespace Control |
| 135 |
|
| 136 |
}; // end namespace Konclude |