Gets the metamodel.

@param persistenceUnit
the persistence unit
@return the metamodel
162641
public Metamodel getMetamodel(String persistenceUnit)
    {
        Map<String, Metamodel> model = getMetamodelMap();
        return persistenceUnit != null && model.containsKey(persistenceUnit) ? model.get(persistenceUnit) : null;
    }
1253526
public function getPersistenceBuilder() : PersistenceBuilder
    {
        if (! $this->persistenceBuilder) {
            $this->persistenceBuilder = new PersistenceBuilder($this->dm, $this);
        }
        return $this->persistenceBuilder;
    }
1119899
protected <T> ManagedObjectFactory<T> getInterceptorManagedObjectFactory(BeanMetaData bmd, Class<T> klass) throws EJBConfigurationException {
        ManagedObjectFactory<T> factory = null;
        ManagedObjectService managedObjectService = getManagedObjectService();
        if (managedObjectService != null) {
            try {
                factory = managedObjectService.createInterceptorManagedObjectFactory(bmd._moduleMetaData, klass);
                //TODO the isManaged method could be moved to the ManagedObjectService and then wouldn't need to create the factory
                if (!factory.isManaged()) {
                    factory = null;
                }
            } catch (ManagedObjectException e) {
                throw new EJBConfigurationException(e);
            }
        }

        return factory;
    }
636960
public static MetamodelImpl getMetamodel(final KunderaMetadata kunderaMetadata, String... persistenceUnits)
    {
        MetamodelImpl metamodel = null;
        for (String pu : persistenceUnits)
        {
            metamodel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(pu);

            if (metamodel != null)
            {
                return metamodel;
            }
        }

        // FIXME: I need to verify this why we need common entity metadata now!
        // if (metamodel == null)
        // {
        // metamodel = (MetamodelImpl)
        // kunderaMetadata.getApplicationMetadata().getMetamodel(
        // Constants.COMMON_ENTITY_METADATAS);
        // }
        return metamodel;
    }
87711
private EntityMetadata getMetadata(Class<?> clazz)
    {
        EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, clazz);
        if (metadata == null)
        {
            log.error("Entity metadata not found for {}, possible reasons may be: "
                    + "1) not annotated with @Entity. 2) is annotated with @MappedSuperclass."
                    + "3) does not properly with mapped persistence unit for persistence unit and keyspace. Please verify with @Table annotation or persistence.xml "
                    + clazz);
            throw new KunderaException("Entity metadata not found for " + clazz.getName());
        }
        return metadata;
    }
1179018
private static PersistenceUnit newPersistenceUnit(final String fJndiName, final String fUnitName)
    {
        return new PersistenceUnit()
        {
            @Override
            public String name()
            {
                return fJndiName;
            }

            @Override
            public Class<? extends Annotation> annotationType()
            {
                return javax.persistence.PersistenceUnit.class;
            }

            @Override
            public String unitName()
            {
                return fUnitName;
            }

            @Override
            public String toString()
            {
                return "JPA.PersistenceUnit(name=" + fJndiName +
                       ", unitName=" + fUnitName + ")";
            }
        };
    }
1075089
public List<PersistenceUnit<Persistence<T>>> getAllPersistenceUnit()
   {
      List<PersistenceUnit<Persistence<T>>> list = new ArrayList<PersistenceUnit<Persistence<T>>>();
      List<Node> nodeList = childNode.get("persistence-unit");
      for(Node node: nodeList)
      {
         PersistenceUnit<Persistence<T>>  type = new PersistenceUnitImpl<Persistence<T>>(this, "persistence-unit", childNode, node);
         list.add(type);
      }
      return list;
   }
