001 package de.deepamehta.core.impl; 002 003 import de.deepamehta.core.DeepaMehtaObject; 004 import de.deepamehta.core.AssociationType; 005 import de.deepamehta.core.JSONEnabled; 006 import de.deepamehta.core.model.AssociationTypeModel; 007 import de.deepamehta.core.service.Directive; 008 import de.deepamehta.core.service.Directives; 009 010 import java.util.List; 011 import java.util.logging.Logger; 012 013 014 015 /** 016 * An association type that is attached to the {@link DeepaMehtaService}. 017 */ 018 class AttachedAssociationType extends AttachedType implements AssociationType { 019 020 // ---------------------------------------------------------------------------------------------- Instance Variables 021 022 private Logger logger = Logger.getLogger(getClass().getName()); 023 024 // ---------------------------------------------------------------------------------------------------- Constructors 025 026 AttachedAssociationType(AssociationTypeModel model, EmbeddedService dms) { 027 super(model, dms); 028 } 029 030 // -------------------------------------------------------------------------------------------------- Public Methods 031 032 033 034 // ************************************** 035 // *** AssociationType Implementation *** 036 // ************************************** 037 038 039 040 @Override 041 public AssociationTypeModel getModel() { 042 return (AssociationTypeModel) super.getModel(); 043 } 044 045 @Override 046 public void update(AssociationTypeModel model) { 047 logger.info("Updating association type \"" + getUri() + "\" (new " + model + ")"); 048 // Note: the UPDATE_ASSOCIATION_TYPE directive must be added *before* a possible UPDATE_TOPIC directive (added 049 // by super.update()). In case of a changed type URI the webclient's type cache must be updated *before* 050 // the AssociationTypeRenderer can render the type. 051 Directives.get().add(Directive.UPDATE_ASSOCIATION_TYPE, this); 052 // 053 super.update(model); 054 } 055 056 // ----------------------------------------------------------------------------------------- Package Private Methods 057 058 059 060 // === AttachedTopic Overrides === 061 062 @Override 063 final String className() { 064 return "association type"; 065 } 066 067 068 069 // === Implementation of abstract AttachedType methods === 070 071 @Override 072 final void putInTypeCache() { 073 dms.typeCache.putAssociationType(this); 074 } 075 076 @Override 077 final void removeFromTypeCache() { 078 dms.typeCache.removeAssociationType(getUri()); 079 } 080 081 // --- 082 083 @Override 084 final Directive getDeleteTypeDirective() { 085 return Directive.DELETE_ASSOCIATION_TYPE; 086 } 087 088 @Override 089 final List<? extends DeepaMehtaObject> getAllInstances() { 090 return dms.getAssociations(getUri()).getItems(); 091 } 092 }