Skip to content

Commit 5128782

Browse files
committed
Merge branch 'maeisabelle-219-FixLoadDataBugs'
2 parents 6db9add + 4bfa3c5 commit 5128782

File tree

7 files changed

+68
-31
lines changed

7 files changed

+68
-31
lines changed

quick-start/src/main/java/com/marklogic/hub/config/EnvironmentConfiguration.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.io.IOException;
1010
import java.io.InputStream;
1111
import java.io.OutputStream;
12+
import java.nio.file.Paths;
1213
import java.util.Properties;
1314

1415
import org.slf4j.Logger;
@@ -263,7 +264,8 @@ public String getFlowMlcpOptionsFromFile(String entityName, String flowName) thr
263264
if(file.exists()) {
264265
return Files.toString(file, Charsets.UTF_8);
265266
}
266-
return "{}";
267+
String currentDirectory = Paths.get("").toAbsolutePath().toString();
268+
return "{ \"input_file_path\": \"" + currentDirectory + "\" }";
267269
}
268270

269271
public HubConfig getHubConfig() {

quick-start/src/main/resources/static/app/mlcp/mlcp.controller.js

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
hideFileTree: hideFileTree,
2121
isText: isText,
2222
dataForTheTree: [],
23-
groups: mlcpGroups.groups(entityName, flowName),
23+
groups: mlcpGroups.groups(entityName, flowName, mlcpOptions),
2424
treeOptions: {
2525
nodeChildren: 'children',
2626
dirSelectable: false,
@@ -34,7 +34,9 @@
3434
}, mlcpOptions);
3535

3636
function ok() {
37-
$uibModalInstance.close($scope.mlcp);
37+
if($scope.mlcp.input_file_path) {
38+
$uibModalInstance.close($scope.mlcp);
39+
}
3840
}
3941

4042
function cancel() {
@@ -71,7 +73,8 @@
7173
function isGroupVisible(category) {
7274
if(category === 'Delimited Text Options' && $scope.mlcp.input_file_type !== 'delimited_text') {
7375
return false;
74-
} else if(category === 'Aggregate XML Options' && $scope.mlcp.input_file_type !== 'aggregates') {
76+
}
77+
else if(category === 'Aggregate XML Options' && $scope.mlcp.input_file_type !== 'aggregates') {
7578
return false;
7679
}
7780
return true;
@@ -109,24 +112,18 @@
109112

110113
function buildMlcpOptions() {
111114
var options = [];
112-
options.push('import');
113-
options.push('-mode');
114-
options.push('local');
115-
options.push('-host');
116-
options.push(DataHub.status.mlHost);
117-
options.push('-port');
118-
options.push(DataHub.status.mlStagingPort);
119-
options.push('-username');
120-
options.push(DataHub.status.mlUsername);
121-
options.push('-password');
122-
options.push(DataHub.status.mlPassword);
123-
124-
options.push('-input_file_path');
125-
options.push($scope.mlcp.input_file_path);
126-
options.push('-input_file_type');
127-
options.push($scope.mlcp.input_file_type);
128-
options.push('-output_uri_replace');
129-
options.push('"' + $scope.mlcp.input_file_path + ',\'\'"');
115+
var inputFilePath = $scope.mlcp.input_file_path;
116+
var input_file_type = $scope.mlcp.input_file_type;
117+
$scope.mlcp = {};
118+
addMlcpOption(options, 'import', null, false);
119+
addMlcpOption(options, 'mode', 'local', false);
120+
addMlcpOption(options, 'host', DataHub.status.mlHost, false);
121+
addMlcpOption(options, 'port', DataHub.status.mlStagingPort, false);
122+
addMlcpOption(options, 'username', DataHub.status.mlUsername, false);
123+
addMlcpOption(options, 'password', DataHub.status.mlPassword, false);
124+
addMlcpOption(options, 'input_file_path', inputFilePath, true);
125+
addMlcpOption(options, 'input_file_type', input_file_type, true);
126+
addMlcpOption(options, 'output_uri_replace', '"' + inputFilePath + ',\'\'"', true);
130127

131128
angular.forEach(self.groups, function(group) {
132129
if (isGroupVisible(group.category)) {
@@ -137,15 +134,24 @@
137134
if (setting.type !== 'boolean') {
138135
value = '"' + setting.value + '"';
139136
}
140-
options.push('-' + key);
141-
options.push(value);
137+
addMlcpOption(options, key, value, true);
142138
}
143139
});
144140
}
145141
});
146142
return options;
147143
}
148144