42438
private static List<FieldSchema> getFieldSchemas(HiveRegistrationUnit unit) {
    List<Column> columns = unit.getColumns();
    List<FieldSchema> fieldSchemas = new ArrayList<>();
    if (columns != null && columns.size() > 0) {
      fieldSchemas = getFieldSchemas(columns);
    } else {
      Deserializer deserializer = getDeserializer(unit);
      if (deserializer != null) {
        try {
          fieldSchemas = MetaStoreUtils.getFieldsFromDeserializer(unit.getTableName(), deserializer);
        } catch (SerDeException | MetaException e) {
          LOG.warn("Encountered exception while getting fields from deserializer.", e);
        }
      }
    }
    return fieldSchemas;
  }
327956
private static ClientFactory instantiateClientFactory(String persistenceUnit, Map<String, Object> puProperties,
            final KunderaMetadata kunderaMetadata)
    {
        ClientFactory clientFactory = null;
        logger.info("Initializing client factory for: " + persistenceUnit);
        PersistenceUnitMetadata persistenceUnitMetadata = kunderaMetadata.getApplicationMetadata()
                .getPersistenceUnitMetadata(persistenceUnit);
        String kunderaClientFactory = puProperties != null ? (String) puProperties
                .get(PersistenceProperties.KUNDERA_CLIENT_FACTORY) : null;
        if (kunderaClientFactory == null)
        {
            kunderaClientFactory = persistenceUnitMetadata.getProperties().getProperty(
                    PersistenceProperties.KUNDERA_CLIENT_FACTORY);
        }

        if (kunderaClientFactory == null)
        {
            throw new ClientResolverException(
                    "<kundera.client.lookup.class> is missing from persistence.xml, please provide specific client factory. e.g., <property name=\"kundera.client.lookup.class\" value=\"com.impetus.client.cassandra.pelops.PelopsClientFactory\" />");
        }
        try
        {
            clientFactory = (ClientFactory) Class.forName(kunderaClientFactory).newInstance();

            Method m = GenericClientFactory.class.getDeclaredMethod("setPersistenceUnit", String.class);
            if (!m.isAccessible())
            {
                m.setAccessible(true);
            }

            m.invoke(clientFactory, persistenceUnit);

            m = GenericClientFactory.class.getDeclaredMethod("setExternalProperties", Map.class);
            if (!m.isAccessible())
            {
                m.setAccessible(true);
            }

            m.invoke(clientFactory, puProperties);
            
            m = GenericClientFactory.class.getDeclaredMethod("setKunderaMetadata", KunderaMetadata.class);
            if (!m.isAccessible())
            {
                m.setAccessible(true);
            }

            m.invoke(clientFactory, kunderaMetadata);
            
        }
        catch (InstantiationException e)
        {
            onError(e);
        }
        catch (IllegalAccessException e)
        {
            onError(e);
        }
        catch (ClassNotFoundException e)
        {
            onError(e);
        }
        catch (SecurityException e)
        {
            onError(e);
        }
        catch (NoSuchMethodException e)
        {
            onError(e);
        }
        catch (IllegalArgumentException e)
        {
            onError(e);
        }
        catch (InvocationTargetException e)
        {
            onError(e);
        }

        if (clientFactory == null)
        {
            logger.error("Client Factory Not Configured For Specified Client Type : ");
            throw new ClientResolverException("Client Factory Not Configured For Specified Client Type.");
        }
        logger.info("Finishing factory initialization");
        return clientFactory;
    }
383415
@Override
    public Client getClientInstance()
    {
        // if threadsafe recycle the same single instance; if not create a new
        // instance

        if (isThreadSafe())
        {
            logger.info("Returning threadsafe used client instance for persistence unit : " + persistenceUnit);
            if (client == null)
            {
                client = instantiateClient(persistenceUnit);
            }
        }
        else
        {
            logger.debug("Returning fresh client instance for persistence unit : " + persistenceUnit);
            // no need to hold a client reference.
            return instantiateClient(persistenceUnit);
        }

        return client;
    }
