Legacy deep-inheritance XML schemas: how to design patterns for APIs that map those to and from flat schemas?

Consider a purely hypothetical legacy proprietary library for XML models, which has some really deep nested inheritance within its corresponding POJOs — 1-10 fields per class, lots of special instance classes that extend archetypal classes, types as wrappers of lists of type instances etc. The resulting model looks really pretty with some dubious performance specs but that’s besides the point.

I want to make this work with the ugly, high-performance flat models that kids these days and people that claim not to have a drinking or substance abuse problem prefer for some reason. So say my beautiful, shiny model is something like this:

<QueryRequestSubtypeObject>   <QueryRequestHeaders>     <QueryReqParams>       <Param value = 4/>       <ParamDescWrapper index = 12>          <WrappedParamDesc>Foobar</WrappedParamDesc>   ... 

And the corresponding object as modeled by the vendor instead looks like

{    paramVal = 4    paramTypeIndex = 12    paramDesc = "Foobar"     } 

There are also regular updates to this ivory Tower of Babylon as well as updates to the business logic as vendor specs change.

Now the part where I convert my ancient classic into a teen flick is straightforward enough, however ugly it might be. Say something like below would be used by a query constructor and that would be enough abstraction for all business logic involved:

def extractParamVal(queryRequestSubtypeObject):     return queryRequestSubtypeObject.getQueryRequestHeaders.getQueryReqParams.getParam.getValue 

Alas, it is not that simple. Now I want to convert whatever ugly, flat, subsecond latency response that comes back into our elegant, delicate model (with 5-10 second latency, patience is a virtue after all!). With some code like this:

queryRequestSubtypeObject = new QueryRequestSubtypeObject queryRequestHeaders = new QueryRequestHeaders queryReqParams = new QueryReqParams queryReqParamList = new ArrayList param = new Param param.setValue(4) queryReqParamList.add(param) queryReqParams.setQueryReqParamList(queryReqParamList) queryRequestSubtypeObject.setQueryRequestHeaders(queryRequestHeaders) ... 

Code like this needs to be somewhere somehow for each and every field that is returned if someone were to convert data into this hypothetical format. Some solutions I have tried:

  • External libraries: Libraries like Dozer use reflections which does not scale well for bulk mapping massive objects like this. Mapstruct et al use code generation which does not do well with deep nesting involving cases like the list wrappers I mentioned.

  • Factory approach: Generic response factories that take a set of transformation functions. Idea is to bury all model specific implementation into business logic based abstractions. In reality this results in some FAT functions.

  • Chain of responsibility: Methods that handle initialization of each field and other methods that handle what goes where from vendor response and some other methods that handle creation of a portion of the mapping and some other methods that handle a sub-group… loooooong chains of responsibility

Given all of these approaches resulted in technical nightmares of some sort, is there an established way to handle cases like this specifically? Ideally it would have minimal non-business logic abstractions involved while providing enough granularity to implement updates and have it technically solid as well. Bonus points for the ability to isolate any given component, wherever it might be in the model hierarchy, without null pointers getting thrown somewhere for unit testing

Are schemas from Schema.org good for SEO or not?

I keep seeing people here saying in comments that SEO is no good for SEO, yet Google’s web developer’s guide does indicate that structured Schema data is best for SEO as

Google Search works hard to understand the content of a page. You can help us by providing explicit clues about the meaning of a page to Google by including structured data on the page.

Am I missing something?

Does pure MongoDB use schemas and models like Mongoose?

I’m new on pure MongoDB and I’ve some questions about pure MongoDB.

1. Does pure MongoDB use schemas and models like Mongoose ODM?

If you have used Mongoose ODM, you know that Mongoose ODM uses schemas and models for defining fields with their properties. Like this;

/* Dependencies */ const mongoose = require('mongoose');  /* Define the user schema */ const userSchema = new mongoose.Schema({   name: {     type: String,     required: true   },   lastname: {     type: String,     required: true   } });  /* Define the model */ const User = mongoose.model('User', userSchema); 

