@Override public String getIdentifier() { return getId(); }
@Override public String[] getAbstract() { return new String[] { getDesc() }; }
private AliasedRIMType( String name, String alias ) { type = RIMType.valueOf( name ); this.alias = alias; }
RIMType type = null; try { type = RIMType.valueOf( rootEl.getLocalName() ); } catch ( Throwable t ) { throw new IllegalArgumentException( "Element '" + rootEl.getLocalName() return new AdhocQuery( rootEl ); case Association: return new Association( rootEl ); case Classification: return new Classification( rootEl ); case ClassificationNode: return new ClassificationNode( rootEl ); case ExtrinsicObject: return new ExtrinsicObject( rootEl ); case RegistryObject: return new RegistryObject( rootEl ); case RegistryPackage: return new RegistryPackage( rootEl ); default: LOG.warn( "Treating registry object '" + type + "' as generic registry object." ); return new RegistryObject( rootEl );
private void addRegistryObject( InsertRow ir, RegistryObject ro ) { ir.addPreparedArgument( new SQLIdentifier( "id" ), ro.getId() ); ir.addPreparedArgument( new SQLIdentifier( "objectType" ), ro.getObjectType() ); ir.addPreparedArgument( new SQLIdentifier( "home" ), ro.getHome() ); ir.addPreparedArgument( new SQLIdentifier( "lid" ), ro.getLid() ); ir.addPreparedArgument( new SQLIdentifier( "status" ), ro.getStatus() ); ir.addPreparedArgument( new SQLIdentifier( "externalId" ), ro.getExtId() ); ir.addPreparedArgument( new SQLIdentifier( "name" ), ro.getName() ); ir.addPreparedArgument( new SQLIdentifier( "description" ), ro.getDesc() ); ir.addPreparedArgument( new SQLIdentifier( "versionInfo" ), ro.getVersionInfo() ); }
private void insertAssociation( Association association, int regPackId, Connection conn ) throws SQLException { InsertRow ir = new InsertRow( new TableName( Table.idxtb_association.name() ), null ); addRegistryObject( ir, association ); ir.addPreparedArgument( new SQLIdentifier( "sourceObject" ), association.getSourceObject() ); ir.addPreparedArgument( new SQLIdentifier( "targetObject" ), association.getTargetObject() ); ir.addPreparedArgument( new SQLIdentifier( "associationType" ), association.getAssociationType() ); ir.addPreparedArgument( new SQLIdentifier( "data" ), getAsByteArray( association.getElement() ) ); ir.addPreparedArgument( new SQLIdentifier( "fk_registrypackage" ), regPackId ); ir.performInsert( conn ); }
private void insertClassification( Classification classification, int regPackId, Connection conn ) throws SQLException { InsertRow ir = new InsertRow( new TableName( Table.idxtb_classification.name() ), null ); addRegistryObject( ir, classification ); ir.addPreparedArgument( new SQLIdentifier( "classificationNode" ), classification.getClassificationNode() ); ir.addPreparedArgument( new SQLIdentifier( "classifiedObject" ), classification.getClassifiedObject() ); ir.addPreparedArgument( new SQLIdentifier( "classificationScheme" ), classification.getClassificationScheme() ); ir.addPreparedArgument( new SQLIdentifier( "data" ), getAsByteArray( classification.getElement() ) ); ir.addPreparedArgument( new SQLIdentifier( "fk_registrypackage" ), regPackId ); ir.performInsert( conn ); }
private void insertClassificationNode( ClassificationNode classificationNode, int regPackId, Connection conn ) throws SQLException { InsertRow ir = new InsertRow( new TableName( Table.idxtb_classificationNode.name() ), null ); addRegistryObject( ir, classificationNode ); ir.addPreparedArgument( new SQLIdentifier( "parent" ), classificationNode.getParent() ); ir.addPreparedArgument( new SQLIdentifier( "code" ), classificationNode.getCode() ); ir.addPreparedArgument( new SQLIdentifier( "path" ), classificationNode.getPath() ); ir.addPreparedArgument( new SQLIdentifier( "data" ), getAsByteArray( classificationNode.getElement() ) ); ir.addPreparedArgument( new SQLIdentifier( "fk_registrypackage" ), regPackId ); ir.performInsert( conn ); }
@Override public List<String> performInsert( InsertOperation insert ) throws MetadataStoreException, MetadataInspectorException { List<String> identifierList = new ArrayList<String>(); for ( MetadataRecord record : insert.getRecords() ) { if ( record != null ) { // TODO: suppor of other registryObjects RegistryPackage ebrimRecord = new RegistryPackage( record.getAsOMElement() ); // TODO: inspect records insert( ebrimRecord ); identifierList.add( ebrimRecord.getIdentifier() ); } } return identifierList; }
List<AliasedRIMType> returnTypes = AliasedRIMType.valueOf( returnTypeNames[0] ); if ( returnTypes.size() != 1 ) { String msg = "Selecting of multiple return types is not supported."; rt = aliasToType.get( returnType.getAlias() ); if ( rt == null ) { for ( AliasedRIMType candidate : aliasToType.values() ) { if ( candidate.getType() == returnType.getType() ) { LOG.warn( "Relying on imprecise match for return type." ); rt = candidate;
public List<ExtrinsicObject> getExtrinsicObjects( String type ) { if ( !extrinsicObjects.containsKey( type ) ) { List<ExtrinsicObject> eos = new ArrayList<ExtrinsicObject>(); List<OMElement> eoElems = adapter.getElements( adapter.getRootElement(), getEOPath( type ) ); for ( OMElement eoElem : eoElems ) { eos.add( new ExtrinsicObject( eoElem ) ); } extrinsicObjects.put( type, eos ); } return extrinsicObjects.get( type ); }
@Override public void serialize( XMLStreamWriter writer, ReturnableElement returnType ) throws XMLStreamException { switch ( returnType ) { case brief: serializeBrief( writer ); break; case summary: serializeSummary( writer ); break; case full: XMLStreamReader xmlStream = adapter.getRootElement().getXMLStreamReader(); XMLStreamUtils.skipStartDocument( xmlStream ); XMLAdapter.writeElement( writer, xmlStream ); break; default: throw new IllegalArgumentException( "Unexpected return type '" + returnType + "'." ); } }
public Table getTable( AliasedRIMType queryType ) { return aliasToTable.get( queryType.getAlias() ); }
@Override public String[] getTitle() { return new String[] { getROName() }; }
/** * Returns {@link AliasedRIMType}s for the given qualified name. * * @param name * qualified name of a {@link RIMType} with optional aliases, separated by underscores * @return aliased registry object types, never <code>null</code> and contains at least a single entry * @throws IllegalArgumentException * if the input name does not refer to a known {@link RIMType} */ public static List<AliasedRIMType> valueOf( QName name ) throws IllegalArgumentException { List<AliasedRIMType> values = null; String[] tokens = split( name.getLocalPart(), "_" ); if ( tokens.length > 1 ) { String unaliasedName = tokens [0]; values = new ArrayList<AliasedRIMType>( tokens.length - 1 ); for ( int i = 1; i < tokens.length; i++ ) { String alias = tokens[i]; values.add( new AliasedRIMType( unaliasedName, alias ) ); } } else { String unaliasedName = name.getLocalPart(); values = Collections.singletonList( new AliasedRIMType( unaliasedName, unaliasedName ) ); } return values; }
/** * @return the classifications */ public List<Classification> getClassifications() { if ( classifications == null ) { List<OMElement> classificationElems = adapter.getElements( adapter.getRootElement(), new XPath( "./rim:RegistryObjectList/rim:Classification", ns ) ); classifications = new ArrayList<Classification>(); for ( OMElement classificationElem : classificationElems ) { classifications.add( new Classification( classificationElem ) ); } } return classifications; }
/** * @return the associations */ public List<Association> getAssociations() { if ( associations == null ) { List<OMElement> associationElements = adapter.getElements( adapter.getRootElement(), new XPath( "./rim:RegistryObjectList/rim:Association", ns ) ); associations = new ArrayList<Association>(); for ( OMElement associationElem : associationElements ) { associations.add( new Association( associationElem ) ); } } return associations; }
/** * @return */ public List<ClassificationNode> getClassificationNodes() { if ( classificationNodes == null ) { // ALL classifictionNodes are parsed -> they can be childs of ClassificationNode or ClassificationScheme // (...) List<OMElement> classNodeElems = adapter.getElements( adapter.getRootElement(), new XPath( "./rim:RegistryObjectList//rim:ClassificationNode", ns ) ); classificationNodes = new ArrayList<ClassificationNode>(); for ( OMElement classNodeElem : classNodeElems ) { classificationNodes.add( new ClassificationNode( classNodeElem ) ); } } return classificationNodes; }
/** * Returns the {@link RIMType}. * * @return {@link RIMType}, never <code>null</code> */ public RIMType getRIMType() { return RIMType.valueOf( adapter.getRootElement().getLocalName() ); }
public String getTableAlias( AliasedRIMType queryType ) { return aliasToTableAlias.get( queryType.getAlias() ); }