/*
 * 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.
 */
package org.apache.rave.portal.repository.impl;

import org.apache.rave.portal.model.JpaPageTemplate;
import org.apache.rave.model.PageTemplate;
import org.apache.rave.portal.model.conversion.JpaConverter;
import org.apache.rave.portal.repository.PageTemplateRepository;
import org.apache.rave.util.CollectionUtils;
import org.springframework.stereotype.Repository;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import java.util.List;

import static org.apache.rave.persistence.jpa.util.JpaUtil.saveOrUpdate;

@Repository
public class JpaPageTemplateRepository implements PageTemplateRepository {

    @PersistenceContext
    private EntityManager manager;

    @Override
    public List<PageTemplate> getAll() {
        TypedQuery<JpaPageTemplate> query = manager.createNamedQuery(JpaPageTemplate.PAGE_TEMPLATE_GET_ALL, JpaPageTemplate.class);
        return CollectionUtils.<PageTemplate>toBaseTypedList(query.getResultList());
    }

    @Override
    public JpaPageTemplate getDefaultPage(String pageType) {
        TypedQuery<JpaPageTemplate> query = manager.createNamedQuery(JpaPageTemplate.PAGE_TEMPLATE_GET_DEFAULT_PAGE_BY_TYPE, JpaPageTemplate.class);
        query.setParameter("pageType", pageType.toUpperCase());
        return query.getSingleResult();
    }

    @Override
    public PageTemplate save(PageTemplate template) {
        return (PageTemplate) saveOrUpdate(template.getId(), manager, JpaConverter.getInstance().convert(template, PageTemplate.class));
    }
}
@@ -866,24 +866,81 @@
 ry.impl;%0D%0A%0D%0A
+import org.apache.commons.lang.NotImplementedException;%0D%0A
 import org.a
@@ -1910,32 +1910,571 @@
 t());%0D%0A    %7D%0D%0A%0D%0A
+    @Override%0D%0A    public List%3CPageTemplate%3E getLimitedList(int offset, int limit) %7B%0D%0A        return null;  //To change body of implemented methods use File %7C Settings %7C File Templates.%0D%0A    %7D%0D%0A%0D%0A    @Override%0D%0A    public int getCountAll() %7B%0D%0A        return 0;  //To change body of implemented methods use File %7C Settings %7C File Templates.%0D%0A    %7D%0D%0A%0D%0A    @Override%0D%0A    public List%3CPageTemplate%3E getAllForType(String pageType) %7B%0D%0A        return null;  //To change body of implemented methods use File %7C Settings %7C File Templates.%0D%0A    %7D%0D%0A%0D%0A
     @Override%0D%0A 
@@ -2791,32 +2791,313 @@
 lt();%0D%0A    %7D%0D%0A%0D%0A
+    @Override%0D%0A    public Class%3C? extends PageTemplate%3E getType() %7B%0D%0A        return PageTemplate.class;%0D%0A    %7D%0D%0A%0D%0A    @Override%0D%0A    public PageTemplate get(String id) %7B%0D%0A        return null;  //To change body of implemented methods use File %7C Settings %7C File Templates.%0D%0A    %7D%0D%0A%0D%0A
     @Override%0D%0A 
@@ -3294,10 +3294,125 @@
 %0D%0A    %7D%0D
+%0A%0D%0A    @Override%0D%0A    public void delete(PageTemplate item) %7B%0D%0A        throw new NotImplementedException();%0D%0A    %7D%0D
 %0A%7D

Update JPA (RAVE-1062)