1291189
private EntityMetadata belongsToPersistenceUnit(EntityMetadata metadata)
    {

        // if pu is null and client is not rdbms OR metadata pu does not match
        // with configured one. don't process for anything.

        PersistenceUnitMetadata puMetadata = kunderaMetadata.getApplicationMetadata()
                .getPersistenceUnitMetadata(persistenceUnit);
        String keyspace = puProperties != null ? (String) puProperties.get(PersistenceProperties.KUNDERA_KEYSPACE):null;
        
        keyspace = keyspace == null ? puMetadata.getProperty(PersistenceProperties.KUNDERA_KEYSPACE):keyspace;

        if (metadata.getPersistenceUnit() != null && !metadata.getPersistenceUnit().equals(persistenceUnit)
                || (keyspace != null && metadata.getSchema() != null && !metadata.getSchema().equals(keyspace)))
        {
            metadata = null;
        }
        else
        {
            applyMetadataChanges(metadata);
        }

        /*
         * if ((metadata.getPersistenceUnit() == null &&
         * !(Constants.RDBMS_CLIENT_FACTORY.equalsIgnoreCase(client) ||
         * Constants.NEO4J_CLIENT_FACTORY .equalsIgnoreCase(client))) ||
         * metadata.getPersistenceUnit() != null &&
         * !metadata.getPersistenceUnit().equals(persistenceUnit)) { metadata =
         * null; }
         */

        return metadata;
    }
341996
public <T> T getModel(Class<T> modelClass) {
		return (T)Injector.injectModel(modelClass, request, false);
	}
611905
public void addEntityMetadata(String persistenceUnit, Class<?> clazz, EntityMetadata entityMetadata)
    {
        Metamodel metamodel = getMetamodelMap().get(persistenceUnit);
        Map<String, EntityMetadata> entityClassToMetadataMap = ((MetamodelImpl) metamodel).getEntityMetadataMap();
        if (entityClassToMetadataMap == null || entityClassToMetadataMap.isEmpty())
        {
            entityClassToMetadataMap.put(clazz.getName(), entityMetadata);
        }
        else
        {
            if (logger.isDebugEnabled())
                logger.debug("Entity meta model already exists for persistence unit " + persistenceUnit + " and class "
                        + clazz + ". Noting needs to be done");
        }
    }
907829
@Override
    protected Client instantiateClient(String persistenceUnit)
    {
        
        return new SparkClient(kunderaMetadata, reader, externalProperties, persistenceUnit, sparkContext, sqlContext);
    }
722558
def ToManagedObject(self):
		
		from Ucs import ClassFactory

		cln = UcsUtils.WordU(self.classId)
		mo = ClassFactory(cln)
		if mo and (isinstance(mo, ManagedObject) == True):
			metaClassId = UcsUtils.FindClassIdInMoMetaIgnoreCase(self.classId)
			for property in self.properties:
				if UcsUtils.WordU(property) in UcsUtils.GetUcsPropertyMetaAttributeList(metaClassId):
					mo.setattr(UcsUtils.WordU(property), self.properties[property])
				else:
					# TODO: Add Warning/Error messages in Logger.
					WriteUcsWarning("Property %s Not Exist in MO %s" % (UcsUtils.WordU(property), metaClassId))

			if len(self.child):
				for ch in self.child:
					moch = ch.ToManagedObject()
					mo.child.append(moch)
			return mo
		else:
			return None
469425
public static synchronized EntityManagerProvider instance(String unitName, Map<String,String> overridingPersistenceProps) {
        overridingProperties = overridingPersistenceProps;
        return instance(unitName);
    }
534740
@Override
    public Object find(Class entityClass, Object key)
    {
        EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entityClass);

        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
                entityMetadata.getPersistenceUnit());

        AbstractManagedType managedType = (AbstractManagedType) metaModel.entity(entityMetadata.getEntityClazz());

        return managedType.hasLobAttribute() ? findGFSEntity(entityMetadata, entityClass, key) : find(entityClass, key,
                entityMetadata, metaModel, managedType);
    }