Ich bin in einem Unternehmen in einem Praktikum, wo ich in JS mit SAPUI5 Framework codieren muss. Es ist völlig neu für mich, deshalb habe ich das Tutorial unter http://sapui5.hana.ondemand.com verfolgt. Aber jetzt habe ich ein Problem, ich kann keine Beratung im Internet finden, und ich kann nicht immer meine Kollegen bitten, mir zu helfen, sie haben auch einen Job ...SAPUI5 Metadata.xml: Binding zwei Entitäten
Ich muss eine Planung mit machen viele Mitarbeiter und ihre Aufgabe. Ich arbeite mit einem mockserver mit einer Datei metadata.xml:
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"
Version="1.0">
<edmx:DataServices
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
m:DataServiceVersion="1.0">
<Schema xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns="http://schemas.microsoft.com/ado/2008/09/edm" Namespace="NorthwindModel">
<EntityType Name="Employee">
<Key>
<PropertyRef Name="EmployeeID" />
</Key>
<Property xmlns:p8="http://schemas.microsoft.com/ado/2009/02/edm/annotation"
Name="EmployeeID" Type="Edm.Int32" Nullable="false"
p8:StoreGeneratedPattern="Identity" />
<Property Name="LastName" Type="Edm.String" Nullable="false"
MaxLength="20" Unicode="true" FixedLength="false" />
<Property Name="City" Type="Edm.String" Nullable="false"/>
<Property Name="Team" Type="Edm.String" Nullable="false"/>
<NavigationProperty Name="Appointments" Relationship="NorthwindModel.FK_Employees_Appointment"
FromRole="Employees" ToRole="Appointments"/>
</EntityType>
<EntityType Name="Appointment">
<Key>
<PropertyRef Name="AppointmentID"/>
</Key>
<Property Name="AppointmentID" Type="Edm.Int32" Nullable="false"/>
<Property Name="EmployeeID" Type="Edm.Int32" Nullable="false"/>
<Property Name="start" Type="Edm.DateTime" Nullable="false"/>
<Property Name="end" Type="Edm.DateTime" Nullable="false"/>
<Property Name="title" Type="Edm.String" Nullable="false"/>
<NavigationProperty Name="Employees" Relationship="NorthwindModel.FK_Employees_Appointment"
ToRole="Employees" FromRole="Appointments"/>
</EntityType>
<Association Name="FK_Employees_Appointment">
<End Type="Employee" Role="Employees" Multiplicity="1" />
<End Type="Appointment" Role="Appointments" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Employees">
<PropertyRef Name="EmployeeID" />
</Principal>
<Principal Role="Appointments">
<PropertyRef Name="EmployeeID" />
</Principal>
</ReferentialConstraint>
</Association>
</Schema>
<Schema xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns="http://schemas.microsoft.com/ado/2008/09/edm" Namespace="ODataWeb.Northwind.Model">
<EntityContainer
xmlns:p7="http://schemas.microsoft.com/ado/2009/02/edm/annotation"
Name="NorthwindEntities" p7:LazyLoadingEnabled="true"
m:IsDefaultEntityContainer="true">
<EntitySet Name="Employees" EntityType="NorthwindModel.Employee" />
<EntitySet Name="Appointments" EntityType="NorthwindModel.Appointment"/>
<AssociationSet Name="FK_Employees_Appointments" Association="NorthwindModel.FK_Employees_Appointment">
<End Role="Employees" EntitySet="Employees"/>
<End Role="Appointments" EntitySet="Appointments"/>
</AssociationSet>
</EntityContainer>
</Schema>
</edmx:DataServices>
(für Tags AssociationSet und Navigation, ich tat es, weil ich auf dem OData-Dienst ich gesehen habe, aber ich weiß nicht versteht es, ich vermuten, es wird gut ...)
nun die Appointments.json Datei:
[
{
"AppointmentID" : 0,
"EmployeeID" : 0,
"start":"\/Date(1466416800000)\/",
"end":"\/Date(1466424000000)\/",
"title": "test"
},{
"AppointmentID" : 1,
"EmployeeID" : 1,
"start":"\/Date(1466409600000)\/",
"end":"\/Date(1466416800000)\/",
"title": "test2"
}]
die Employees.json Datei:
[
{
"EmployeeID":0,
"LastName":"APERCE",
"City":"Paris",
"Team":"Dev"
},
{
"EmployeeID":1,
"LastName":"HACHMI",
"City":"Lille",
"Team":"Dev"
},
{
"EmployeeID":2,
"LastName":"MILLET",
"City":"Paris",
"Team":"Admin"
},
{
"EmployeeID":3,
"LastName":"CORNET",
"City":"Poitiers",
"Team":"Admin"
},
{
"EmployeeID":4,
"LastName":"EVAIN",
"City":"Paris",
"Team":"R&D"
}]
(Wie Sie sehen können, ist die EmployeeID auf beiden Appointments.json et Employees.json)
Und schließlich die Overview.view.xml Datei:
<mvc:View controllerName="sap.ui.demo.wt.controller.Overview"
xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc" xmlns:semantic="sap.m.semantic"
xmlns:unified="sap.ui.unified"
xmlns:core="sap.ui.core" displayBlock="true">
<semantic:FullscreenPage title="{i18n>overviewPageTitle}">
<VBox>
<PlanningCalendar startDate="{path : '/Startdate'}" rows="{path : 'data>/Employees',parameters:{expand:'Appointments'}}"
appointmentSelect="handleAppointmentSelect">
<rows>
<PlanningCalendarRow title="{data>LastName}"
appointments="{path : 'data>Appointments',templateShareable:true}">
<appointments>
<unified:CalendarAppointment
startDate="{data>start}"
endDate="{data>end}"
title="{data>title}">
</unified:CalendarAppointment>
</appointments>
</PlanningCalendarRow>
</rows>
</PlanningCalendar>
</VBox>
</semantic:FullscreenPage>
(das "Daten" -Modell bindet bereits mit der metadata.xml und ruft sowohl Appointments.json als auch Employees.json ab)
Eigentlich dieser Code Zeigt die beiden Aufgaben von "Appointments.json" für jeden Mitarbeiter in meiner Planung an. Ich möchte es binden, um den Termin "test" nur für den Angestellten "APERCE" und "test2" nur für "HACHMI" zu haben, aber ich kann nicht.
Ich glaube, dass es möglich ist, etwas zu tun, das einem JOIN für eine SQL-Datenbank entspricht, aber ich finde nichts darüber. Wie soll ich das machen? Danke für deine Antworten.
PS: Ich bin Französisch, wenn Sie nicht verstehen, was ich oben geschrieben habe, sorry; und wenn Sie auf Französisch antworten können, tun Sie es, es wird besser für mein Verständnis sein.
EDIT: Ich habe den Code nach nistv4n's Empfehlungen korrigiert. Jetzt bekomme ich folgende Fehler:
MockServer: Ressource nicht für das Segment ‚Termin‘ gefunden => Ich verstehe, dass das Segment ‚Termin‘ existiert nicht, da es ‚Termin s‘, aber ich don‘ Ich weiß, wo ich das 'S' vergessen habe.
Folgendes Problem ist aufgetreten: HTTP-Anforderung failed404, Not Found, {"Fehler": {"code": 404, "message": {"lang": "en", "value": "Ressource nicht gefunden für das Segment 'Termin' "}}} => Ich nehme an, es ist mit dem vorherigen Fehler verbunden, weil es nach 'Termin' statt 'Termin s' fragt?
REEDIT: Ich legte das 's' an den richtigen Stellen. Jetzt habe ich nur: Kann die Eigenschaft 'getTime' von undefined => nicht lesen, weil ein Problem mit dem in Overview.view verwendeten Modell vorliegt.xml, wahrscheinlich in der, aber es ist das gleiche, wenn ich verwende: "{Termine/start}", "{Termine> start}", "{start}" oder "{/ Termine> start}".
LASTEDIT: Dank nistv4n habe ich es endlich geschafft. Ich habe meinen Code oben aktualisiert, wenn Sie das gleiche Problem haben. Der richtige Code ist in PlanningCalendarRow =>Termine = "{path: 'data> Termine'}" und in einheitlicher: CalendarAppointment =>startdate = "{data> start}" etc ...
Eigentlich , um nistv4n zu zitieren: "Appointments hat einen relativen Verweis, und innere Eigenschaften (Start, Ende, Titel) haben auch einen relativen Verweis, einschließlich des Modellnamens."
was ist mit startDate = "{daten> start}", endDate = "{daten> end}", title = "{daten> titel}". –
Jeder Mitarbeiter hat die Aufgaben "test" und "test2". Aber ich will nur für "APERCE" und "test2" nur für "HACHMI" "testen", und nichts für die anderen Mitarbeiter. – Nicaps
@Ash eigentlich hatten Sie Recht, das Problem lag in der PlanningCalendarRow. Vielen Dank ! – Nicaps