Skip to content

Commit 6d9264b

Browse files
Merge remote-tracking branch 'upstream/master'
2 parents 25555aa + 47242f8 commit 6d9264b

8 files changed

Lines changed: 217 additions & 197 deletions

File tree

.classpath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<attributes>
1616
<attribute name="optional" value="true"/>
1717
<attribute name="maven.pomderived" value="true"/>
18+
<attribute name="test" value="true"/>
1819
</attributes>
1920
</classpathentry>
2021
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
eclipse.preferences.version=1
22
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
33
org.eclipse.jdt.core.compiler.compliance=1.5
4+
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
45
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
6+
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
7+
org.eclipse.jdt.core.compiler.release=disabled
58
org.eclipse.jdt.core.compiler.source=1.5

bimserverapipromise.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default class BimServerApiPromise {
1+
export class BimServerApiPromise {
22
constructor(counter = null) {
33
this.isDone = false;
44
this.chains = [];

bimserverapiwebsocket.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default class BimServerApiWebSocket {
1+
export class BimServerApiWebSocket {
22
constructor(baseUrl, bimServerApi) {
33
this.connected = false;
44
this.openCallbacks = [];

bimserverclient.js

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import BimServerApiPromise from './bimserverapipromise.js';
2-
import BimServerApiWebSocket from './bimserverapiwebsocket.js';
1+
import {BimServerApiPromise} from './bimserverapipromise.js';
2+
import {BimServerApiWebSocket} from './bimserverapiwebsocket.js';
33
import {geometry} from './geometry.js';
44
import {ifc2x3tc1} from './ifc2x3tc1.js';
55
import {ifc4} from './ifc4.js';
6-
import Model from './model.js';
6+
import {Model} from './model.js';
77
import {translations} from './translations_en.js';
88

9-
export { default as BimServerApiPromise } from './bimserverapipromise.js';
10-
export { default as BimServerApiWebSocket } from './bimserverapiwebsocket.js';
11-
export { default as Model } from './model.js';
9+
//export { default as BimServerApiPromise } from './bimserverapipromise.js';
10+
//export { default as BimServerApiWebSocket } from './bimserverapiwebsocket.js';
11+
//export { default as Model } from './model.js';
1212

13-
//import XMLHttpRequest from 'xhr2';
13+
//import {XMLHttpRequest from 'xhr2';
1414

1515
// Where does this come frome? The API crashes on the absence of this
1616
// member function?
1717
String.prototype.firstUpper = function () {
1818
return this.charAt(0).toUpperCase() + this.slice(1);
1919
};
2020

21-
export default class BimServerClient {
21+
export class BimServerClient {
2222
constructor(baseUrl, notifier = null, translate = null) {
2323
this.interfaceMapping = {
2424
"ServiceInterface": "org.bimserver.ServiceInterface",
@@ -62,9 +62,9 @@ export default class BimServerClient {
6262
clear: function () {}
6363
};
6464
}
65-
65+
6666
// ID -> Resolve method
67-
this.websocketCalls = new Map();
67+
this.websocketCalls = new Map();
6868

6969
// The websocket client
7070
this.webSocket = new BimServerApiWebSocket(baseUrl, this);
@@ -75,7 +75,7 @@ export default class BimServerClient {
7575

7676
// Keeps track of the unique ID's required to handle websocket calls that return something
7777
this.idCounter = 0;
78-
78+
7979
this.listeners = {};
8080

8181
// this.autoLoginTried = false;
@@ -101,21 +101,21 @@ export default class BimServerClient {
101101
this.call("AdminInterface", "getServerInfo", {}, (serverInfo) => {
102102
this.version = serverInfo.version;
103103
//const versionString = this.version.major + "." + this.version.minor + "." + this.version.revision;
104-
104+
105105
this.schemas.geometry = geometry.classes;
106106
this.addSubtypesToSchema(this.schemas.geometry);
107-
107+
108108
this.schemas.ifc2x3tc1 = ifc2x3tc1.classes;
109109
this.addSubtypesToSchema(this.schemas.ifc2x3tc1);
110-
110+
111111
this.schemas.ifc4 = ifc4.classes;
112112
this.addSubtypesToSchema(this.schemas.ifc4);
113113

114114
if (callback != null) {
115115
callback(this, serverInfo);
116116
}
117117
resolve(serverInfo);
118-
});
118+
}, (error) => { reject(error); });
119119
});
120120
return promise;
121121
}
@@ -199,7 +199,7 @@ export default class BimServerClient {
199199
clearBinaryDataListener(topicId) {
200200
delete this.binaryDataListener[topicId];
201201
}
202-
202+
203203
processNotification(message) {
204204
if (message instanceof ArrayBuffer) {
205205
if (message == null || message.byteLength == 0) {
@@ -211,7 +211,7 @@ export default class BimServerClient {
211211
if (listener != null) {
212212
listener(message);
213213
} else {
214-
console.error("No listener for topicId", topicId);
214+
console.error("No listener for topicId", topicId, message);
215215
}
216216
} else {
217217
const intf = message["interface"];
@@ -274,6 +274,12 @@ export default class BimServerClient {
274274
});
275275
}
276276

277+
getMinimalJsonStreamingSerializer(callback) {
278+
this.getSerializerByPluginClassName("org.bimserver.serializers.MinimalJsonStreamingSerializerPlugin").then((serializer) => {
279+
callback(serializer);
280+
});
281+
}
282+
277283
getSerializerByPluginClassName(pluginClassName) {
278284
if (this.serializersByPluginClassName[pluginClassName] != null) {
279285
return this.serializersByPluginClassName[pluginClassName];
@@ -287,7 +293,7 @@ export default class BimServerClient {
287293
});
288294

289295
this.serializersByPluginClassName[pluginClassName] = promise;
290-
296+
291297
return promise;
292298
}
293299
}
@@ -313,9 +319,9 @@ export default class BimServerClient {
313319
this.listeners[interfaceName] = {};
314320
}
315321
if (this.listeners[interfaceName][methodName] == null) {
316-
this.listeners[interfaceName][methodName] = [];
322+
this.listeners[interfaceName][methodName] = new Set();
317323
}
318-
this.listeners[interfaceName][methodName].push(callback);
324+
this.listeners[interfaceName][methodName].add(callback);
319325
if (registerCallback != null) {
320326
registerCallback();
321327
}
@@ -464,6 +470,8 @@ export default class BimServerClient {
464470
if (callback != null) {
465471
callback();
466472
}
473+
}, () => {
474+
// Discard
467475
});
468476
}
469477
}
@@ -477,6 +485,8 @@ export default class BimServerClient {
477485
if (callback != null) {
478486
callback();
479487
}
488+
}, () => {
489+
// Discard
480490
});
481491
}
482492

@@ -719,11 +729,11 @@ export default class BimServerClient {
719729
}
720730
this.notifier.setError(this.translate("ERROR_REMOTE_METHOD_CALL"));
721731
}
722-
if (callback != null) {
732+
if (errorCallback != null) {
723733
const result = {};
724734
result.error = textStatus;
725735
result.ok = false;
726-
callback(result);
736+
errorCallback(result);
727737
}
728738
promise.fire();
729739
});
@@ -868,6 +878,7 @@ export default class BimServerClient {
868878
}, false);
869879
xhr.open("POST", this.baseUrl + "/upload");
870880
if (typeof data == "File") {
881+
var file = data;
871882
reader.onload = () => {
872883
const formData = new FormData();
873884
formData.append("action", "file");
@@ -902,7 +913,7 @@ export default class BimServerClient {
902913
}
903914
}, true, false, true, false);
904915
}
905-
916+
906917
callWithWebsocket(interfaceName, methodName, data) {
907918
var promise = new Promise((resolve, reject) => {
908919
var id = this.idCounter++;
@@ -935,7 +946,7 @@ export default class BimServerClient {
935946
* @param {boolean} showBusy - Whether to show busy indication
936947
* @param {boolean} showDone - Whether to show done indication
937948
* @param {boolean} showError - Whether to show errors
938-
*
949+
*
939950
*/
940951
call(interfaceName, methodName, data, callback, errorCallback, showBusy = true, showDone = false, showError = true, connectWebSocket = true) {
941952
return this.multiCall([

model.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import BimServerApiPromise from "./bimserverapipromise.js";
1+
import {BimServerApiPromise} from "./bimserverapipromise.js";
22

3-
export default class Model {
3+
export class Model {
44
constructor(bimServerApi, poid, roid, schema) {
55
this.schema = schema;
66
this.bimServerApi = bimServerApi;
@@ -677,7 +677,7 @@ export default class Model {
677677
if (typeof subQuery.type === "object") {
678678
fullTypesLoading[subQuery.type.name] = true;
679679
this.loadedTypes[subQuery.type.name] = {};
680-
if (subQuery.type.includeAllSubtypes) {
680+
if (subQuery.type.includeAllSubTypes) {
681681
const schema = this.bimServerApi.schemas[this.schema];
682682
this.bimServerApi.getAllSubTypes(schema, subQuery.type.name, (subTypeName) => {
683683
fullTypesLoading[subTypeName] = true;
@@ -687,7 +687,7 @@ export default class Model {
687687
} else {
688688
fullTypesLoading[subQuery.type] = true;
689689
this.loadedTypes[subQuery.type] = {};
690-
if (subQuery.includeAllSubtypes) {
690+
if (subQuery.includeAllSubTypes) {
691691
const schema = this.bimServerApi.schemas[this.schema];
692692
this.bimServerApi.getAllSubTypes(schema, subQuery.type, (subTypeName) => {
693693
fullTypesLoading[subTypeName] = true;

0 commit comments

Comments
 (0)