Skip to content
This repository has been archived by the owner on Feb 4, 2025. It is now read-only.

Commit

Permalink
Merge pull request #4 from CampusDual/BFS42024-19
Browse files Browse the repository at this point in the history
BFS42024-19
  • Loading branch information
daemonowl12 authored Oct 17, 2024
2 parents 7f0230b + c285d52 commit 7418c2f
Show file tree
Hide file tree
Showing 15 changed files with 177 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ public interface IStudentBootcampService {

EntityResult studentBootcampInsert(Map<String, Object> attrMap) throws OntimizeJEERuntimeException;

EntityResult studentBootcampUpdate(Map<String, Object> attrMap, Map<String, Object> keyMap) throws OntimizeJEERuntimeException;
EntityResult studentBootcampDelete(Map<String, Object> keyMap) throws OntimizeJEERuntimeException;

EntityResult studentsWithBootcampQuery(Map<String, Object> keysValues, List<String> attributes);

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<o-table attr="studentsTable" service="students" entity="student" keys="id"
columns="id;name;surnames"
visible-columns="name;surnames" query-rows="2">
<o-table-column attr="name" title="Name"></o-table-column>
<o-table-column attr="surnames" title="Surnames"></o-table-column>
</o-table>
<o-form keys="id" service="bootcamps" entity="bootcamp">
<o-text-input attr="id" sql-type="INTEGER" enabled="no"></o-text-input>
<o-table attr="studentsBootcampTable" service="studentBootcamps" entity="studentsWithBootcamp" keys="id"
parent-keys="bootcamp_id:id"
columns="id;name;surnames"
visible-columns="name;surnames" query-rows="10"
detail-mode="false"
delete-button="false">
</o-table>
</o-form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
<o-table attr="studentsTable" service="students" entity="student" keys="id"
columns="id;name;surnames;email"
visible-columns="name;surnames;email" query-rows="3">
</o-table> -->

<o-form #studentBootcampForm service="studentBootcamps" entity="studentBootcamp" editable-detail="no" show-header="no">
<o-text-input attr="bootcamp_id" sql-type="INTEGER" enabled="no"></o-text-input>
<o-combo
attr="student_id"
label="Students"
value-column="id"
columns="id;name;surnames"
service ="students"
entity="student"
visible-columns="name;surnames"
searchable="yes">
</o-combo>

</o-form>
<o-button label="Add" (click)="addStudentBootcamp()"></o-button>
<o-button label="Return" (click)="navigateBack()"></o-button>

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { StudentBootcampAddComponent } from './student-bootcamp-add.component';

describe('StudentBootcampAddComponent', () => {
let component: StudentBootcampAddComponent;
let fixture: ComponentFixture<StudentBootcampAddComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ StudentBootcampAddComponent ]
})
.compileComponents();

fixture = TestBed.createComponent(StudentBootcampAddComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Component, ViewChild } from '@angular/core';
import { OFormComponent } from 'ontimize-web-ngx';

@Component({
selector: 'app-student-bootcamp-add',
templateUrl: './student-bootcamp-add.component.html',
styleUrls: ['./student-bootcamp-add.component.css']
})
export class StudentBootcampAddComponent {

@ViewChild('studentBootcampForm') studentBootcampForm:OFormComponent;

addStudentBootcamp() {
this.studentBootcampForm.insert();
}


navigateBack() {
window.history.back();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
show-charts-on-demand-option="false"
delete-button="false"
selection-mode="none"
detail-mode="false"
>

<o-table-paginator
Expand All @@ -22,6 +21,7 @@
</o-table-context-menu>

<o-table-column

attr="name" title="name"
type="string" content-align="center"
title-align="center"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ import { ActivatedRoute, Router } from '@angular/router';
styleUrls: ['./bootcamp-list.component.css']
})
export class BootcampListComponent {

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { BootcampDetailsComponent } from './bootcamp-details/bootcamp-details.component';
import { BootcampListComponent } from './bootcamp-list/bootcamp-list.component';
import { StudentBootcampAddComponent } from './bootcamp-details/student-bootcamp-add/student-bootcamp-add.component';

const routes: Routes = [
//AQUI ES DONDE REDIRIGIMOS A LA LISTA SI ESTA VACIA
{path:"",redirectTo:"list",pathMatch:"full"},
{path:"list",component:BootcampListComponent}];
{path:"list",component:BootcampListComponent},
{path:'list/:id', component: BootcampDetailsComponent},
{path:'list/:bootcamp_id/new', component: StudentBootcampAddComponent}
];