Do we need to define schemas and models with their fields?

2. Does pure MongoDB have any validators?

For example, If we have a field in schema; we can define some properties to fields like;

...   name: {     type: String,  // Type built-in validator     required: true // Required built-in validator   },   points: {     type: Number,  // Type built-in validator     min: 0,        // Min (minimum) built-in validator     max: 100       // Max (maximum) built-in validator   },   verified: {     type: Boolean, // Type built-in validator     validate: {    // Custom schema validator       validator: function(v) {         return this.points > 50;       },       message: 'You can not register!'     }   } ... 

Does pure MongoDB support for any validators or we define them while CRUD operations like this;

function createUser(userData, db, callback) {   if(userData.name && typeof(userData.name) == 'string' && userData.username && typeof(userData.lastname) == 'string') { // Validator for object     const collection = db.collection('users');     collection.insertOne({       name: userData.name,       lastname: userData.lastname     }, function(err, result) {       if(err) callback(err, null);       console.log('One record writed!');       callback(null, result);     });   } else {     callback(new Error('You must enter name and lastname to register!', null));   } } 

All my questions are about these. Thanks…

Oracle impdp onlu one schema when expdp its use many schemas

I have the following problem and doubt in Oracle … I am trying to import with impdp a save from my database made in which I export several schemes … the problem comes when I try to import into the same database in another scheme completely empty one and only one of those schemes that are in the export (expdp) …. during the import show several errors of creation, of sequences, of data that already exist and of creation of other objects in general. How is this possible if the scheme where I import this empty? the expdp I execute it in the following way:

To export: 

expdp \ "/ as sysdba \" DIRECTORY=logic_bakups DUMPFILE=backup%U.dmp FLASHBACK_TIME=timestamp PARALLEL=5 SCHEMAS=SCH1,SCH2,SCH3,SCH4

To import:

impdp \ "/ as sysdba \" DIRECTORY=imp_logic_backups DUMPFILE=backup%U.dmp PARALLEL=5 REMAP_SCHEMA=SCH3:SCH3_V2 REMAP_TABLESPACE=source_tablespace:target_tablespace_V2

Thank you

MYSQL server 8.0.13 does not show schemas previously created

First, I have a problem in accessing mySQL 8.0.13 using Workbench suddenly where the usual password is not accepted.

I then tried different ways to revive the connection; including using the following ways:

C:\Program Files (x86)\MySQL\mysql-8.0.13-winx64\bin>mysqld –initialize-insecure –console 2019-01-06T13:48:30.472661Z 0 [System] [MY-013169] [Server] C:\Program Files (x86)\MySQL\mysql-8.0.13-winx64\bin\mysqld.exe (mysqld 8.0.13) initializing of server in progress as process 7148 2019-01-06T13:48:30.526721Z 0 [ERROR] [MY-010457] [Server] –initialize specified but the data directory has files in it. Aborting. 2019-01-06T13:48:30.549741Z 0 [ERROR] [MY-013236] [Server] Newly created data directory C:\Program Files (x86)\MySQL\mysql-8.0.13-winx64\data\ is unusable. You can safely remove it. 2019-01-06T13:48:30.566754Z 0 [ERROR] [MY-010119] [Server] Aborting 2019-01-06T13:48:30.575948Z 0 [System] [MY-010910] [Server] C:\Program Files (x86)\MySQL\mysql-8.0.13-winx64\bin\mysqld.exe: Shutdown complete (mysqld 8.0.13) MySQL Community Server – GPL.

Now, even though I have no problem in connecting, the schema just will not show up.

What should I do ?

Another strange thing is that I have used the following :


when an error show up :

ERROR 1045 (28000): Access denied for user ‘ODBC’@’localhost’ (using password: NO)

which really stumped me cos I never created user ODBC. All along I am using root @ localhost

Another strange thing is when I log in using WorkBench, it shows me mysql@localhost and not root@localhost

Please help me out how to make MYSQL server work properly again.

OS : Windows 10