| /* |
| * Copyright (c) 2010-2021 BSI Business Systems Integration AG. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * BSI Business Systems Integration AG - initial API and implementation |
| */ |
| package org.eclipse.scout.rt.dataobject.migration.fixture.house; |
| |
| import java.util.Set; |
| |
| import org.eclipse.scout.rt.dataobject.IDoEntity; |
| import org.eclipse.scout.rt.dataobject.ITypeVersion; |
| import org.eclipse.scout.rt.dataobject.migration.AbstractDoStructureMigrationHandler; |
| import org.eclipse.scout.rt.dataobject.migration.DoStructureMigrationContext; |
| import org.eclipse.scout.rt.dataobject.migration.fixture.version.CharlieFixtureTypeVersions.CharlieFixture_4; |
| import org.eclipse.scout.rt.platform.IgnoreBean; |
| import org.eclipse.scout.rt.platform.util.CollectionUtility; |
| |
| @IgnoreBean |
| public class RoomFixtureDoStructureMigrationHandler_4 extends AbstractDoStructureMigrationHandler { |
| |
| @Override |
| public Class<? extends ITypeVersion> toTypeVersionClass() { |
| return CharlieFixture_4.class; |
| } |
| |
| /** |
| * References {@link RoomFixtureDo}. |
| */ |
| @Override |
| public Set<String> getTypeNames() { |
| return CollectionUtility.hashSet("charlieFixture.RoomFixture"); |
| } |
| |
| @Override |
| public boolean migrate(DoStructureMigrationContext ctx, IDoEntity doEntity) { |
| if (!doEntity.has("areaInSquareFoot")) { |
| // already migrated or nothing to migrate |
| return false; |
| } |
| |
| Integer areaInSquareFoot = doEntity.get("areaInSquareFoot", Integer.class); |
| if (areaInSquareFoot != null) { |
| int areaInSquareMeter = Math.round(areaInSquareFoot.intValue() / 10.764f); |
| doEntity.put("areaInSquareMeter", areaInSquareMeter); |
| } |
| doEntity.remove("areaInSquareFoot"); |
| |
| return true; |
| } |
| } |