@NgModule({
imports: [RouterModule.forChild(routes)],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import { BootcampsRoutingModule } from './bootcamps-routing.module';
import { BootcampDetailsComponent } from './bootcamp-details/bootcamp-details.component';
import { OntimizeWebModule } from 'ontimize-web-ngx';
import { BootcampListComponent } from './bootcamp-list/bootcamp-list.component';
import { StudentBootcampAddComponent } from './bootcamp-details/student-bootcamp-add/student-bootcamp-add.component';


@NgModule({
declarations: [
BootcampListComponent,
BootcampDetailsComponent
BootcampDetailsComponent,
StudentBootcampAddComponent
],
imports: [
CommonModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ export const SERVICE_CONFIG: Object = {
'bootcamps':{
'path': '/bootcamps'
}
,
'studentBootcamps':{
'path': '/studentBootcamps'
}

};
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package com.campusdual.cd2024bfs4g1.model.core.dao;

import com.ontimize.jee.common.dto.EntityResult;
import com.ontimize.jee.common.dto.EntityResultMapImpl;
import com.ontimize.jee.server.dao.common.ConfigurationFile;
import com.ontimize.jee.server.dao.jdbc.OntimizeJdbcDaoSupport;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Lazy
@Repository(value = "StudentBootcampDao")
@ConfigurationFile(
Expand All @@ -14,4 +19,6 @@ public class StudentBootcampDao extends OntimizeJdbcDaoSupport {
public static final String TABLE_ID = "ID";
public static final String STUDENT_ID = "STUDENT_ID";
public static final String BOOTCAMP_ID = "BOOTCAMP_ID";


}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.campusdual.cd2024bfs4g1.model.core.service;

import com.campusdual.cd2024bfs4g1.api.core.service.IStudentBootcampService;
import com.campusdual.cd2024bfs4g1.model.core.dao.StudentBootcampDao;
import com.ontimize.jee.common.dto.EntityResult;
import com.ontimize.jee.common.dto.EntityResultMapImpl;
import com.ontimize.jee.common.exceptions.OntimizeJEERuntimeException;
import com.ontimize.jee.server.dao.DefaultOntimizeDaoHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("StudentBootcampService")
@Lazy
public class StudentBootcampService implements IStudentBootcampService {

@Autowired
private StudentBootcampDao studentBootcampDao;

@Autowired
private DefaultOntimizeDaoHelper daoHelper;

@Override
public EntityResult studentBootcampInsert(Map<String, Object> attrMap) throws OntimizeJEERuntimeException {
try {
return this.daoHelper.insert(this.studentBootcampDao, attrMap);
} catch (DuplicateKeyException e) {
EntityResult entityResultError = new EntityResultMapImpl();
entityResultError.setCode(EntityResult.OPERATION_WRONG);
entityResultError.setMessage("The student already exists in the bootcamp");
return entityResultError;
} catch (Exception generalException) {
throw generalException;
}
}

@Override
public EntityResult studentBootcampDelete(Map<String, Object> keyMap) throws OntimizeJEERuntimeException {
return this.daoHelper.delete(this.studentBootcampDao, keyMap);
}
@Override
public EntityResult studentsWithBootcampQuery(Map<String, Object> keysValues, List<String> attributes) {
return this.daoHelper.query(this.studentBootcampDao, keysValues, attributes);
}
}
26 changes: 25 additions & 1 deletion cd2024bfs4g1-model/src/main/resources/dao/StudentBootcampDao.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<JdbcEntitySetup xmlns="http://www.ontimize.com/schema/jdbc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ontimize.com/schema/jdbc http://www.ontimize.com/schema/jdbc/ontimize-jdbc-dao.xsd"
catalog="" schema="${mainschema}" table="studentbootcamp" datasource="mainDataSource"
catalog="" schema="${mainschema}" table="student_bootcamp" datasource="mainDataSource"
sqlhandler="dbSQLStatementHandler">

<DeleteKeys>
Expand All @@ -12,5 +12,29 @@
<Column>id</Column>
</UpdateKeys>
<GeneratedKey>id</GeneratedKey>
<Queries>
<Query id="default">
<AmbiguousColumns>
<AmbiguousColumn name="id" prefix="sb"/>
<AmbiguousColumn name="name" prefix="s"/>
<AmbiguousColumn name="studentname" prefix="s" databaseName="name" />
<AmbiguousColumn name="bootcampname" prefix="b" databaseName="name" />

</AmbiguousColumns>

<Sentence>
<![CDATA[
select
#COLUMNS#
from
students s
inner join
student_bootcamp sb on s.id = sb.student_id
inner join
bootcamps b on sb.bootcamp_id = b.id
#WHERE#
]]>
</Sentence>
</Query>
</Queries>
</JdbcEntitySetup>

0 comments on commit 7418c2f

Please sign in to comment.