145+
function addMlcpOption(options, key, value, isOtherOption) {
146+
options.push('-' + key);
147+
if(value) {
148+
options.push(value);
149+
if(isOtherOption) {
150+
$scope.mlcp[key] = value;
151+
}
152+
}
153+
}
154+
149155
function updateMlcpCommand() {
150156
var mlcpCommand = 'mlcp';
151157
mlcpCommand += (navigator.appVersion.indexOf('Win') !== -1) ? '.bat' : '.sh';
@@ -157,7 +163,9 @@
157163
}
158164

159165
$scope.$watch('mlcp.input_file_path', function(value) {
160-
searchPath(value);
166+
if(value) {
167+
searchPath(value);
168+
}
161169
});
162170

163171
$scope.$watch('mlcp', function(value) {

quick-start/src/main/resources/static/app/mlcp/mlcp.groups.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
function MlcpGroupsFactory() {
1010
return {
11-
groups: function(entityName, flowName) {
12-
return [
11+
groups: function(entityName, flowName, previousOptions) {
12+
var groups = [
1313
{
1414
category: 'General Options',
1515
settings: [
@@ -237,6 +237,16 @@
237237
]
238238
}
239239
];
240+
angular.forEach(previousOptions, function(value, key) {
241+
angular.forEach(groups, function(group) {
242+
angular.forEach(group.settings, function(setting) {
243+
if (setting.field === key) {
244+
setting.value = value.replace(/"/g, '');
245+
}
246+
});
247+
});
248+
});
249+
return groups;
240250
}
241251
};
242252
}

quick-start/src/main/resources/static/app/mlcp/mlcp.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
44
<h4 class="modal-title" id="myModalLabel">Load Data</h4>
55
</div>
6-
<div class="modal-body" id="myModalBody">
6+
<div class="modal-body" id="myModalBody" ng-cloak>
77
<div class="row">
88
<div id="details" class="col-xs-12 col-md-12">
9-
<form ng-submit="ctrl.ok()">
10-
<div class="form-group">
9+
<form name="loadDataForm" ng-submit="ctrl.ok()">
10+
<div class="form-group" ng-class="{ 'has-error' : !loadDataForm.ifp.$valid }">
1111
<label for="ifp" popover-trigger="mouseenter" uib-popover="The location of a folder containing the files you wish to load.">Location of Files to Load</label>
1212
<input id="ifp" class="form-control" name="ifp" type="text" ng-model="mlcp.input_file_path"
13-
placeHolder="Enter Path" required="required" ng-focus="showInputPathTreeBrowser = true">
13+
placeHolder="Enter Path (required)" required="required" ng-focus="showInputPathTreeBrowser = true">
1414
<div id="inputPathTreeBrowser" class="panel panel-primary tree-scroller-cust1" ng-show="showInputPathTreeBrowser">
1515
<div class="panel-body">
1616
<treecontrol class="tree-classic" tree-model="ctrl.dataForTheTree"

quick-start/src/main/resources/static/app/quickStartApp.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
'ngAnimate',
1616
'ui.bootstrap',
1717
'angular-confirm',
18+
'ngSanitize',
1819
'swaggerUi',
1920
'mlcp'
2021
];

quick-start/src/main/resources/static/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<script src="lib/angular.js/js/angular-animate.min.js"></script>
1717
<script src="lib/angular.js/js/ui-bootstrap-tpls-1.2.4.js"></script>
1818
<script src="lib/angular.js/js/angular-aria.min.js"></script>
19+
<script src="lib/angular.js/js/angular-sanitize.min.js"></script>
1920

2021
<!-- tree control -->
2122
<script type="text/javascript" src="lib/angular-tree-control/angular-tree-control.js"></script>

quick-start/src/main/resources/static/lib/angular.js/js/angular-sanitize.min.js

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)