@Test public void givenMongoDbVarNameAdapterWhengetVariableNameThenReturnCorrect() throws InvalidParseOperationException { assertEquals(null, mongoVarNameAdapter.getVariableName("notValid")); assertEquals(MetadataDocument.ID, mongoVarNameAdapter.getVariableName("#id")); assertEquals(Unit.APPRAISALRULES, mongoVarNameAdapter.getVariableName("#dua")); assertEquals(Unit.NBCHILD, mongoVarNameAdapter.getVariableName("#nbunits")); assertEquals(MetadataDocument.TYPE, mongoVarNameAdapter.getVariableName("#type")); assertEquals(ObjectGroup.OBJECTSIZE, mongoVarNameAdapter.getVariableName("#size")); assertEquals(ObjectGroup.OBJECTFORMAT, mongoVarNameAdapter.getVariableName("#format")); assertEquals(MetadataDocument.QUALIFIERS, mongoVarNameAdapter.getVariableName("#qualifiers")); assertEquals(ObjectGroup.STORAGE, mongoVarNameAdapter.getVariableName("#storage")); }
@Override public String getVariableName(String name) throws InvalidParseOperationException { if (name.charAt(0) == ParserTokens.DEFAULT_HASH_PREFIX_CHAR) { int pos = name.indexOf('.'); final String realname; final String extension; if (pos > 1) { realname = name.substring(1, pos); extension = name.substring(pos); } else { realname = name.substring(1); extension = ""; } try { final PROJECTIONARGS proj = ParserTokens.PROJECTIONARGS.parse(realname); switch (proj) { case DUA: return Unit.APPRAISALRULES + extension; case FORMAT: return ObjectGroup.OBJECTFORMAT; case ID: return VitamDocument.ID; case QUALIFIERS: return MetadataDocument.QUALIFIERS + extension; case NBUNITS: return Unit.NBCHILD; case NBOBJECTS: return ObjectGroup.NBCHILD; case SIZE: return ObjectGroup.OBJECTSIZE; case TYPE: return MetadataDocument.TYPE; case TENANT: return VitamDocument.TENANT_ID; case OBJECT: return MetadataDocument.OG; case UNITUPS: return MetadataDocument.UP; case MIN: return Unit.MINDEPTH; case MAX: return Unit.MAXDEPTH; case ALLUNITUPS: return Unit.UNITUPS; case UNITTYPE: return Unit.UNIT_TYPE; case MANAGEMENT: return Unit.MANAGEMENT + extension; case OPERATIONS: return MetadataDocument.OPS; case OPI: return MetadataDocument.OPI; case ORIGINATING_AGENCY: return MetadataDocument.ORIGINATING_AGENCY; case ORIGINATING_AGENCIES: return MetadataDocument.ORIGINATING_AGENCIES; case VERSION: return MetadataDocument.VERSION; case ATOMIC_VERSION: return MetadataDocument.ATOMIC_VERSION; case STORAGE: return ObjectGroup.STORAGE + extension; case SCORE: return VitamDocument.SCORE; case UDS: return Unit.UNITDEPTHS; case GRAPH: return Unit.GRAPH; case ELIMINATION: return Unit.ELIMINATION + extension; case COMPUTEDINHERITEDRULES: return Unit.COMPUTED_INHERITED_RULES + extension; case VALIDCOMPUTEDINHERITEDRULES: return Unit.VALID_COMPUTED_INHERITED_RULES; case OPTS: return Unit.OPERATION_TRANSFERS; case GRAPH_LAST_PERISTED_DATE: return MetadataDocument.GRAPH_LAST_PERSISTED_DATE; case PARENT_ORIGINATING_AGENCIES: return Unit.PARENT_ORIGINATING_AGENCIES; case HISTORY: return Unit.HISTORY + extension; case SEDAVERSION: return VitamDocument.SEDAVERSION; case IMPLEMENTATIONVERSION: return VitamDocument.IMPLEMENTATIONVERSION; case ALL: default: break; } } catch (final IllegalArgumentException e) { throw new InvalidParseOperationException("Name: " + name, e); } } return null; }
MongoDbVarNameAdapter extends VarNameAdapter { @Override public String getVariableName(String name) throws InvalidParseOperationException { if (name.charAt(0) == ParserTokens.DEFAULT_HASH_PREFIX_CHAR) { int pos = name.indexOf('.'); final String realname; final String extension; if (pos > 1) { realname = name.substring(1, pos); extension = name.substring(pos); } else { realname = name.substring(1); extension = ""; } try { final PROJECTIONARGS proj = ParserTokens.PROJECTIONARGS.parse(realname); switch (proj) { case DUA: return Unit.APPRAISALRULES + extension; case FORMAT: return ObjectGroup.OBJECTFORMAT; case ID: return VitamDocument.ID; case QUALIFIERS: return MetadataDocument.QUALIFIERS + extension; case NBUNITS: return Unit.NBCHILD; case NBOBJECTS: return ObjectGroup.NBCHILD; case SIZE: return ObjectGroup.OBJECTSIZE; case TYPE: return MetadataDocument.TYPE; case TENANT: return VitamDocument.TENANT_ID; case OBJECT: return MetadataDocument.OG; case UNITUPS: return MetadataDocument.UP; case MIN: return Unit.MINDEPTH; case MAX: return Unit.MAXDEPTH; case ALLUNITUPS: return Unit.UNITUPS; case UNITTYPE: return Unit.UNIT_TYPE; case MANAGEMENT: return Unit.MANAGEMENT + extension; case OPERATIONS: return MetadataDocument.OPS; case OPI: return MetadataDocument.OPI; case ORIGINATING_AGENCY: return MetadataDocument.ORIGINATING_AGENCY; case ORIGINATING_AGENCIES: return MetadataDocument.ORIGINATING_AGENCIES; case VERSION: return MetadataDocument.VERSION; case ATOMIC_VERSION: return MetadataDocument.ATOMIC_VERSION; case STORAGE: return ObjectGroup.STORAGE + extension; case SCORE: return VitamDocument.SCORE; case UDS: return Unit.UNITDEPTHS; case GRAPH: return Unit.GRAPH; case ELIMINATION: return Unit.ELIMINATION + extension; case COMPUTEDINHERITEDRULES: return Unit.COMPUTED_INHERITED_RULES + extension; case VALIDCOMPUTEDINHERITEDRULES: return Unit.VALID_COMPUTED_INHERITED_RULES; case OPTS: return Unit.OPERATION_TRANSFERS; case GRAPH_LAST_PERISTED_DATE: return MetadataDocument.GRAPH_LAST_PERSISTED_DATE; case PARENT_ORIGINATING_AGENCIES: return Unit.PARENT_ORIGINATING_AGENCIES; case HISTORY: return Unit.HISTORY + extension; case SEDAVERSION: return VitamDocument.SEDAVERSION; case IMPLEMENTATIONVERSION: return VitamDocument.IMPLEMENTATIONVERSION; case ALL: default: break; } } catch (final IllegalArgumentException e) { throw new InvalidParseOperationException("Name: " + name, e); } } return null; } }
MongoDbVarNameAdapter extends VarNameAdapter { @Override public String getVariableName(String name) throws InvalidParseOperationException { if (name.charAt(0) == ParserTokens.DEFAULT_HASH_PREFIX_CHAR) { int pos = name.indexOf('.'); final String realname; final String extension; if (pos > 1) { realname = name.substring(1, pos); extension = name.substring(pos); } else { realname = name.substring(1); extension = ""; } try { final PROJECTIONARGS proj = ParserTokens.PROJECTIONARGS.parse(realname); switch (proj) { case DUA: return Unit.APPRAISALRULES + extension; case FORMAT: return ObjectGroup.OBJECTFORMAT; case ID: return VitamDocument.ID; case QUALIFIERS: return MetadataDocument.QUALIFIERS + extension; case NBUNITS: return Unit.NBCHILD; case NBOBJECTS: return ObjectGroup.NBCHILD; case SIZE: return ObjectGroup.OBJECTSIZE; case TYPE: return MetadataDocument.TYPE; case TENANT: return VitamDocument.TENANT_ID; case OBJECT: return MetadataDocument.OG; case UNITUPS: return MetadataDocument.UP; case MIN: return Unit.MINDEPTH; case MAX: return Unit.MAXDEPTH; case ALLUNITUPS: return Unit.UNITUPS; case UNITTYPE: return Unit.UNIT_TYPE; case MANAGEMENT: return Unit.MANAGEMENT + extension; case OPERATIONS: return MetadataDocument.OPS; case OPI: return MetadataDocument.OPI; case ORIGINATING_AGENCY: return MetadataDocument.ORIGINATING_AGENCY; case ORIGINATING_AGENCIES: return MetadataDocument.ORIGINATING_AGENCIES; case VERSION: return MetadataDocument.VERSION; case ATOMIC_VERSION: return MetadataDocument.ATOMIC_VERSION; case STORAGE: return ObjectGroup.STORAGE + extension; case SCORE: return VitamDocument.SCORE; case UDS: return Unit.UNITDEPTHS; case GRAPH: return Unit.GRAPH; case ELIMINATION: return Unit.ELIMINATION + extension; case COMPUTEDINHERITEDRULES: return Unit.COMPUTED_INHERITED_RULES + extension; case VALIDCOMPUTEDINHERITEDRULES: return Unit.VALID_COMPUTED_INHERITED_RULES; case OPTS: return Unit.OPERATION_TRANSFERS; case GRAPH_LAST_PERISTED_DATE: return MetadataDocument.GRAPH_LAST_PERSISTED_DATE; case PARENT_ORIGINATING_AGENCIES: return Unit.PARENT_ORIGINATING_AGENCIES; case HISTORY: return Unit.HISTORY + extension; case SEDAVERSION: return VitamDocument.SEDAVERSION; case IMPLEMENTATIONVERSION: return VitamDocument.IMPLEMENTATIONVERSION; case ALL: default: break; } } catch (final IllegalArgumentException e) { throw new InvalidParseOperationException("Name: " + name, e); } } return null; } MongoDbVarNameAdapter(); }
MongoDbVarNameAdapter extends VarNameAdapter { @Override public String getVariableName(String name) throws InvalidParseOperationException { if (name.charAt(0) == ParserTokens.DEFAULT_HASH_PREFIX_CHAR) { int pos = name.indexOf('.'); final String realname; final String extension; if (pos > 1) { realname = name.substring(1, pos); extension = name.substring(pos); } else { realname = name.substring(1); extension = ""; } try { final PROJECTIONARGS proj = ParserTokens.PROJECTIONARGS.parse(realname); switch (proj) { case DUA: return Unit.APPRAISALRULES + extension; case FORMAT: return ObjectGroup.OBJECTFORMAT; case ID: return VitamDocument.ID; case QUALIFIERS: return MetadataDocument.QUALIFIERS + extension; case NBUNITS: return Unit.NBCHILD; case NBOBJECTS: return ObjectGroup.NBCHILD; case SIZE: return ObjectGroup.OBJECTSIZE; case TYPE: return MetadataDocument.TYPE; case TENANT: return VitamDocument.TENANT_ID; case OBJECT: return MetadataDocument.OG; case UNITUPS: return MetadataDocument.UP; case MIN: return Unit.MINDEPTH; case MAX: return Unit.MAXDEPTH; case ALLUNITUPS: return Unit.UNITUPS; case UNITTYPE: return Unit.UNIT_TYPE; case MANAGEMENT: return Unit.MANAGEMENT + extension; case OPERATIONS: return MetadataDocument.OPS; case OPI: return MetadataDocument.OPI; case ORIGINATING_AGENCY: return MetadataDocument.ORIGINATING_AGENCY; case ORIGINATING_AGENCIES: return MetadataDocument.ORIGINATING_AGENCIES; case VERSION: return MetadataDocument.VERSION; case ATOMIC_VERSION: return MetadataDocument.ATOMIC_VERSION; case STORAGE: return ObjectGroup.STORAGE + extension; case SCORE: return VitamDocument.SCORE; case UDS: return Unit.UNITDEPTHS; case GRAPH: return Unit.GRAPH; case ELIMINATION: return Unit.ELIMINATION + extension; case COMPUTEDINHERITEDRULES: return Unit.COMPUTED_INHERITED_RULES + extension; case VALIDCOMPUTEDINHERITEDRULES: return Unit.VALID_COMPUTED_INHERITED_RULES; case OPTS: return Unit.OPERATION_TRANSFERS; case GRAPH_LAST_PERISTED_DATE: return MetadataDocument.GRAPH_LAST_PERSISTED_DATE; case PARENT_ORIGINATING_AGENCIES: return Unit.PARENT_ORIGINATING_AGENCIES; case HISTORY: return Unit.HISTORY + extension; case SEDAVERSION: return VitamDocument.SEDAVERSION; case IMPLEMENTATIONVERSION: return VitamDocument.IMPLEMENTATIONVERSION; case ALL: default: break; } } catch (final IllegalArgumentException e) { throw new InvalidParseOperationException("Name: " + name, e); } } return null; } MongoDbVarNameAdapter(); @Override boolean metadataAdapter(); @Override String getVariableName(String name); }
MongoDbVarNameAdapter extends VarNameAdapter { @Override public String getVariableName(String name) throws InvalidParseOperationException { if (name.charAt(0) == ParserTokens.DEFAULT_HASH_PREFIX_CHAR) { int pos = name.indexOf('.'); final String realname; final String extension; if (pos > 1) { realname = name.substring(1, pos); extension = name.substring(pos); } else { realname = name.substring(1); extension = ""; } try { final PROJECTIONARGS proj = ParserTokens.PROJECTIONARGS.parse(realname); switch (proj) { case DUA: return Unit.APPRAISALRULES + extension; case FORMAT: return ObjectGroup.OBJECTFORMAT; case ID: return VitamDocument.ID; case QUALIFIERS: return MetadataDocument.QUALIFIERS + extension; case NBUNITS: return Unit.NBCHILD; case NBOBJECTS: return ObjectGroup.NBCHILD; case SIZE: return ObjectGroup.OBJECTSIZE; case TYPE: return MetadataDocument.TYPE; case TENANT: return VitamDocument.TENANT_ID; case OBJECT: return MetadataDocument.OG; case UNITUPS: return MetadataDocument.UP; case MIN: return Unit.MINDEPTH; case MAX: return Unit.MAXDEPTH; case ALLUNITUPS: return Unit.UNITUPS; case UNITTYPE: return Unit.UNIT_TYPE; case MANAGEMENT: return Unit.MANAGEMENT + extension; case OPERATIONS: return MetadataDocument.OPS; case OPI: return MetadataDocument.OPI; case ORIGINATING_AGENCY: return MetadataDocument.ORIGINATING_AGENCY; case ORIGINATING_AGENCIES: return MetadataDocument.ORIGINATING_AGENCIES; case VERSION: return MetadataDocument.VERSION; case ATOMIC_VERSION: return MetadataDocument.ATOMIC_VERSION; case STORAGE: return ObjectGroup.STORAGE + extension; case SCORE: return VitamDocument.SCORE; case UDS: return Unit.UNITDEPTHS; case GRAPH: return Unit.GRAPH; case ELIMINATION: return Unit.ELIMINATION + extension; case COMPUTEDINHERITEDRULES: return Unit.COMPUTED_INHERITED_RULES + extension; case VALIDCOMPUTEDINHERITEDRULES: return Unit.VALID_COMPUTED_INHERITED_RULES; case OPTS: return Unit.OPERATION_TRANSFERS; case GRAPH_LAST_PERISTED_DATE: return MetadataDocument.GRAPH_LAST_PERSISTED_DATE; case PARENT_ORIGINATING_AGENCIES: return Unit.PARENT_ORIGINATING_AGENCIES; case HISTORY: return Unit.HISTORY + extension; case SEDAVERSION: return VitamDocument.SEDAVERSION; case IMPLEMENTATIONVERSION: return VitamDocument.IMPLEMENTATIONVERSION; case ALL: default: break; } } catch (final IllegalArgumentException e) { throw new InvalidParseOperationException("Name: " + name, e); } } return null; } MongoDbVarNameAdapter(); @Override boolean metadataAdapter(); @Override String getVariableName(String name);  }