@Override public void onSuccess(final EIInstance newInstance) { listener.onInstanceAdded( newInstance ); newInstance.addNonOntologyLiteralProperty( SweetUIConstants.isStubEntity, "True" ); if ( hasOldValue() ) { eiInstance.replaceObjectPropertyValue( propertyEntity, EIURI.create( oldValue ), newInstance.getEntity() ); } else { eiInstance.addObjectProperty( propertyEntity, newInstance.getEntity() ); } updateOldValue( newInstance.getInstanceURI() ); addStubWidget( range, propertyEntity, newInstance ); } } );
public EIExchangeInstance(EIInstance instance) { this.specificTypeUri = instance.getInstanceType().getURI(); this.instanceEntity = instance.getEntity(); this.rootType = instance.getRootSuperType().getEntity().getURI(); final Set<String> foreignKeys = instance.getNonOntologyLiteralProperty( EIDT.foreignKey.getEntity() ); if(!foreignKeys.isEmpty()) { this.foreignKey = foreignKeys.iterator().next(); } final Set<String> sources = instance.getNonOntologyLiteralProperty( EIDT.source.getEntity() ); if(!sources.isEmpty()) { this.source = sources.iterator().next(); } processTextProperties( instance.getDatatypeProperties()); }
private boolean checkLabels() { if ( isMissingLabel( eiInstance ) ) { return false; } for (final EIInstance inner : newInnerInstances) { if ( isMissingLabel( inner ) ) { return false; } } for (final EIInstance inner : eiInstance.getEmbeddedInstanceList()) { if ( isMissingLabel( inner ) && inner.getObjectProperties().isEmpty() && inner.getDatatypeProperties().isEmpty() && !inner.getInstanceClass().equals( inner.getRootSuperType() ) ) { return false; } } return true; }
/** * */ private void moveTermRequestsFromEmbeddedToMain() { if ( eiInstance.hasEmbeddedInstances() ) { for (EIInstance embedded : eiInstance.getEmbeddedInstanceList()) { Set<String> termRequests = embedded.getNonOntologyLiteralProperty( SweetUIConstants.termRequestEntity ); if ( termRequests!= null && !termRequests.isEmpty() ) { embedded.replaceNonOntologyLiteralPropertyAllValues( SweetUIConstants.termRequestEntity, null ); for (String termRequest : termRequests) { eiInstance.addNonOntologyLiteralProperty( SweetUIConstants.termRequestEntity, termRequest ); } } } } }
private EIInstanceMinimal(final EIInstance instance) { super( instance.getEntity() ); instanceType = instance.getInstanceType(); created = instance.getCreationDate(); modified = instance.getModificationDate(); // skip for now - we're not using it // this.otherEITypes; owner = isNull( instance.getWFOwner() ) ? EIEntity.NULL_ENTITY : instance.getWFOwner(); WFState = isNull( instance.getWFState() ) ? EIEntity.NULL_ENTITY : instance.getWFState(); }
private boolean isDuplicate(final EIInstance instance, final EIInstance otherInstance) { if ( instance == otherInstance || instance.getEntity().equals( otherInstance.getEntity() ) ) { return false; // not a duplicate of itself } // duplicate if type & label are identical return instance.getInstanceType().equals( otherInstance.getInstanceType() ) && instance.getInstanceLabel().equals( otherInstance.getInstanceLabel() ); }
public void addCellLine(final EIInstance cellLineInstance) { EIEntity cellLine = EIEntity.create( cellLineInstance.getInstanceURI(), cellLineInstance.getInstanceLabel() ); List<EIEntity> cellLineList = cellLineTypeToEntityMap.get( cellLineInstance.getInstanceType() ); if ( cellLineList == null ) { cellLineList = new ArrayList<EIEntity>(); cellLineTypeToEntityMap.put( cellLineInstance.getInstanceType(), cellLineList ); } cellLineList.add( cellLine ); }
@Override public void onSuccess(final EIInstance eiInstance) { if ( eiInstance != null && !EIInstance.NULL_INSTANCE.equals( eiInstance ) ) { final EIEntity providerEntity = ResourceProvider.getProperResourceProviderEntity( eiInstance ); ApplicationState.getInstance().updateApplicationState( Mode.view, eiInstance.getEntity(), eiInstance.getInstanceType(), providerEntity ); } } } );
final EIInstance linkedInstance = initializeInstance( linkedExchangeInstance, false, user ); EIEntity objPropEntity = EIEntity.create( entry.getKey(), "" ); if ( instanceFactory.isEmbeddedClass( linkedInstance.getInstanceType().getURI() ) ) { linkedInstance.setEmbedded( true ); primaryInstance.addEmbeddedInstance( objPropEntity, linkedInstance ); } else { final EIInstance pushedInstance = pushOneInstance( linkedInstance, linkedExchangeInstance.getForeignKey(), updateResponse, user ); final EIEntity newObjPropValue = pushedInstance.getEntity(); primaryInstance.replaceObjectPropertyValue( objPropEntity, oldObjPropValue, newObjPropValue );
/** * */ protected void clearEmbeddedInstance() { embeddedInstance.setInstanceLabel( "" ); embeddedInstance.setInstanceClass( embeddedInstance.getRootSuperType() ); embeddedInstance.getDatatypeProperties().clear(); embeddedInstance.getObjectProperties().clear(); listener.onInstanceRemoved( embeddedInstance ); for (final EIInstance inner : newInnerInstances) { listener.onInstanceRemoved( inner ); } }
@Override public boolean isAddedInstanceEntity(final EIEntity entity) { for (final EIInstance inner : newInnerInstances) { if ( inner.getEntity().equals( entity ) ) { return true; } } return false; }
private void deduplicate() { final List<EIInstance> ignore = new ArrayList<EIInstance>(); for (final EIInstance instance : newInnerInstances) { if ( ignore.contains( instance ) ) { continue; } for (final EIInstance otherInstance : newInnerInstances) { if ( ignore.contains( otherInstance ) ) { continue; } if ( isDuplicate( instance, otherInstance ) ) { final EIEntity property = eiInstance.findPropertyForInstance( otherInstance.getEntity() ); eiInstance.replaceObjectPropertyValue( property, otherInstance.getInstanceURI(), instance.getEntity() ); ignore.add( otherInstance ); } } } newInnerInstances.removeAll( ignore ); }
if(eiInstance.getInstanceURI().getId().contains( "http://global." )) { return null; contactButton.setStyleName( "contactButton" ); if ( eiInstance.getInstanceType().equals( FOAF.person.getEntity() ) ) { if ( eiInstance.getRootSuperType().getEntity().equals( FOAF.organization.getEntity() ) ) { if ( eiInstance.getMaterializedInverseProperties().isEmpty() ) { return null; if ( !eiInstance.isOfPrimaryType() ) { return null; if ( eiInstance.isOfTransferableType() ) { configureTributaryContactButton( EC_CONTACT_BUTTON_TEXT, contactButton ); } else {
addTypeProperty( labelPrefix ); addContactButton( ontologyPanel, eiInstance.getEntity() ); final Map<EIEntity, Set<String>> instanceDataTypeProperties = eiInstance.getDatatypeProperties(); final Map<EIEntity, Set<EIEntity>> instanceObjectProperties = eiInstance.getObjectProperties(); decorateSection( entry.getKey(), propertySectionPanel, eiInstance.getEntity() );
private boolean isNull(final EIInstance instance) { return instance == null || instance.getInstanceURI() == null || EIInstance.NULL_INSTANCE.equals( instance ); }
eiInstance.replaceObjectPropertyValue( propertyEntity, EIURI.create( oldValue ), WidgetUtils.getSelectedEntity( subClassList ) ); if(isPropertyProviderRelated) { final EIEntity providerEntity = getCorrectProviderEntity( WidgetUtils.getSelectedEntity( subClassList ).getURI()); eiInstance.replaceResourceProvider( EIURI.create( oldValue ), providerEntity ); ApplicationState.getInstance().updateFromEIInstance( providerEntity, eiInstance.getInstanceType() ); eiInstance.addObjectProperty( propertyEntity, WidgetUtils.getSelectedEntity( subClassList ) ); if(isPropertyProviderRelated) { eiInstance.addResourceProvider( getCorrectProviderEntity(WidgetUtils.getSelectedEntity( subClassList ).getURI()) );
private boolean needsCiteButton() { //globals can't be cited if(eiInstance.getInstanceURI().getId().contains( "http://global." )) { return false; } // Organizations will show a cite button, but only if // they have resources if ( eiInstance.getRootSuperType().getEntity().equals( FOAF.organization.getEntity() ) ) { if ( eiInstance.getMaterializedInverseProperties().isEmpty() ) { return false; } return true; } // The only non-primary types that will ever get a cite button are // organizations, which are dealt with above if ( !eiInstance.isOfPrimaryType() ) { return false; } //All primary types need a button return true; }
private int countProperties(final EIInstance basicInstance) { int propertyCount = 0; final Map<EIEntity, Set<String>> datatypeProps = basicInstance.getDatatypeProperties(); for (final EIEntity key : datatypeProps.keySet()) { propertyCount += datatypeProps.get( key ).size(); } final Map<EIEntity, Set<EIEntity>> objectProps = basicInstance.getObjectProperties(); for (final EIEntity key : objectProps.keySet()) { propertyCount += objectProps.get( key ).size(); } return propertyCount; }
private void setCorrectResourceProvider() { // Set the correct app state if ( isNewForm() ) { // is it a new org? then set it as provider if ( ResourceProvider.isResourceProviderType( eiInstance.getInstanceType() ) ) { ApplicationState.getInstance().setResourceProviderEntity( eiInstance.getEntity() ); } else if ( !eiInstance.getResourceProviders().isEmpty() ) { ApplicationState.getInstance().setResourceProviderEntity( eiInstance.getResourceProviders().get( 0 ) ); } else { // Will this happen? } } else { // for non providers, override app state with what we have in eiinstance if we do have // some if ( !ResourceProvider.isResourceProviderType( eiInstance.getInstanceType() ) && !eiInstance.getResourceProviders().isEmpty() ) { ApplicationState.getInstance().setResourceProviderEntity( eiInstance.getResourceProviders().get( 0 ) ); } } }
private void cancel() { if ( formType == EditFormType.New ) { if ( ApplicationState.getInstance().getMode() == Mode.duplicate ) { History.back(); } else if ( ResourceProvider.isResourceProviderType( eiInstance.getInstanceType() ) ) { ApplicationState.getInstance().updateApplicationState( Mode.workbench, EIEntity.NULL_ENTITY, EIEntity.NULL_ENTITY, EIEntity.NULL_ENTITY ); } else { final EIEntity typeEntity = eiInstance.getRootSuperType().getEntity(); ApplicationState.getInstance().updateApplicationState( Mode.list, EIEntity.NULL_ENTITY, typeEntity, ApplicationState.getInstance().getResourceProviderEntity() ); } } else { ClientSweetProxy.getInstance().getInstance( eiInstance.getInstanceURI(), new RootAsyncCallback<EIInstance>() { @Override public void onSuccess(final EIInstance fetched) { formRedisplayCallbacks.drawAfterCancel( fetched ); } @Override public void onFailure(final Throwable caught) { formRedisplayCallbacks.drawAfterCancel( eiInstance ); } } ); } }