= MetaModelService
:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

This service provides a formal API into the framework's metamodel.

== API

[source,java]
.MetaModelService.java
----
interface MetaModelService {
  Optional<LogicalType> lookupLogicalTypeByName(String logicalTypeName)     // <.>
  Optional<LogicalType> lookupLogicalTypeByClass(Class<?> domainType)     // <.>
  void rebuild(Class<?> domainType)     // <.>
  DomainModel getDomainModel()     // <.>
  BeanSort sortOf(Class<?> domainType, Mode mode)     // <.>
  BeanSort sortOf(Bookmark bookmark, Mode mode)     // <.>
  CommandDtoProcessor commandDtoProcessorFor(String logicalMemberIdentifier)     // <.>
  MetamodelDto exportMetaModel(Config config)     // <.>
  ObjectGraph exportObjectGraph(BiPredicate<BeanSort, LogicalType> filter)     // <.>
}
----

<.> xref:#lookupLogicalTypeByName_String[lookupLogicalTypeByName(String)]
+
--
Provides a lookup by logicalTypeName of a domain class' object type, corresponding to _Named#value()_ or _DomainService#aliased()_ or _DomainObject#aliased()_ . Will return an empty result if there is no such non-abstract class registered. (interfaces and abstract types are never added to the lookup table).
--
<.> xref:#lookupLogicalTypeByClass_Class[lookupLogicalTypeByClass(Class)]
+
--
Provides a lookup by class of a domain class' object type,corresponding to _Named#value()_ or _DomainService#aliased()_ or _DomainObject#aliased()_ .
--
<.> xref:#rebuild_Class[rebuild(Class)]
+
--
Invalidates and rebuilds the internal metadata for the specified domain type.
--
<.> xref:#getDomainModel_[getDomainModel()]
+
--
Returns a list of representations of each of member of each domain class.
--
<.> xref:#sortOf_Class_Mode[sortOf(Class, Mode)]
+
--
What sort of object the domain type represents.
--
<.> xref:#sortOf_Bookmark_Mode[sortOf(Bookmark, Mode)]
+
--
Override of _#sortOf(Class, Mode)_ , extracting the domain type from the provided xref:refguide:applib:index/services/bookmark/Bookmark.adoc[Bookmark] of a domain object instance.
--
<.> xref:#commandDtoProcessorFor_String[commandDtoProcessorFor(String)]
+
--
Obtains the implementation of xref:refguide:applib:index/services/commanddto/processor/CommandDtoProcessor.adoc[CommandDtoProcessor] (if any) as per _Action#commandDtoProcessor()_ or _Property#commandDtoProcessor()_ .
--
<.> xref:#exportMetaModel_Config[exportMetaModel(Config)]
+
--
Exports the entire metamodel as a DTO, serializable into XML using JAXB.
--
<.> xref:#exportObjectGraph_BiPredicate[exportObjectGraph(BiPredicate)]
+
--
Can be used to create object relation diagrams (e.g. Plantuml).
--

== Members

[#lookupLogicalTypeByName_String]
=== lookupLogicalTypeByName(String)

Provides a lookup by logicalTypeName of a domain class' object type, corresponding to _Named#value()_ or _DomainService#aliased()_ or _DomainObject#aliased()_ . Will return an empty result if there is no such non-abstract class registered. (interfaces and abstract types are never added to the lookup table).

[#lookupLogicalTypeByClass_Class]
=== lookupLogicalTypeByClass(Class)

Provides a lookup by class of a domain class' object type,corresponding to _Named#value()_ or _DomainService#aliased()_ or _DomainObject#aliased()_ .

[#rebuild_Class]
=== rebuild(Class)

Invalidates and rebuilds the internal metadata for the specified domain type.

[#getDomainModel_]
=== getDomainModel()

Returns a list of representations of each of member of each domain class.

Used by xref:refguide:applib:index/services/metamodel/MetaModelServiceMenu.adoc[MetaModelServiceMenu] to return a downloadable CSV.

Note that _MetaModelService#exportMetaModel(Config)_ provides a superset of the functionality provided by this method.

[#sortOf_Class_Mode]
=== sortOf(Class, Mode)

What sort of object the domain type represents.

[#sortOf_Bookmark_Mode]
=== sortOf(Bookmark, Mode)

Override of _#sortOf(Class, Mode)_ , extracting the domain type from the provided xref:refguide:applib:index/services/bookmark/Bookmark.adoc[Bookmark] of a domain object instance.

[#commandDtoProcessorFor_String]
=== commandDtoProcessorFor(String)

Obtains the implementation of xref:refguide:applib:index/services/commanddto/processor/CommandDtoProcessor.adoc[CommandDtoProcessor] (if any) as per _Action#commandDtoProcessor()_ or _Property#commandDtoProcessor()_ .

This is used by framework-provided implementations of _org.apache.causeway.applib.services.conmap.ContentMappingService_ .

[#exportMetaModel_Config]
=== exportMetaModel(Config)

Exports the entire metamodel as a DTO, serializable into XML using JAXB.

The xref:refguide:applib:index/services/metamodel/Config.adoc[Config] parameter can be used to restrict/filter the export to some subset of the metamodel; in particular to specific _Config#getNamespacePrefixes() namespace prefixes_ .

[#exportObjectGraph_BiPredicate]
=== exportObjectGraph(BiPredicate)

Can be used to create object relation diagrams (e.g. Plantuml).

include::hooks/MetaModelService_010-implementation.adoc[]

include::hooks/MetaModelService_020-examples-and-usage.adoc[]
