Skip to content

Commit

Permalink
Update AD_Process from AD_Process_Trl if trl is in base language
Browse files Browse the repository at this point in the history
#10232
Signed-off-by: TheBestPessimist <cristian@tbp.land>
  • Loading branch information
TheBestPessimist committed Nov 16, 2020
1 parent 2f68520 commit 495f66f
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,6 @@ default void registerTableProcess(final String tableName, final AdProcessId adPr
ImmutableList<I_AD_Process> getProcessesByType(Set<ProcessType> processTypeSet);

ImmutableList<I_AD_Process_Para> getProcessParamsByProcessIds(Set<Integer> processIDs);

void save(I_AD_Process process);
}
Original file line number Diff line number Diff line change
Expand Up @@ -602,4 +602,10 @@ public ImmutableList<I_AD_Process_Para> getProcessParamsByProcessIds(@NonNull fi
.stream()
.collect(ImmutableList.toImmutableList());
}

@Override
public void save(final I_AD_Process process)
{
InterfaceWrapperHelper.save(process);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* #%L
* de.metas.adempiere.adempiere.base
* %%
* Copyright (C) 2020 metas GmbH
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/

package de.metas.translation.interceptor;

import de.metas.i18n.Language;
import de.metas.process.AdProcessId;
import de.metas.process.IADProcessDAO;
import de.metas.util.Services;
import org.adempiere.ad.modelvalidator.annotations.Interceptor;
import org.adempiere.ad.modelvalidator.annotations.ModelChange;
import org.compiere.model.I_AD_Process;
import org.compiere.model.I_AD_Process_Trl;
import org.compiere.model.ModelValidator;
import org.springframework.stereotype.Component;

@Interceptor(I_AD_Process_Trl.class)
@Component
public class AD_Process_Trl
{
final IADProcessDAO processDAO = Services.get(IADProcessDAO.class);

@SuppressWarnings("ConstantConditions")
@ModelChange(timings = ModelValidator.TYPE_AFTER_CHANGE)
public void updateProcessNameFromTrl(final I_AD_Process_Trl processTrl)
{
if (!Language.isBaseLanguage(processTrl.getAD_Language()))
{
return;
}

final I_AD_Process process = processDAO.getById(AdProcessId.ofRepoId(processTrl.getAD_Process_ID()));
process.setName(processTrl.getName());
process.setDescription(processTrl.getDescription());
process.setHelp(processTrl.getHelp());
processDAO.save(process);
}
}

0 comments on commit 495f66f

Please sign in to comment.